Skip to content

Commit 42ee75c

Browse files
committed
Fix cross-compilation for macOS x86_64
1 parent 6e94027 commit 42ee75c

File tree

3 files changed

+77
-10
lines changed

3 files changed

+77
-10
lines changed

cpython-unix/build-cpython.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,9 @@ pushd Python-${PYTHON_VERSION}
7171

7272
# configure doesn't support cross-compiling on Apple. Teach it.
7373
if [ "${PYBUILD_PLATFORM}" = "macos" ]; then
74-
if [ -n "${PYTHON_MEETS_MINIMUM_VERSION_3_13}" ]; then
74+
if [ -n "${PYTHON_MEETS_MINIMUM_VERSION_3_14}" ]; then
75+
patch -p1 -i ${ROOT}/patch-apple-cross-3.14.patch
76+
elif [ -n "${PYTHON_MEETS_MINIMUM_VERSION_3_13}" ]; then
7577
patch -p1 -i ${ROOT}/patch-apple-cross-3.13.patch
7678
elif [ "${PYTHON_MAJMIN_VERSION}" = "3.12" ]; then
7779
patch -p1 -i ${ROOT}/patch-apple-cross-3.12.patch
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
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+
--- a/configure.ac
28+
+++ b/configure.ac
29+
@@ -771,6 +786,15 @@ if test "$cross_compiling" = yes; then
30+
;;
31+
esac
32+
;;
33+
+ *-*-darwin*)
34+
+ case "$host_cpu" in
35+
+ arm*)
36+
+ _host_ident=arm
37+
+ ;;
38+
+ *)
39+
+ _host_ident=$host_cpu
40+
+ esac
41+
+ ;;
42+
*-*-vxworks*)
43+
_host_ident=$host_cpu
44+
;;
45+
@@ -1582,7 +1623,7 @@ if test $enable_shared = "yes"; then
46+
BLDLIBRARY='-Wl,+b,$(LIBDIR) -L. -lpython$(LDVERSION)'
47+
RUNSHARED=SHLIB_PATH=`pwd`${SHLIB_PATH:+:${SHLIB_PATH}}
48+
;;
49+
- Darwin*)
50+
+ Darwin*|iOS*|tvOS*|watchOS*)
51+
LDLIBRARY='libpython$(LDVERSION).dylib'
52+
BLDLIBRARY='-L. -lpython$(LDVERSION)'
53+
RUNSHARED=DYLD_LIBRARY_PATH=`pwd`${DYLD_LIBRARY_PATH:+:${DYLD_LIBRARY_PATH}}
54+
@@ -3469,6 +3510,11 @@ then
55+
Linux*|GNU*|QNX*|VxWorks*|Haiku*)
56+
LDSHARED='$(CC) -shared'
57+
LDCXXSHARED='$(CXX) -shared';;
58+
+ iOS*|tvOS*|watchOS*)
59+
+ LDSHARED='$(CC) -bundle -undefined dynamic_lookup'
60+
+ LDCXXSHARED='$(CXX) -bundle -undefined dynamic_lookup'
61+
+ BLDSHARED="$LDSHARED"
62+
+ ;;
63+
FreeBSD*)
64+
if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
65+
then
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
diff --git a/configure b/configure
2-
index 57be576e3ca..a87c6eb8f2e 100755
3-
--- a/configure
4-
+++ b/configure
5-
@@ -7617,10 +7617,6 @@ fi
6-
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $LDLIBRARY" >&5
7-
printf "%s\n" "$LDLIBRARY" >&6; }
1+
diff --git a/configure.ac b/configure.ac
2+
index bd0221481c5..f2fb52c1efc 100644
3+
--- a/configure.ac
4+
+++ b/configure.ac
5+
@@ -1605,10 +1605,6 @@ else # shared is disabled
6+
fi
7+
AC_MSG_RESULT([$LDLIBRARY])
88

99
-if test "$cross_compiling" = yes; then
1010
- RUNSHARED=
1111
-fi
1212
-
1313
# HOSTRUNNER - Program to run CPython for the host platform
14-
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking HOSTRUNNER" >&5
15-
printf %s "checking HOSTRUNNER... " >&6; }
14+
AC_MSG_CHECKING([HOSTRUNNER])
15+
if test -z "$HOSTRUNNER"

0 commit comments

Comments
 (0)