@@ -88,57 +88,14 @@ if [ -n "${CROSS_COMPILING}" ]; then
8888 # Same patch as below. See comment there.
8989 if [ " ${CC} " = " clang" ]; then
9090 if [ " ${PYTHON_MAJMIN_VERSION} " != " 3.8" ]; then
91- patch -p1 << "EOF "
92- diff --git a/configure b/configure
93- index d078887b2f..78654eed29 100755
94- --- a/configure
95- +++ b/configure
96- @@ -5366,20 +5366,7 @@ $as_echo "none" >&6; }
97- fi
98- rm -f conftest.c conftest.out
99-
100- -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for multiarch" >&5
101- -$as_echo_n "checking for multiarch... " >&6; }
102- -case $ac_sys_system in #(
103- - Darwin*) :
104- - MULTIARCH="" ;; #(
105- - FreeBSD*) :
106- - MULTIARCH="" ;; #(
107- - *) :
108- - MULTIARCH=$($CC --print-multiarch 2>/dev/null)
109- - ;;
110- -esac
111- -
112- -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $MULTIARCH" >&5
113- -$as_echo "$MULTIARCH" >&6; }
114- +MULTIARCH=
115-
116- if test x$PLATFORM_TRIPLET != x && test x$MULTIARCH != x; then
117- if test x$PLATFORM_TRIPLET != x$MULTIARCH; then
118-
119- EOF
91+ patch -p1 < ${ROOT} /patch-disable-multiarch.patch
12092 else
121- patch -p1 << "EOF "
122- diff --git a/configure b/configure
123- index c091865aff..0aeea8cedb 100755
124- --- a/configure
125- +++ b/configure
126- @@ -5318,10 +5318,7 @@ $as_echo "none" >&6; }
127- fi
128- rm -f conftest.c conftest.out
129-
130- -if test x$PLATFORM_TRIPLET != xdarwin; then
131- - MULTIARCH=$($CC --print-multiarch 2>/dev/null)
132- -fi
133- -
134- +MULTIARCH=
135-
136- if test x$PLATFORM_TRIPLET != x && test x$MULTIARCH != x; then
137- if test x$PLATFORM_TRIPLET != x$MULTIARCH; then
138- EOF
93+ patch -p1 < ${ROOT} /patch-disable-multiarch-legacy.patch
13994 fi
14095 fi
14196
97+ autoconf
98+
14299 # When cross-compiling, we need to build a host Python that has working zlib
143100 # and ctypes extensions, otherwise various things fail. (`make install` fails
144101 # without zlib and setuptools / pip used by target install fail due to missing
@@ -184,259 +141,30 @@ cat Makefile.extra
184141
185142pushd Python-${PYTHON_VERSION}
186143
187- # configure assumes cross compiling when host != target and doesn't provide a way to
188- # override. Our target triple normalization may lead configure into thinking we
189- # aren't cross-compiling when we are. So force a static "yes" value when our
190- # build system says we are cross-compiling.
191- if [ -n " ${CROSS_COMPILING} " ]; then
192- patch -p1 << "EOF "
193- diff --git a/configure b/configure
194- index d078887b2f..8f1ea07cd8 100755
195- --- a/configure
196- +++ b/configure
197- @@ -1329,14 +1329,7 @@ build=$build_alias
198- host=$host_alias
199- target=$target_alias
200-
201- -# FIXME: To remove some day.
202- -if test "x$host_alias" != x; then
203- - if test "x$build_alias" = x; then
204- - cross_compiling=maybe
205- - elif test "x$build_alias" != "x$host_alias"; then
206- - cross_compiling=yes
207- - fi
208- -fi
209- +cross_compiling=yes
210-
211- ac_tool_prefix=
212- test -n "$host_alias" && ac_tool_prefix=$host_alias-
213- EOF
214- fi
215-
216144# configure doesn't support cross-compiling on Apple. Teach it.
217- patch -p1 << "EOF "
218- diff --git a/configure b/configure
219- index 1252335472..6665645839 100755
220- --- a/configure
221- +++ b/configure
222- @@ -3301,6 +3301,15 @@ then
223- *-*-cygwin*)
224- ac_sys_system=Cygwin
225- ;;
226- + *-apple-ios*)
227- + ac_sys_system=iOS
228- + ;;
229- + *-apple-tvos*)
230- + ac_sys_system=tvOS
231- + ;;
232- + *-apple-watchos*)
233- + ac_sys_system=watchOS
234- + ;;
235- *-*-vxworks*)
236- ac_sys_system=VxWorks
237- ;;
238- @@ -3351,6 +3360,19 @@ if test "$cross_compiling" = yes; then
239- *-*-cygwin*)
240- _host_cpu=
241- ;;
242- + *-*-darwin*)
243- + _host_cpu=
244- + ;;
245- + *-apple-*)
246- + case "$host_cpu" in
247- + arm*)
248- + _host_cpu=arm
249- + ;;
250- + *)
251- + _host_cpu=$host_cpu
252- + ;;
253- + esac
254- + ;;
255- *-*-vxworks*)
256- _host_cpu=$host_cpu
257- ;;
258- @@ -3359,7 +3381,22 @@ if test "$cross_compiling" = yes; then
259- MACHDEP="unknown"
260- as_fn_error $? "cross build not supported for $host" "$LINENO" 5
261- esac
262- - _PYTHON_HOST_PLATFORM="$MACHDEP${_host_cpu:+-$_host_cpu}"
263- +
264- + case "$host" in
265- + # The _PYTHON_HOST_PLATFORM environment variable is used to
266- + # override the platform name in distutils and sysconfig when
267- + # cross-compiling. On Apple, the platform name expansion logic
268- + # is non-trivial, including renaming MACHDEP=darwin to macosx
269- + # and including the deployment target (or current OS version if
270- + # not set). Our hack here is not generic, but gets the job done
271- + # for python-build-standalone's cross-compile use cases.
272- + aarch64-apple-darwin*)
273- + _PYTHON_HOST_PLATFORM="macosx-${MACOSX_DEPLOYMENT_TARGET}-arm64"
274- + ;;
275- + *)
276- + _PYTHON_HOST_PLATFORM="$MACHDEP${_host_cpu:+-$_host_cpu}"
277- + esac
278- +
279- fi
280-
281- # Some systems cannot stand _XOPEN_SOURCE being defined at all; they
282- @@ -5968,7 +6005,7 @@ $as_echo "#define Py_ENABLE_SHARED 1" >>confdefs.h
283- BLDLIBRARY='-Wl,+b,$(LIBDIR) -L. -lpython$(LDVERSION)'
284- RUNSHARED=SHLIB_PATH=`pwd`${SHLIB_PATH:+:${SHLIB_PATH}}
285- ;;
286- - Darwin*)
287- + Darwin*|iOS*|tvOS*|watchOS*)
288- LDLIBRARY='libpython$(LDVERSION).dylib'
289- BLDLIBRARY='-L. -lpython$(LDVERSION)'
290- RUNSHARED=DYLD_LIBRARY_PATH=`pwd`${DYLD_LIBRARY_PATH:+:${DYLD_LIBRARY_PATH}}
291- @@ -6205,16 +6242,6 @@ esac
292- fi
293- fi
294-
295- -if test "$cross_compiling" = yes; then
296- - case "$READELF" in
297- - readelf|:)
298- - as_fn_error $? "readelf for the host is required for cross builds" "$LINENO" 5
299- - ;;
300- - esac
301- -fi
302- -
303- -
304- -
305- case $MACHDEP in
306- hp*|HP*)
307- # install -d does not work on HP-UX
308- @@ -9541,6 +9568,11 @@ then
309- BLDSHARED="$LDSHARED"
310- fi
311- ;;
312- + iOS*|tvOS*|watchOS*)
313- + LDSHARED='$(CC) -bundle -undefined dynamic_lookup'
314- + LDCXXSHARED='$(CXX) -bundle -undefined dynamic_lookup'
315- + BLDSHARED="$LDSHARED"
316- + ;;
317- Linux*|GNU*|QNX*|VxWorks*)
318- LDSHARED='$(CC) -shared'
319- LDCXXSHARED='$(CXX) -shared';;
320- EOF
145+ patch -p1 < ${ROOT} /patch-apple-cross.patch
321146
322147# This patch is slightly different on Python 3.10+.
323148if [ " ${PYTHON_MAJMIN_VERSION} " = " 3.10" ]; then
324- patch -p1 << "EOF "
325- diff --git a/configure b/configure
326- index 2d379feb4b..3eb8dbe9ea 100755
327- --- a/configure
328- +++ b/configure
329- @@ -3426,6 +3448,12 @@ $as_echo "#define _BSD_SOURCE 1" >>confdefs.h
330- define_xopen_source=no;;
331- Darwin/[12][0-9].*)
332- define_xopen_source=no;;
333- + iOS/*)
334- + define_xopen_source=no;;
335- + tvOS/*)
336- + define_xopen_source=no;;
337- + watchOS/*)
338- + define_xopen_source=no;;
339- # On QNX 6.3.2, defining _XOPEN_SOURCE prevents netdb.h from
340- # defining NI_NUMERICHOST.
341- QNX/6.3.2)
342- EOF
149+ patch -p1 < ${ROOT} /patch-xopen-source-ios.patch
343150else
344- patch -p1 << "EOF "
345- diff --git a/configure b/configure
346- index 2d379feb4b..3eb8dbe9ea 100755
347- --- a/configure
348- +++ b/configure
349- @@ -3426,6 +3448,12 @@ $as_echo "#define _BSD_SOURCE 1" >>confdefs.h
350- define_xopen_source=no;;
351- Darwin/[12][0-9].*)
352- define_xopen_source=no;;
353- + iOS/*)
354- + define_xopen_source=no;;
355- + tvOS/*)
356- + define_xopen_source=no;;
357- + watchOS/*)
358- + define_xopen_source=no;;
359- # On AIX 4 and 5.1, mbstate_t is defined only when _XOPEN_SOURCE == 500 but
360- # used in wcsnrtombs() and mbsnrtowcs() even if _XOPEN_SOURCE is not defined
361- # or has another value. By not (re)defining it, the defaults come in place.
362- EOF
151+ patch -p1 < ${ROOT} /patch-xopen-source-ios-legacy.patch
363152fi
364153
365154# Configure nerfs RUNSHARED when cross-compiling, which prevents PGO from running when
366155# we can in fact run the target binaries (e.g. x86_64 host and i686 target). Undo that.
367156if [ -n " ${CROSS_COMPILING} " ]; then
368- patch -p1 << "EOF "
369- diff --git a/configure b/configure
370- index 1252335472..33c11fbade 100755
371- --- a/configure
372- +++ b/configure
373- @@ -5989,10 +5989,6 @@ else # shared is disabled
374- esac
375- fi
376-
377- -if test "$cross_compiling" = yes; then
378- - RUNSHARED=
379- -fi
380- -
381- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LDLIBRARY" >&5
382- $as_echo "$LDLIBRARY" >&6; }
383-
384- EOF
157+ patch -p1 < ${ROOT} /patch-dont-clear-runshared.patch
385158fi
386159
387160# Clang 13 actually prints something with --print-multiarch, confusing CPython's
388161# configure. This is reported as https://bugs.python.org/issue45405. We nerf the
389162# check since we know what we're doing.
390163if [ " ${CC} " = " clang" ]; then
391164 if [ " ${PYTHON_MAJMIN_VERSION} " != " 3.8" ]; then
392- patch -p1 << "EOF "
393- diff --git a/configure b/configure
394- index d078887b2f..78654eed29 100755
395- --- a/configure
396- +++ b/configure
397- @@ -5366,20 +5366,7 @@ $as_echo "none" >&6; }
398- fi
399- rm -f conftest.c conftest.out
400-
401- -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for multiarch" >&5
402- -$as_echo_n "checking for multiarch... " >&6; }
403- -case $ac_sys_system in #(
404- - Darwin*) :
405- - MULTIARCH="" ;; #(
406- - FreeBSD*) :
407- - MULTIARCH="" ;; #(
408- - *) :
409- - MULTIARCH=$($CC --print-multiarch 2>/dev/null)
410- - ;;
411- -esac
412- -
413- -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $MULTIARCH" >&5
414- -$as_echo "$MULTIARCH" >&6; }
415- +MULTIARCH=
416-
417- if test x$PLATFORM_TRIPLET != x && test x$MULTIARCH != x; then
418- if test x$PLATFORM_TRIPLET != x$MULTIARCH; then
419-
420- EOF
165+ patch -p1 < ${ROOT} /patch-disable-multiarch.patch
421166 else
422- patch -p1 << "EOF "
423- diff --git a/configure b/configure
424- index c091865aff..0aeea8cedb 100755
425- --- a/configure
426- +++ b/configure
427- @@ -5318,10 +5318,7 @@ $as_echo "none" >&6; }
428- fi
429- rm -f conftest.c conftest.out
430-
431- -if test x$PLATFORM_TRIPLET != xdarwin; then
432- - MULTIARCH=$($CC --print-multiarch 2>/dev/null)
433- -fi
434- -
435- +MULTIARCH=
436-
437- if test x$PLATFORM_TRIPLET != x && test x$MULTIARCH != x; then
438- if test x$PLATFORM_TRIPLET != x$MULTIARCH; then
439- EOF
167+ patch -p1 < ${ROOT} /patch-disable-multiarch-legacy.patch
440168 fi
441169fi
442170
@@ -698,6 +426,38 @@ index 12f72f525f..4503c5fc60 100644
698426EOF
699427fi
700428
429+ # We patched configure.ac above. Reflect those changes.
430+ autoconf
431+
432+ # configure assumes cross compiling when host != target and doesn't provide a way to
433+ # override. Our target triple normalization may lead configure into thinking we
434+ # aren't cross-compiling when we are. So force a static "yes" value when our
435+ # build system says we are cross-compiling.
436+ if [ -n " ${CROSS_COMPILING} " ]; then
437+ patch -p1 << "EOF "
438+ diff --git a/configure b/configure
439+ index d078887b2f..8f1ea07cd8 100755
440+ --- a/configure
441+ +++ b/configure
442+ @@ -1329,14 +1329,7 @@ build=$build_alias
443+ host=$host_alias
444+ target=$target_alias
445+
446+ -# FIXME: To remove some day.
447+ -if test "x$host_alias" != x; then
448+ - if test "x$build_alias" = x; then
449+ - cross_compiling=maybe
450+ - elif test "x$build_alias" != "x$host_alias"; then
451+ - cross_compiling=yes
452+ - fi
453+ -fi
454+ +cross_compiling=yes
455+
456+ ac_tool_prefix=
457+ test -n "$host_alias" && ac_tool_prefix=$host_alias-
458+ EOF
459+ fi
460+
701461# Most bits look at CFLAGS. But setup.py only looks at CPPFLAGS.
702462# So we need to set both.
703463CFLAGS=" ${EXTRA_TARGET_CFLAGS} -fPIC -I${TOOLS_PATH} /deps/include -I${TOOLS_PATH} /deps/include/ncursesw"
0 commit comments