Skip to content

Commit 99d223e

Browse files
committed
Add patch for Apple cross compilation on 3.13+
1 parent a294377 commit 99d223e

File tree

2 files changed

+88
-2
lines changed

2 files changed

+88
-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: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
diff --git a/configure.ac b/configure.ac
2+
index 58f54076ff2..a734260691a 100644
3+
--- a/configure.ac
4+
+++ b/configure.ac
5+
@@ -330,6 +330,21 @@ then
6+
*-apple-ios*)
7+
ac_sys_system=iOS
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+
+ *-*-darwin*)
19+
+ ac_sys_system=Darwin
20+
+ ;;
21+
+ *-apple-*)
22+
+ ac_sys_system=Darwin
23+
+ ;;
24+
*-*-vxworks*)
25+
ac_sys_system=VxWorks
26+
;;
27+
@@ -771,6 +786,15 @@ if test "$cross_compiling" = yes; then
28+
;;
29+
esac
30+
;;
31+
+ *-*-darwin*)
32+
+ case "$host_cpu" in
33+
+ arm*)
34+
+ _host_ident=arm
35+
+ ;;
36+
+ *)
37+
+ _host_ident=$host_cpu
38+
+ esac
39+
+ ;;
40+
*-*-vxworks*)
41+
_host_ident=$host_cpu
42+
;;
43+
@@ -785,6 +809,23 @@ if test "$cross_compiling" = yes; then
44+
_PYTHON_HOST_PLATFORM="$MACHDEP${_host_ident:+-$_host_ident}"
45+
fi
46+
47+
+# The _PYTHON_HOST_PLATFORM environment variable is used to
48+
+# override the platform name in distutils and sysconfig when
49+
+# cross-compiling. On Apple, the platform name expansion logic
50+
+# is non-trivial, including renaming MACHDEP=darwin to macosx
51+
+# and including the deployment target (or current OS version if
52+
+# not set). Here we always force an override based on the target
53+
+# triple. We do this in all build configurations because historically
54+
+# the automatic resolution has been brittle.
55+
+case "$host" in
56+
+aarch64-apple-darwin*)
57+
+ _PYTHON_HOST_PLATFORM="macosx-${MACOSX_DEPLOYMENT_TARGET}-arm64"
58+
+ ;;
59+
+x86_64-apple-darwin*)
60+
+ _PYTHON_HOST_PLATFORM="macosx-${MACOSX_DEPLOYMENT_TARGET}-x86_64"
61+
+ ;;
62+
+esac
63+
+
64+
# Some systems cannot stand _XOPEN_SOURCE being defined at all; they
65+
# disable features if it is defined, without any means to access these
66+
# features as extensions. For these systems, we skip the definition of
67+
@@ -1582,7 +1623,7 @@ if test $enable_shared = "yes"; then
68+
BLDLIBRARY='-Wl,+b,$(LIBDIR) -L. -lpython$(LDVERSION)'
69+
RUNSHARED=SHLIB_PATH=`pwd`${SHLIB_PATH:+:${SHLIB_PATH}}
70+
;;
71+
- Darwin*)
72+
+ Darwin*|iOS*|tvOS*|watchOS*)
73+
LDLIBRARY='libpython$(LDVERSION).dylib'
74+
BLDLIBRARY='-L. -lpython$(LDVERSION)'
75+
RUNSHARED=DYLD_LIBRARY_PATH=`pwd`${DYLD_LIBRARY_PATH:+:${DYLD_LIBRARY_PATH}}
76+
@@ -3469,6 +3510,11 @@ then
77+
Linux*|GNU*|QNX*|VxWorks*|Haiku*)
78+
LDSHARED='$(CC) -shared'
79+
LDCXXSHARED='$(CXX) -shared';;
80+
+ iOS*|tvOS*|watchOS*)
81+
+ LDSHARED='$(CC) -bundle -undefined dynamic_lookup'
82+
+ LDCXXSHARED='$(CXX) -bundle -undefined dynamic_lookup'
83+
+ BLDSHARED="$LDSHARED"
84+
+ ;;
85+
FreeBSD*)
86+
if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
87+
then

0 commit comments

Comments
 (0)