diff --git a/.github/workflows/buildwheel.yml b/.github/workflows/buildwheel.yml index 9b48d669..edb3d42b 100644 --- a/.github/workflows/buildwheel.yml +++ b/.github/workflows/buildwheel.yml @@ -10,7 +10,14 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-22.04, ubuntu-22.04-arm, windows-2022, macos-15-intel, macos-14] + os: [ + ubuntu-22.04, + ubuntu-22.04-arm, + windows-2022, + windows-11-arm, + macos-15-intel, + macos-14, + ] steps: - uses: actions/checkout@v6.0.1 @@ -22,7 +29,12 @@ jobs: - uses: msys2/setup-msys2@v2.29.0 with: msystem: mingw64 - if: ${{ startsWith( matrix.os , 'windows' ) }} + if: ${{ matrix.os == 'windows-2022' }} + + - uses: msys2/setup-msys2@v2.29.0 + with: + msystem: clangarm64 + if: ${{ matrix.os == 'windows-11-arm' }} # Install pkgconfig on Windows from choco rather than from msys and # avoid using the Strawberry one. @@ -34,11 +46,30 @@ jobs: - run: echo "PKG_CONFIG_PATH=${{ github.workspace }}/.local/lib/pkgconfig" >> $env:GITHUB_ENV if: ${{ startsWith( matrix.os , 'windows' ) }} - - name: Build wheels + # We need to set these environment variables here rather than + # pyproject.toml so we can use differnt values for different + # architectures. For non-Windows this is just done with $(uname -m) + # don't know what that would do in msys2 on Windows when cibuildwheel + # parses it. + + - name: Build wheels for windows-2022 + uses: pypa/cibuildwheel@63fd63b352a9a8bdcc24791c9dbee952ee9a8abc # v3.3.0 + if: ${{ matrix.os == 'windows-2022' }} + env: + CIBW_BEFORE_ALL_WINDOWS: msys2 -c bin/cibw_before_all_windows_amd64.sh + + - name: Build wheels for windows-11-arm uses: pypa/cibuildwheel@63fd63b352a9a8bdcc24791c9dbee952ee9a8abc # v3.3.0 + if: ${{ matrix.os == 'windows-11-arm' }} env: - # override setting in pyproject.toml to use msys2 instead of msys64 bash - CIBW_BEFORE_ALL_WINDOWS: msys2 -c bin/cibw_before_all_windows.sh + CIBW_BEFORE_ALL_WINDOWS: msys2 -c bin/cibw_before_all_windows_arm64.sh + + # After all the Windows-specific steps above this is what actually + # builds the wheels for every other OS: + + - name: Build wheels for any other OS + uses: pypa/cibuildwheel@63fd63b352a9a8bdcc24791c9dbee952ee9a8abc # v3.3.0 + if: ${{ !startsWith( matrix.os , 'windows' ) }} - uses: actions/upload-artifact@v5 with: @@ -78,6 +109,7 @@ jobs: ubuntu-24.04-arm, windows-2022, windows-2025, + windows-11-arm, macos-15-intel, macos-14, macos-15, diff --git a/bin/build_dependencies_unix.sh b/bin/build_dependencies_unix.sh index 6dfdeb12..aaec4531 100755 --- a/bin/build_dependencies_unix.sh +++ b/bin/build_dependencies_unix.sh @@ -18,6 +18,8 @@ set -o errexit SKIP_GMP=no SKIP_MPFR=no +FAT_GMP_ARG="--enable-fat" +PATCH_LDD=no USE_GMP=gmp PATCH_GMP_ARM64=no @@ -37,6 +39,8 @@ do echo " --host - set the host (target) for GMP build" echo " --skip-gmp - skip building GMP" echo " --skip-mpfr - skip building MPFR" + echo " --disable-fat - disable building fat binaries" + echo " --patch-ldd - patch flint to work with ldd (for mingw on arm64)" echo echo "Legacy options:" echo " --gmp gmp - build based on GMP (default)" @@ -83,6 +87,11 @@ do SKIP_MPFR=yes shift ;; + --disable-fat) + # Disable building fat binaries + FAT_GMP_ARG="--disable-assembly" + shift + ;; --patch-gmp-arm64) # Needed only for GMP 6.2.1 on OSX arm64 (Apple M1) hardware # As of GMP 6.3.0 this patch is no longer needed @@ -94,6 +103,11 @@ do PATCH_GMP_C23=yes shift ;; + --patch-ldd) + # Needed only for GMP 6.3.0 on OSX arm64 (Apple M1) hardware + PATCH_LDD=yes + shift + ;; --use-gmp-github-mirror) USE_GMP_GITHUB_MIRROR=yes shift @@ -190,7 +204,7 @@ if [ $USE_GMP = "gmp" ]; then ./configfsf.guess ./configure --prefix=$PREFIX\ - --enable-fat\ + $FAT_GMP_ARG\ --enable-shared=yes\ --enable-static=no\ --host=$HOST_ARG @@ -309,6 +323,15 @@ echo curl -O -L https://github.com/flintlib/flint/releases/download/v$FLINTVER/flint-$FLINTVER.tar.gz tar xf flint-$FLINTVER.tar.gz cd flint-$FLINTVER + + if [ $PATCH_LDD = "yes" ]; then + echo + echo -------------------------------------------- + echo " patching FLINT" + echo -------------------------------------------- + patch -N -Z -p1 < ../../../bin/patch-ldd.diff + fi + ./bootstrap.sh ./configure --prefix=$PREFIX\ --host=$HOST_ARG\ diff --git a/bin/cibw_before_all_windows.sh b/bin/cibw_before_all_windows_amd64.sh similarity index 100% rename from bin/cibw_before_all_windows.sh rename to bin/cibw_before_all_windows_amd64.sh diff --git a/bin/cibw_before_all_windows_arm64.sh b/bin/cibw_before_all_windows_arm64.sh new file mode 100755 index 00000000..01c38ced --- /dev/null +++ b/bin/cibw_before_all_windows_arm64.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +set -o errexit + +pacman -S --noconfirm \ + mingw-w64-clang-aarch64-toolchain\ + mingw-w64-clang-aarch64-tools-git\ + m4\ + make\ + base-devel\ + autoconf-wrapper\ + automake-wrapper\ + libtool\ + git\ + # + +bin/build_dependencies_unix.sh \ + --disable-fat\ + --use-gmp-github-mirror\ + --patch-C23\ + --patch-ldd\ + # diff --git a/bin/patch-ldd.diff b/bin/patch-ldd.diff new file mode 100644 index 00000000..81b06b92 --- /dev/null +++ b/bin/patch-ldd.diff @@ -0,0 +1,36 @@ +diff --git a/Makefile.in b/Makefile.in +index 0f25aa2b5..937fffa10 100644 +--- a/Makefile.in ++++ b/Makefile.in +@@ -416,14 +416,7 @@ endif + ifneq ($(SHARED), 0) + shared: $(FLINT_DIR)/$(FLINT_LIB_FULL) + +-# The following is to avoid reaching the maximum length of command line +-# arguments, mainly present on MinGW. +-define xxx_merged_lobj_rule +-$(BUILD_DIR)/$(1)_merged.lo: $($(1)_LOBJS) | $(BUILD_DIR) +- @$(LD) -r $($(1)_LOBJS) -o $(BUILD_DIR)/$(1)_merged.lo +-endef +-$(foreach dir, $(DIRS), $(eval $(call xxx_merged_lobj_rule,$(dir)))) +-MERGED_LOBJS:=$(foreach dir, $(DIRS),$(BUILD_DIR)/$(dir)_merged.lo) ++MERGED_LOBJS:=$(foreach dir,$(DIRS),$($(dir)_LOBJS)) + + $(FLINT_DIR)/$(FLINT_LIB_FULL): $(MERGED_LOBJS) + @echo "Building $(FLINT_LIB_FULL)" +@@ -437,14 +430,7 @@ endif + ifneq ($(STATIC), 0) + static: $(FLINT_DIR)/$(FLINT_LIB_STATIC) + +-# The following is to avoid reaching the maximum length of command line +-# arguments, mainly present on MinGW. +-define xxx_merged_obj_rule +-$(BUILD_DIR)/$(1)_merged.o: $($(1)_OBJS) | $(BUILD_DIR) +- @$(LD) -r $($(1)_OBJS) -o $(BUILD_DIR)/$(1)_merged.o +-endef +-$(foreach dir, $(DIRS), $(eval $(call xxx_merged_obj_rule,$(dir)))) +-MERGED_OBJS:=$(foreach dir, $(DIRS),$(BUILD_DIR)/$(dir)_merged.o) ++MERGED_OBJS:=$(foreach dir,$(DIRS),$($(dir)_OBJS)) + + $(FLINT_DIR)/$(FLINT_LIB_STATIC): $(MERGED_OBJS) + @echo "Building $(FLINT_LIB_STATIC)"