From 838713dcac89f24d88d54a2f0c668c8e13fdb076 Mon Sep 17 00:00:00 2001 From: Russell Keith-Magee Date: Wed, 14 Feb 2024 10:12:13 +0800 Subject: [PATCH] Improve error handling and reuse in configure.ac. --- configure | 82 +++++++++++++++++++++++-------------------------- configure.ac | 87 ++++++++++++++++++++++++---------------------------- 2 files changed, 78 insertions(+), 91 deletions(-) diff --git a/configure b/configure index ab9d1a3f59ed44..824efe3e750c33 100755 --- a/configure +++ b/configure @@ -4197,10 +4197,18 @@ then : enableval=$enable_framework; case $enableval in yes) + if test "$ac_sys_system" = "iOS"; then + as_fn_error $? "iOS builds must provide an explicit path for --enable-framework" "$LINENO" 5 + fi + enableval=/Library/Frameworks esac case $enableval in no) + if test "$ac_sys_system" = "iOS"; then + as_fn_error $? "iOS builds must use --enable-framework=" "$LINENO" 5 + fi + PYTHONFRAMEWORK= PYTHONFRAMEWORKDIR=no-framework PYTHONFRAMEWORKPREFIX= @@ -4314,6 +4322,10 @@ then : else $as_nop + if test "$ac_sys_system" = "iOS"; then + as_fn_error $? "iOS builds must use --enable-framework=" "$LINENO" 5 + fi + PYTHONFRAMEWORK= PYTHONFRAMEWORKDIR=no-framework PYTHONFRAMEWORKPREFIX= @@ -4371,26 +4383,21 @@ if test "$cross_compiling" = yes; then *-*-cygwin*) _host_ident= ;; - *-apple-ios*-simulator) - _host_os=`echo $host | cut -d '-' -f3` - IOS_DEPLOYMENT_TARGET=${_host_os:3} - case "$host_cpu" in - aarch64) - _host_ident=${IOS_DEPLOYMENT_TARGET}-iphonesimulator-arm64 - ;; - *) - _host_ident=${IOS_DEPLOYMENT_TARGET}-iphonesimulator-$host_cpu - esac - ;; *-apple-ios*) _host_os=`echo $host | cut -d '-' -f3` - IOS_DEPLOYMENT_TARGET=${_host_os:3} + _host_device=`echo $host | cut -d '-' -f4` + _host_device=${_host_device:=os} + + IOS_DEPLOYMENT_TARGET=${_host_os:3} + IOS_DEPLOYMENT_TARGET=${IOS_DEPLOYMENT_TARGET:=12.0} + case "$host_cpu" in - aarch64) - _host_ident=${IOS_DEPLOYMENT_TARGET}-iphoneos-arm64 - ;; - *) - _host_ident=${IOS_DEPLOYMENT_TARGET}-iphoneos-$host_cpu + aarch64) + _host_ident=${IOS_DEPLOYMENT_TARGET}-arm64-iphone${_host_device} + ;; + *) + _host_ident=${IOS_DEPLOYMENT_TARGET}-$host_cpu-iphone${_host_device} + ;; esac ;; *-*-vxworks*) @@ -4571,7 +4578,6 @@ esac case $ac_sys_system in #( iOS) : - IOS_DEPLOYMENT_TARGET=${IOS_DEPLOYMENT_TARGET:=12.0} as_fn_append CFLAGS " -mios-version-min=${IOS_DEPLOYMENT_TARGET}" as_fn_append LDFLAGS " -mios-version-min=${IOS_DEPLOYMENT_TARGET}" @@ -12906,7 +12912,7 @@ then Linux-android*) LINKFORSHARED="-pie -Xlinker -export-dynamic";; Linux*|GNU*) LINKFORSHARED="-Xlinker -export-dynamic";; # -u libsys_s pulls in all symbols in libsys - Darwin/*) + Darwin/*|iOS/*) LINKFORSHARED="$extra_undefs -framework CoreFoundation" # Issue #18075: the default maximum stack size (8MBytes) is too @@ -12919,35 +12925,21 @@ then stack_size="4000000" # 64 MB fi - LINKFORSHARED="-Wl,-stack_size,$stack_size $LINKFORSHARED" - printf "%s\n" "#define THREAD_STACK_SIZE 0x$stack_size" >>confdefs.h - if test "$enable_framework" - then - LINKFORSHARED="$LINKFORSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' - fi - LINKFORSHARED="$LINKFORSHARED";; - iOS/*) - LINKFORSHARED="$extra_undefs -framework CoreFoundation" + if test $ac_sys_system = "Darwin"; then + LINKFORSHARED="-Wl,-stack_size,$stack_size $LINKFORSHARED" - # Issue #18075: the default maximum stack size (8MBytes) is too - # small for the default recursion limit. Increase the stack size - # to ensure that tests don't crash - stack_size="1000000" # 16 MB - if test "$with_ubsan" = "yes" - then - # Undefined behavior sanitizer requires an even deeper stack - stack_size="4000000" # 64 MB + if test "$enable_framework"; then + LINKFORSHARED="$LINKFORSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' + fi + LINKFORSHARED="$LINKFORSHARED" + elif test $ac_sys_system = "iOS"; then + LINKFORSHARED="-Wl,-stack_size,$stack_size $LINKFORSHARED "'$(PYTHONFRAMEWORKDIR)/$(PYTHONFRAMEWORK)' fi - - -printf "%s\n" "#define THREAD_STACK_SIZE 0x$stack_size" >>confdefs.h - - - LINKFORSHARED="-Wl,-stack_size,$stack_size $LINKFORSHARED "'$(PYTHONFRAMEWORKDIR)/$(PYTHONFRAMEWORK)';; + ;; OpenUNIX*|UnixWare*) LINKFORSHARED="-Wl,-Bexport";; SCO_SV*) LINKFORSHARED="-Wl,-Bexport";; ReliantUNIX*) LINKFORSHARED="-W1 -Blargedynsym";; @@ -26804,7 +26796,10 @@ CPPFLAGS=$ac_save_cppflags { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for device files" >&5 printf "%s\n" "$as_me: checking for device files" >&6;} -if test "$ac_sys_system" != "iOS" ; then +if test "$ac_sys_system" = "iOS" ; then + ac_cv_file__dev_ptmx=no + ac_cv_file__dev_ptc=no +else if test "x$cross_compiling" = xyes; then if test "${ac_cv_file__dev_ptmx+set}" != set; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for /dev/ptmx" >&5 @@ -28268,7 +28263,6 @@ case $ac_sys_system in #( py_cv_module__posixsubprocess=n/a py_cv_module__scproxy=n/a py_cv_module__tkinter=n/a - py_cv_module__xxsubinterpreters=n/a py_cv_module_grp=n/a py_cv_module_nis=n/a py_cv_module_readline=n/a diff --git a/configure.ac b/configure.ac index b317ab44a34297..60af6f61a49551 100644 --- a/configure.ac +++ b/configure.ac @@ -487,10 +487,18 @@ AC_ARG_ENABLE([framework], [ case $enableval in yes) + if test "$ac_sys_system" = "iOS"; then + AC_MSG_ERROR([iOS builds must provide an explicit path for --enable-framework]) + fi + enableval=/Library/Frameworks esac case $enableval in no) + if test "$ac_sys_system" = "iOS"; then + AC_MSG_ERROR([iOS builds must use --enable-framework=]) + fi + PYTHONFRAMEWORK= PYTHONFRAMEWORKDIR=no-framework PYTHONFRAMEWORKPREFIX= @@ -597,6 +605,10 @@ AC_ARG_ENABLE([framework], esac esac ],[ + if test "$ac_sys_system" = "iOS"; then + AC_MSG_ERROR([iOS builds must use --enable-framework=]) + fi + PYTHONFRAMEWORK= PYTHONFRAMEWORKDIR=no-framework PYTHONFRAMEWORKPREFIX= @@ -651,26 +663,22 @@ if test "$cross_compiling" = yes; then *-*-cygwin*) _host_ident= ;; - *-apple-ios*-simulator) - _host_os=`echo $host | cut -d '-' -f3` - IOS_DEPLOYMENT_TARGET=${_host_os:3} - case "$host_cpu" in - aarch64) - _host_ident=${IOS_DEPLOYMENT_TARGET}-iphonesimulator-arm64 - ;; - *) - _host_ident=${IOS_DEPLOYMENT_TARGET}-iphonesimulator-$host_cpu - esac - ;; *-apple-ios*) _host_os=`echo $host | cut -d '-' -f3` + _host_device=`echo $host | cut -d '-' -f4` + _host_device=${_host_device:=os} + + dnl IOS_DEPLOYMENT_TARGET is the minimum supported iOS version IOS_DEPLOYMENT_TARGET=${_host_os:3} + IOS_DEPLOYMENT_TARGET=${IOS_DEPLOYMENT_TARGET:=12.0} + case "$host_cpu" in - aarch64) - _host_ident=${IOS_DEPLOYMENT_TARGET}-iphoneos-arm64 - ;; - *) - _host_ident=${IOS_DEPLOYMENT_TARGET}-iphoneos-$host_cpu + aarch64) + _host_ident=${IOS_DEPLOYMENT_TARGET}-arm64-iphone${_host_device} + ;; + *) + _host_ident=${IOS_DEPLOYMENT_TARGET}-$host_cpu-iphone${_host_device} + ;; esac ;; *-*-vxworks*) @@ -843,12 +851,9 @@ AS_CASE([$host], ], ) -dnl iOS needs to enforce the deployment target; if the version hasn't -dnl been provided as part of the --host configuration, fall back to -dnl a default value (12.0 for iOS). +dnl Add the compiler flag for the iOS minimum supported OS version. AS_CASE([$ac_sys_system], [iOS], [ - IOS_DEPLOYMENT_TARGET=${IOS_DEPLOYMENT_TARGET:=12.0} AS_VAR_APPEND([CFLAGS], [" -mios-version-min=${IOS_DEPLOYMENT_TARGET}"]) AS_VAR_APPEND([LDFLAGS], [" -mios-version-min=${IOS_DEPLOYMENT_TARGET}"]) AC_SUBST([IOS_DEPLOYMENT_TARGET]) @@ -3439,7 +3444,7 @@ then Linux-android*) LINKFORSHARED="-pie -Xlinker -export-dynamic";; Linux*|GNU*) LINKFORSHARED="-Xlinker -export-dynamic";; # -u libsys_s pulls in all symbols in libsys - Darwin/*) + Darwin/*|iOS/*) LINKFORSHARED="$extra_undefs -framework CoreFoundation" # Issue #18075: the default maximum stack size (8MBytes) is too @@ -3452,35 +3457,21 @@ then stack_size="4000000" # 64 MB fi - LINKFORSHARED="-Wl,-stack_size,$stack_size $LINKFORSHARED" - AC_DEFINE_UNQUOTED([THREAD_STACK_SIZE], [0x$stack_size], [Custom thread stack size depending on chosen sanitizer runtimes.]) - if test "$enable_framework" - then - LINKFORSHARED="$LINKFORSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' - fi - LINKFORSHARED="$LINKFORSHARED";; - iOS/*) - LINKFORSHARED="$extra_undefs -framework CoreFoundation" + if test $ac_sys_system = "Darwin"; then + LINKFORSHARED="-Wl,-stack_size,$stack_size $LINKFORSHARED" - # Issue #18075: the default maximum stack size (8MBytes) is too - # small for the default recursion limit. Increase the stack size - # to ensure that tests don't crash - stack_size="1000000" # 16 MB - if test "$with_ubsan" = "yes" - then - # Undefined behavior sanitizer requires an even deeper stack - stack_size="4000000" # 64 MB + if test "$enable_framework"; then + LINKFORSHARED="$LINKFORSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' + fi + LINKFORSHARED="$LINKFORSHARED" + elif test $ac_sys_system = "iOS"; then + LINKFORSHARED="-Wl,-stack_size,$stack_size $LINKFORSHARED "'$(PYTHONFRAMEWORKDIR)/$(PYTHONFRAMEWORK)' fi - - AC_DEFINE_UNQUOTED([THREAD_STACK_SIZE], - [0x$stack_size], - [Custom thread stack size depending on chosen sanitizer runtimes.]) - - LINKFORSHARED="-Wl,-stack_size,$stack_size $LINKFORSHARED "'$(PYTHONFRAMEWORKDIR)/$(PYTHONFRAMEWORK)';; + ;; OpenUNIX*|UnixWare*) LINKFORSHARED="-Wl,-Bexport";; SCO_SV*) LINKFORSHARED="-Wl,-Bexport";; ReliantUNIX*) LINKFORSHARED="-W1 -Blargedynsym";; @@ -6629,8 +6620,11 @@ AC_MSG_NOTICE([checking for device files]) dnl NOTE: Inform user how to proceed with files when cross compiling. dnl iOS cross-compile builds are predictable; they won't ever -dnl have /dev/ptmx or /dev/ptc, so we can set them explicitly -if test "$ac_sys_system" != "iOS" ; then +dnl have /dev/ptmx or /dev/ptc, so we can set them explicitly. +if test "$ac_sys_system" = "iOS" ; then + ac_cv_file__dev_ptmx=no + ac_cv_file__dev_ptc=no +else if test "x$cross_compiling" = xyes; then if test "${ac_cv_file__dev_ptmx+set}" != set; then AC_MSG_CHECKING([for /dev/ptmx]) @@ -7310,7 +7304,6 @@ AS_CASE([$ac_sys_system], [_posixsubprocess], [_scproxy], [_tkinter], - [_xxsubinterpreters], [grp], [nis], [readline],