Skip to content

Commit 9946621

Browse files
committed
maint: patch GMP for macos arm64
1 parent 2cb2eee commit 9946621

File tree

3 files changed

+564
-3
lines changed

3 files changed

+564
-3
lines changed

bin/build_dependencies_unix.sh

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,15 @@ set -o errexit
99
# #
1010
# Supported options: #
1111
# #
12-
# --gmp gmp - build based on GMP (default) #
13-
# --gmp mpir - build based on MPIR (instead of GMP) #
12+
# --gmp gmp - build based on GMP (default) #
13+
# --gmp mpir - build based on MPIR (no longer works) #
14+
# --host <HOST> - set the host (target) for GMP build #
15+
# --patch-gmp-arm64 - apply patch to GMP for OSX arm64 #
1416
# #
1517
# ------------------------------------------------------------------------- #
1618

1719
USE_GMP=gmp
20+
PATCH_GMP_ARM64=no
1821

1922
while [[ $# -gt 0 ]]
2023
do
@@ -41,6 +44,14 @@ do
4144
shift
4245
shift
4346
;;
47+
--patch-gmp-arm64)
48+
PATCH_GMP_ARM64=yes
49+
shift
50+
;;
51+
*)
52+
2>&1 echo "unrecognised argument:" $key
53+
exit 1
54+
;;
4455
esac
4556
done
4657

@@ -74,6 +85,23 @@ if [ $USE_GMP = "gmp" ]; then
7485
curl -O https://gmplib.org/download/gmp/gmp-$GMPVER.tar.xz
7586
tar xf gmp-$GMPVER.tar.xz
7687
cd gmp-$GMPVER
88+
89+
#
90+
# See https://github.com/aleaxit/gmpy/issues/350
91+
#
92+
# We need to patch GMP for OSX arm64 (Apple M1) hardware. This patch is
93+
# from the GMP repo but was applied after the release of GMP 6.2.1.
94+
# Hopefully when a newer version of GMP is released we will not need to
95+
# apply this patch any more.
96+
#
97+
if [ $PATCH_GMP_ARM64 = "yes" ]; then
98+
echo
99+
echo --------------------------------------------
100+
echo " patching GMP"
101+
echo --------------------------------------------
102+
patch -N -Z -p0 < ../../../bin/patch-arm64.diff
103+
fi
104+
77105
# Show the output of configfsf.guess
78106
./configfsf.guess
79107
./configure --prefix=$PREFIX\
@@ -109,6 +137,18 @@ else
109137
# #
110138
# ----------------------------------------------------------------------- #
111139

140+
#
141+
# The mpir.org domain has expired and no longer hosts the source code so the
142+
# call to curl below will fail.
143+
# We could try to download from https://github.com/wbhart/mpir/releases.
144+
#
145+
# Ultimately it seems that MPIR is no longer maintained though so for now
146+
# this remains unfixed.
147+
#
148+
149+
>&2 echo "MPIR build of python_flint is no longer supported"
150+
exit 1
151+
112152
curl -O http://mpir.org/mpir-$MPIRVER.tar.bz2
113153
tar xf mpir-$MPIRVER.tar.bz2
114154
cd mpir-$MPIRVER

bin/cibw_before_all_macosx_arm64.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ export LDFLAGS=" -arch arm64"
55

66
bin/build_dependencies_unix.sh\
77
--gmp gmp\
8-
--host aarch64-apple-darwin
8+
--host aarch64-apple-darwin\
9+
--patch-gmp-arm64

0 commit comments

Comments
 (0)