Skip to content

Commit 447fb86

Browse files
committed
Add patch for Apple cross compilation on 3.13+
1 parent 7966b24 commit 447fb86

File tree

2 files changed

+86
-2
lines changed

2 files changed

+86
-2
lines changed

cpython-unix/build-cpython.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,7 @@ pushd Python-${PYTHON_VERSION}
7373

7474
# configure doesn't support cross-compiling on Apple. Teach it.
7575
if [ "${PYTHON_MAJMIN_VERSION}" = "3.13" ]; then
76-
# TODO: Add support for cross-compiling on 3.13
77-
:
76+
patch -p1 -i ${ROOT}/patch-apple-cross-3.13.patch
7877
elif [ "${PYTHON_MAJMIN_VERSION}" = "3.12" ]; then
7978
patch -p1 -i ${ROOT}/patch-apple-cross-3.12.patch
8079
else
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
diff --git a/configure.ac b/configure.ac
2+
index c62a565eb6..7e5d34632c 100644
3+
--- a/configure.ac
4+
+++ b/configure.ac
5+
@@ -545,6 +545,15 @@ then
6+
*-*-cygwin*)
7+
ac_sys_system=Cygwin
8+
;;
9+
+ *-apple-ios*)
10+
+ ac_sys_system=iOS
11+
+ ;;
12+
+ *-apple-tvos*)
13+
+ ac_sys_system=tvOS
14+
+ ;;
15+
+ *-apple-watchos*)
16+
+ ac_sys_system=watchOS
17+
+ ;;
18+
*-*-vxworks*)
19+
ac_sys_system=VxWorks
20+
;;
21+
@@ -600,6 +609,19 @@ if test "$cross_compiling" = yes; then
22+
*-*-cygwin*)
23+
_host_cpu=
24+
;;
25+
+ *-*-darwin*)
26+
+ _host_cpu=
27+
+ ;;
28+
+ *-apple-*)
29+
+ case "$host_cpu" in
30+
+ arm*)
31+
+ _host_cpu=arm
32+
+ ;;
33+
+ *)
34+
+ _host_cpu=$host_cpu
35+
+ ;;
36+
+ esac
37+
+ ;;
38+
*-*-vxworks*)
39+
_host_cpu=$host_cpu
40+
;;
41+
@@ -614,6 +636,23 @@ if test "$cross_compiling" = yes; then
42+
_PYTHON_HOST_PLATFORM="$MACHDEP${_host_cpu:+-$_host_cpu}"
43+
fi
44+
45+
+# The _PYTHON_HOST_PLATFORM environment variable is used to
46+
+# override the platform name in distutils and sysconfig when
47+
+# cross-compiling. On Apple, the platform name expansion logic
48+
+# is non-trivial, including renaming MACHDEP=darwin to macosx
49+
+# and including the deployment target (or current OS version if
50+
+# not set). Here we always force an override based on the target
51+
+# triple. We do this in all build configurations because historically
52+
+# the automatic resolution has been brittle.
53+
+case "$host" in
54+
+aarch64-apple-darwin*)
55+
+ _PYTHON_HOST_PLATFORM="macosx-${MACOSX_DEPLOYMENT_TARGET}-arm64"
56+
+ ;;
57+
+x86_64-apple-darwin*)
58+
+ _PYTHON_HOST_PLATFORM="macosx-${MACOSX_DEPLOYMENT_TARGET}-x86_64"
59+
+ ;;
60+
+esac
61+
+
62+
# Some systems cannot stand _XOPEN_SOURCE being defined at all; they
63+
# disable features if it is defined, without any means to access these
64+
# features as extensions. For these systems, we skip the definition of
65+
@@ -1582,7 +1621,7 @@ if test $enable_shared = "yes"; then
66+
BLDLIBRARY='-Wl,+b,$(LIBDIR) -L. -lpython$(LDVERSION)'
67+
RUNSHARED=SHLIB_PATH=`pwd`${SHLIB_PATH:+:${SHLIB_PATH}}
68+
;;
69+
- Darwin*)
70+
+ Darwin*|iOS*|tvOS*|watchOS*)
71+
LDLIBRARY='libpython$(LDVERSION).dylib'
72+
BLDLIBRARY='-L. -lpython$(LDVERSION)'
73+
RUNSHARED=DYLD_LIBRARY_PATH=`pwd`${DYLD_LIBRARY_PATH:+:${DYLD_LIBRARY_PATH}}
74+
@@ -3173,6 +3203,11 @@ then
75+
Linux*|GNU*|QNX*|VxWorks*|Haiku*)
76+
LDSHARED='$(CC) -shared'
77+
LDCXXSHARED='$(CXX) -shared';;
78+
+ iOS*|tvOS*|watchOS*)
79+
+ LDSHARED='$(CC) -bundle -undefined dynamic_lookup'
80+
+ LDCXXSHARED='$(CXX) -bundle -undefined dynamic_lookup'
81+
+ BLDSHARED="$LDSHARED"
82+
+ ;;
83+
FreeBSD*)
84+
if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
85+
then

0 commit comments

Comments
 (0)