From 2a31f90c6a2ea8314a45046eb6c740a160e322c8 Mon Sep 17 00:00:00 2001 From: Christian Heimes Date: Mon, 29 Nov 2021 12:40:29 +0100 Subject: [PATCH 1/7] bpo-45881: configure --with-freeze-module --with-build-python Make cross compiling more convenient. configure now takes ``--with-freeze-module`` and ``--with-build-python`` arguments. There is no need pass ``FREEZE_MODULE`` and ``PYTHON_FOR_BUILD`` env vars any more. Signed-off-by: Christian Heimes --- Makefile.pre.in | 5 +-- configure | 104 ++++++++++++++++++++++++++++++++++++------------ configure.ac | 82 +++++++++++++++++++++++++++----------- 3 files changed, 139 insertions(+), 52 deletions(-) diff --git a/Makefile.pre.in b/Makefile.pre.in index fc8ab99babcdbb..d5be6edf784e2d 100644 --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -282,6 +282,8 @@ PYTHON_FOR_BUILD=@PYTHON_FOR_BUILD@ _PYTHON_HOST_PLATFORM=@_PYTHON_HOST_PLATFORM@ BUILD_GNU_TYPE= @build@ HOST_GNU_TYPE= @host@ +# Allow developers to override freeze_module command for cross building (bpo-45886) +FREEZE_MODULE?=@FREEZE_MODULE@ # Tcl and Tk config info from --with-tcltk-includes and -libs options TCLTK_INCLUDES= @TCLTK_INCLUDES@ @@ -1011,9 +1013,6 @@ Python/deepfreeze/frozen_only.c: Python/frozen_modules/frozen_only.h $(DEEPFREEZ ############################################################################ # frozen modules (including importlib) -# Allow developers to override freeze_module command for cross building (bpo-45886) -FREEZE_MODULE?=Programs/_freeze_module - # FROZEN_FILES_* are auto-generated by Tools/scripts/freeze_modules.py. FROZEN_FILES_IN = \ Lib/importlib/_bootstrap.py \ diff --git a/configure b/configure index 29c65a6bc94a46..041b35e5eb16de 100755 --- a/configure +++ b/configure @@ -931,8 +931,9 @@ PKG_CONFIG CONFIG_ARGS SOVERSION VERSION -PYTHON_FOR_BUILD PYTHON_FOR_REGEN +PYTHON_FOR_BUILD +FREEZE_MODULE host_os host_vendor host_cpu @@ -988,6 +989,8 @@ SHELL' ac_subst_files='' ac_user_opts=' enable_option_checking +with_freeze_module +with_build_python with_pkg_config enable_universalsdk with_universal_archs @@ -1721,6 +1724,12 @@ Optional Features: Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) + --with-freeze-module=Programs/_freeze_module + path to _freeze_module binary for cross compiling + (default: self-hosted Programs/_freeze_module + binary) + --with-build-python path to build python binary for cross compiling + (default: self-hosted ./python binary) --with-pkg-config=[yes|no|check] use pkg-config to detect build options (default is check) @@ -3177,9 +3186,77 @@ case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac +if test "x$cross_compiling" = xmaybe; then : + as_fn_error $? "Cross compiling required --host=HOST-TUPLE and --build=ARCH" "$LINENO" 5 + +fi + # pybuilddir.txt will be created by --generate-posix-vars in the Makefile rm -f pybuilddir.txt + +# Check whether --with-freeze_module was given. +if test "${with_freeze_module+set}" = set; then : + withval=$with_freeze_module; + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for --with-freeze-module" >&5 +$as_echo_n "checking for --with-freeze-module... " >&6; } + if test "$with_freeze_module" = yes -o "$with_freeze_module" = no; then + as_fn_error $? "invalid --with-freeze-module option: expect path, not \"$with_freeze_module\"" "$LINENO" 5 + fi + if ! $(command -v "$with_freeze_module" >/dev/null 2>&1); then + as_fn_error $? "invalid or missing freeze module binary \"$with_freeze_module\"" "$LINENO" 5 + fi + FREEZE_MODULE="$with_freeze_module" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $FREEZE_MODULE" >&5 +$as_echo "$FREEZE_MODULE" >&6; } + +else + + if test "x$cross_compiling" = xyes; then : + as_fn_error $? "Cross compiling requires --with-freeze-module" "$LINENO" 5 + +fi + FREEZE_MODULE=Programs/_freeze_module + + +fi + + + + +# Check whether --with-build-python was given. +if test "${with_build_python+set}" = set; then : + withval=$with_build_python; + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for --with-build-python" >&5 +$as_echo_n "checking for --with-build-python... " >&6; } + if test "$with_build_python" = yes -o "$with_build_python" = no; then + as_fn_error $? "invalid --with-freeze-module option: expect path, not \"$with_build_python\"" "$LINENO" 5 + fi + if ! $(command -v "$with_build_python" >/dev/null 2>&1); then + as_fn_error $? "invalid or missing build Python binary \"$with_build_python\"" "$LINENO" 5 + fi + build_python_ver=$($with_build_python -c "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}')") + if test "$build_python_ver" != "$PACKAGE_VERSION"; then + as_fn_error $? "\"$with_build_python\" has incompatible version $build_python_ver (expected: $PACKAGE_VERSION)" "$LINENO" 5 + fi + ac_cv_prog_PYTHON_FOR_REGEN=$with_build_python + PYTHON_FOR_BUILD='_PYTHON_PROJECT_BASE=$(abs_builddir) _PYTHON_HOST_PLATFORM=$(_PYTHON_HOST_PLATFORM) PYTHONPATH=$(shell test -f pybuilddir.txt && echo $(abs_builddir)/`cat pybuilddir.txt`:)$(srcdir)/Lib _PYTHON_SYSCONFIGDATA_NAME=_sysconfigdata_$(ABIFLAGS)_$(MACHDEP)_$(MULTIARCH) '$with_build_python + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PYTHON_FOR_BUILD" >&5 +$as_echo "$PYTHON_FOR_BUILD" >&6; } + +else + + if test "x$cross_compiling" = xyes; then : + as_fn_error $? "Cross compiling requires --with-build-python" "$LINENO" 5 + +fi + PYTHON_FOR_BUILD='./$(BUILDPYTHON) -E' + + +fi + + + for ac_prog in python$PACKAGE_VERSION python3.10 python3.9 python3.8 python3.7 python3.6 python3 python do # Extract the first word of "$ac_prog", so it can be a program name with args. @@ -3235,31 +3312,6 @@ else $as_echo "missing" >&6; } fi -if test "$cross_compiling" = yes; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for python interpreter for cross build" >&5 -$as_echo_n "checking for python interpreter for cross build... " >&6; } - if test -z "$PYTHON_FOR_BUILD"; then - for interp in python$PACKAGE_VERSION python3 python; do - which $interp >/dev/null 2>&1 || continue - if $interp -c "import sys;sys.exit(not '.'.join(str(n) for n in sys.version_info[:2]) == '$PACKAGE_VERSION')"; then - break - fi - interp= - done - if test x$interp = x; then - as_fn_error $? "python$PACKAGE_VERSION interpreter not found" "$LINENO" 5 - fi - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $interp" >&5 -$as_echo "$interp" >&6; } - PYTHON_FOR_BUILD='_PYTHON_PROJECT_BASE=$(abs_builddir) _PYTHON_HOST_PLATFORM=$(_PYTHON_HOST_PLATFORM) PYTHONPATH=$(shell test -f pybuilddir.txt && echo $(abs_builddir)/`cat pybuilddir.txt`:)$(srcdir)/Lib _PYTHON_SYSCONFIGDATA_NAME=_sysconfigdata_$(ABIFLAGS)_$(MACHDEP)_$(MULTIARCH) '$interp - fi -elif test "$cross_compiling" = maybe; then - as_fn_error $? "Cross compiling required --host=HOST-TUPLE and --build=ARCH" "$LINENO" 5 -else - PYTHON_FOR_BUILD='./$(BUILDPYTHON) -E' -fi - - if test "$prefix" != "/"; then prefix=`echo "$prefix" | sed -e 's/\/$//g'` diff --git a/configure.ac b/configure.ac index 80f256073d68ad..976a537f5cd04a 100644 --- a/configure.ac +++ b/configure.ac @@ -93,9 +93,68 @@ AC_CANONICAL_HOST AC_SUBST(build) AC_SUBST(host) +AS_VAR_IF([cross_compiling], [maybe], + [AC_MSG_ERROR([Cross compiling required --host=HOST-TUPLE and --build=ARCH])] +) + # pybuilddir.txt will be created by --generate-posix-vars in the Makefile rm -f pybuilddir.txt +dnl cross-compiling needs a freeze_module binary for build platform +AC_ARG_WITH( + [freeze_module], + [AS_HELP_STRING([--with-freeze-module=Programs/_freeze_module], + [path to _freeze_module binary for cross compiling (default: self-hosted Programs/_freeze_module binary)])], + [ + AC_MSG_CHECKING([for --with-freeze-module]) + AS_VAR_IF([cross_compiling], [no], AC_MSG_ERROR([--with-freeze-module only applies to cross compiling])) + if test "$with_freeze_module" = yes -o "$with_freeze_module" = no; then + AC_MSG_ERROR([invalid --with-freeze-module option: expect path, not "$with_freeze_module"]) + fi + if ! $(command -v "$with_freeze_module" >/dev/null 2>&1); then + AC_MSG_ERROR([invalid or missing freeze module binary "$with_freeze_module"]) + fi + FREEZE_MODULE="$with_freeze_module" + AC_MSG_RESULT([$FREEZE_MODULE]) + ], [ + AS_VAR_IF([cross_compiling], [yes], + [AC_MSG_ERROR([Cross compiling requires --with-freeze-module])] + ) + FREEZE_MODULE=Programs/_freeze_module + ] +) +AC_SUBST([FREEZE_MODULE]) + +AC_ARG_WITH( + [build-python], + [AS_HELP_STRING([--with-build-python], + [path to build python binary for cross compiling (default: self-hosted ./python binary)])], + [ + AC_MSG_CHECKING([for --with-build-python]) + AS_VAR_IF([cross_compiling], [no], AC_MSG_ERROR([--with-build-python only applies to cross compiling])) + if test "$with_build_python" = yes -o "$with_build_python" = no; then + AC_MSG_ERROR([invalid -with-build-python option: expect path, not "$with_build_python"]) + fi + if ! $(command -v "$with_build_python" >/dev/null 2>&1); then + AC_MSG_ERROR([invalid or missing build Python binary "$with_build_python"]) + fi + build_python_ver=$($with_build_python -c "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}')") + if test "$build_python_ver" != "$PACKAGE_VERSION"; then + AC_MSG_ERROR(["$with_build_python" has incompatible version $build_python_ver (expected: $PACKAGE_VERSION)]) + fi + dnl use build Python for regeneration, too + ac_cv_prog_PYTHON_FOR_REGEN=$with_build_python + PYTHON_FOR_BUILD='_PYTHON_PROJECT_BASE=$(abs_builddir) _PYTHON_HOST_PLATFORM=$(_PYTHON_HOST_PLATFORM) PYTHONPATH=$(shell test -f pybuilddir.txt && echo $(abs_builddir)/`cat pybuilddir.txt`:)$(srcdir)/Lib _PYTHON_SYSCONFIGDATA_NAME=_sysconfigdata_$(ABIFLAGS)_$(MACHDEP)_$(MULTIARCH) '$with_build_python + AC_MSG_RESULT([$with_build_python]) + ], [ + AS_VAR_IF([cross_compiling], [yes], + [AC_MSG_ERROR([Cross compiling requires --with-build-python])] + ) + PYTHON_FOR_BUILD='./$(BUILDPYTHON) -E' + ] +) +AC_SUBST([PYTHON_FOR_BUILD]) + AC_CHECK_PROGS([PYTHON_FOR_REGEN], [python$PACKAGE_VERSION python3.10 python3.9 python3.8 python3.7 python3.6 python3 python], [python3]) @@ -108,29 +167,6 @@ else AC_MSG_RESULT([missing]) fi -if test "$cross_compiling" = yes; then - AC_MSG_CHECKING([for python interpreter for cross build]) - if test -z "$PYTHON_FOR_BUILD"; then - for interp in python$PACKAGE_VERSION python3 python; do - which $interp >/dev/null 2>&1 || continue - if $interp -c "import sys;sys.exit(not '.'.join(str(n) for n in sys.version_info@<:@:2@:>@) == '$PACKAGE_VERSION')"; then - break - fi - interp= - done - if test x$interp = x; then - AC_MSG_ERROR([python$PACKAGE_VERSION interpreter not found]) - fi - AC_MSG_RESULT($interp) - PYTHON_FOR_BUILD='_PYTHON_PROJECT_BASE=$(abs_builddir) _PYTHON_HOST_PLATFORM=$(_PYTHON_HOST_PLATFORM) PYTHONPATH=$(shell test -f pybuilddir.txt && echo $(abs_builddir)/`cat pybuilddir.txt`:)$(srcdir)/Lib _PYTHON_SYSCONFIGDATA_NAME=_sysconfigdata_$(ABIFLAGS)_$(MACHDEP)_$(MULTIARCH) '$interp - fi -elif test "$cross_compiling" = maybe; then - AC_MSG_ERROR([Cross compiling required --host=HOST-TUPLE and --build=ARCH]) -else - PYTHON_FOR_BUILD='./$(BUILDPYTHON) -E' -fi -AC_SUBST(PYTHON_FOR_BUILD) - dnl Ensure that if prefix is specified, it does not end in a slash. If dnl it does, we get path names containing '//' which is both ugly and dnl can cause trouble. From 0a8c3397d36527178e7675fb65441ba1bcd74430 Mon Sep 17 00:00:00 2001 From: Christian Heimes Date: Mon, 29 Nov 2021 14:34:21 +0200 Subject: [PATCH 2/7] Rename arg to freeze-module Co-authored-by: Erlend Egeberg Aasland --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 976a537f5cd04a..48e2744db19ebe 100644 --- a/configure.ac +++ b/configure.ac @@ -102,7 +102,7 @@ rm -f pybuilddir.txt dnl cross-compiling needs a freeze_module binary for build platform AC_ARG_WITH( - [freeze_module], + [freeze-module], [AS_HELP_STRING([--with-freeze-module=Programs/_freeze_module], [path to _freeze_module binary for cross compiling (default: self-hosted Programs/_freeze_module binary)])], [ From 47f9e2ee01fec58a540102742d09001c82f8290f Mon Sep 17 00:00:00 2001 From: Christian Heimes Date: Mon, 29 Nov 2021 14:34:39 +0200 Subject: [PATCH 3/7] it's called _freeze_module Co-authored-by: Ethan Smith --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 48e2744db19ebe..482ee1ffe37cc2 100644 --- a/configure.ac +++ b/configure.ac @@ -109,7 +109,7 @@ AC_ARG_WITH( AC_MSG_CHECKING([for --with-freeze-module]) AS_VAR_IF([cross_compiling], [no], AC_MSG_ERROR([--with-freeze-module only applies to cross compiling])) if test "$with_freeze_module" = yes -o "$with_freeze_module" = no; then - AC_MSG_ERROR([invalid --with-freeze-module option: expect path, not "$with_freeze_module"]) + AC_MSG_ERROR([invalid --with-freeze-module option: expected path, not "$with_freeze_module"]) fi if ! $(command -v "$with_freeze_module" >/dev/null 2>&1); then AC_MSG_ERROR([invalid or missing freeze module binary "$with_freeze_module"]) From ad8c9da73a46860aa0883c84bbb57d1e26bcb513 Mon Sep 17 00:00:00 2001 From: Christian Heimes Date: Mon, 29 Nov 2021 14:34:46 +0200 Subject: [PATCH 4/7] Update configure.ac Co-authored-by: Ethan Smith --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 482ee1ffe37cc2..b7ec13c5487ad9 100644 --- a/configure.ac +++ b/configure.ac @@ -133,7 +133,7 @@ AC_ARG_WITH( AC_MSG_CHECKING([for --with-build-python]) AS_VAR_IF([cross_compiling], [no], AC_MSG_ERROR([--with-build-python only applies to cross compiling])) if test "$with_build_python" = yes -o "$with_build_python" = no; then - AC_MSG_ERROR([invalid -with-build-python option: expect path, not "$with_build_python"]) + AC_MSG_ERROR([invalid -with-build-python option: expected path, not "$with_build_python"]) fi if ! $(command -v "$with_build_python" >/dev/null 2>&1); then AC_MSG_ERROR([invalid or missing build Python binary "$with_build_python"]) From deab8e9ad72ce9171901891ac8c53f9a76500d91 Mon Sep 17 00:00:00 2001 From: Christian Heimes Date: Mon, 29 Nov 2021 14:34:53 +0200 Subject: [PATCH 5/7] Update configure.ac Co-authored-by: Ethan Smith --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index b7ec13c5487ad9..06159b440e5129 100644 --- a/configure.ac +++ b/configure.ac @@ -136,7 +136,7 @@ AC_ARG_WITH( AC_MSG_ERROR([invalid -with-build-python option: expected path, not "$with_build_python"]) fi if ! $(command -v "$with_build_python" >/dev/null 2>&1); then - AC_MSG_ERROR([invalid or missing build Python binary "$with_build_python"]) + AC_MSG_ERROR([invalid or missing build python binary "$with_build_python"]) fi build_python_ver=$($with_build_python -c "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}')") if test "$build_python_ver" != "$PACKAGE_VERSION"; then From 04d8eb05b0d7bfd1c16f56ec67714756370da83e Mon Sep 17 00:00:00 2001 From: Christian Heimes Date: Mon, 29 Nov 2021 16:30:20 +0100 Subject: [PATCH 6/7] More docs --- Doc/using/configure.rst | 50 +++++++++++++++++++++++++++++++++++++++++ configure | 36 ++++++++++++++++++----------- configure.ac | 13 ++++++----- 3 files changed, 80 insertions(+), 19 deletions(-) diff --git a/Doc/using/configure.rst b/Doc/using/configure.rst index c6aa4af73f4d3c..5720f015eca061 100644 --- a/Doc/using/configure.rst +++ b/Doc/using/configure.rst @@ -513,6 +513,56 @@ See ``Mac/README.rst``. :option:`--enable-framework` is set (default: ``Python``). +Cross Compiling Options +----------------------- + +Cross compiling, also known as cross building, can be used to build Python +for another CPU architecture or platform. Cross compiling requires a Python +interpreter and the :program:`_freeze_module` binary from another build. The +version of the build Python and :program:`_freeze_module` command must be +the same as the cross compiled host Python. + +.. cmdoption:: --build=BUILD + + configure for building on BUILD, usually guessed by :program:`config.guess`. + +.. cmdoption:: --host=HOST + + cross-compile to build programs to run on HOST (target platform) + +.. cmdoption:: --with-freeze-module=Programs/_freeze_module + + path to ``_freeze_module`` binary for cross compiling. + + .. versionadded:: 3.11 + +.. cmdoption:: --with-build-python=python3.xx + + path to build ``python`` binary for cross compiling + + .. versionadded:: 3.11 + +.. cmdoption:: CONFIG_SITE=file + + An environment variable that points to a file with configure overrides. + + Example *config.site* file:: + + # config.site-aarch64 + ac_cv_buggy_getaddrinfo=no + ac_cv_file__dev_ptmx=yes + ac_cv_file__dev_ptc=no + + +Cross compiling example:: + + CONFIG_SITE=config.site-aarch64 ../configure \ + --build=x86_64-pc-linux-gnu \ + --host=aarch64-unknown-linux-gnu \ + --with-freeze-module=../x86_64/Programs/_freeze_module \ + --with-build-python=../x86_64/python + + Python Build System =================== diff --git a/configure b/configure index 041b35e5eb16de..382e0309747279 100755 --- a/configure +++ b/configure @@ -1726,10 +1726,9 @@ Optional Packages: --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --with-freeze-module=Programs/_freeze_module path to _freeze_module binary for cross compiling - (default: self-hosted Programs/_freeze_module - binary) - --with-build-python path to build python binary for cross compiling - (default: self-hosted ./python binary) + --with-build-python=python3.11 + path to build python binary for cross compiling + (default: python3.11) --with-pkg-config=[yes|no|check] use pkg-config to detect build options (default is check) @@ -3195,13 +3194,16 @@ fi rm -f pybuilddir.txt -# Check whether --with-freeze_module was given. +# Check whether --with-freeze-module was given. if test "${with_freeze_module+set}" = set; then : withval=$with_freeze_module; { $as_echo "$as_me:${as_lineno-$LINENO}: checking for --with-freeze-module" >&5 $as_echo_n "checking for --with-freeze-module... " >&6; } - if test "$with_freeze_module" = yes -o "$with_freeze_module" = no; then - as_fn_error $? "invalid --with-freeze-module option: expect path, not \"$with_freeze_module\"" "$LINENO" 5 + if test "x$cross_compiling" = xno; then : + as_fn_error $? "--with-freeze-module only applies to cross compiling" "$LINENO" 5 +fi + if test "$with_freeze_module" = yes -o "$with_freeze_module" = no; then + as_fn_error $? "invalid --with-freeze-module option: expected path, not \"$with_freeze_module\"" "$LINENO" 5 fi if ! $(command -v "$with_freeze_module" >/dev/null 2>&1); then as_fn_error $? "invalid or missing freeze module binary \"$with_freeze_module\"" "$LINENO" 5 @@ -3229,11 +3231,19 @@ if test "${with_build_python+set}" = set; then : withval=$with_build_python; { $as_echo "$as_me:${as_lineno-$LINENO}: checking for --with-build-python" >&5 $as_echo_n "checking for --with-build-python... " >&6; } - if test "$with_build_python" = yes -o "$with_build_python" = no; then - as_fn_error $? "invalid --with-freeze-module option: expect path, not \"$with_build_python\"" "$LINENO" 5 - fi + + if test "x$cross_compiling" = xno; then : + as_fn_error $? "--with-build-python only applies to cross compiling" "$LINENO" 5 +fi + if test "x$with_build_python" = xyes; then : + with_build_python=python$PACKAGE_VERSION +fi + if test "x$with_build_python" = xno; then : + as_fn_error $? "invalid --with-build-python option: expected path, not \"no\"" "$LINENO" 5 +fi + if ! $(command -v "$with_build_python" >/dev/null 2>&1); then - as_fn_error $? "invalid or missing build Python binary \"$with_build_python\"" "$LINENO" 5 + as_fn_error $? "invalid or missing build python binary \"$with_build_python\"" "$LINENO" 5 fi build_python_ver=$($with_build_python -c "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}')") if test "$build_python_ver" != "$PACKAGE_VERSION"; then @@ -3241,8 +3251,8 @@ $as_echo_n "checking for --with-build-python... " >&6; } fi ac_cv_prog_PYTHON_FOR_REGEN=$with_build_python PYTHON_FOR_BUILD='_PYTHON_PROJECT_BASE=$(abs_builddir) _PYTHON_HOST_PLATFORM=$(_PYTHON_HOST_PLATFORM) PYTHONPATH=$(shell test -f pybuilddir.txt && echo $(abs_builddir)/`cat pybuilddir.txt`:)$(srcdir)/Lib _PYTHON_SYSCONFIGDATA_NAME=_sysconfigdata_$(ABIFLAGS)_$(MACHDEP)_$(MULTIARCH) '$with_build_python - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PYTHON_FOR_BUILD" >&5 -$as_echo "$PYTHON_FOR_BUILD" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_build_python" >&5 +$as_echo "$with_build_python" >&6; } else diff --git a/configure.ac b/configure.ac index 06159b440e5129..1e5fef337ca5d1 100644 --- a/configure.ac +++ b/configure.ac @@ -104,7 +104,7 @@ dnl cross-compiling needs a freeze_module binary for build platform AC_ARG_WITH( [freeze-module], [AS_HELP_STRING([--with-freeze-module=Programs/_freeze_module], - [path to _freeze_module binary for cross compiling (default: self-hosted Programs/_freeze_module binary)])], + [path to _freeze_module binary for cross compiling])], [ AC_MSG_CHECKING([for --with-freeze-module]) AS_VAR_IF([cross_compiling], [no], AC_MSG_ERROR([--with-freeze-module only applies to cross compiling])) @@ -127,14 +127,15 @@ AC_SUBST([FREEZE_MODULE]) AC_ARG_WITH( [build-python], - [AS_HELP_STRING([--with-build-python], - [path to build python binary for cross compiling (default: self-hosted ./python binary)])], + [AS_HELP_STRING([--with-build-python=python]PYTHON_VERSION, + [path to build python binary for cross compiling (default: python]PYTHON_VERSION[)])], [ AC_MSG_CHECKING([for --with-build-python]) + AS_VAR_IF([cross_compiling], [no], AC_MSG_ERROR([--with-build-python only applies to cross compiling])) - if test "$with_build_python" = yes -o "$with_build_python" = no; then - AC_MSG_ERROR([invalid -with-build-python option: expected path, not "$with_build_python"]) - fi + AS_VAR_IF([with_build_python], [yes], [with_build_python=python$PACKAGE_VERSION]) + AS_VAR_IF([with_build_python], [no], [AC_MSG_ERROR([invalid --with-build-python option: expected path, not "no"])]) + if ! $(command -v "$with_build_python" >/dev/null 2>&1); then AC_MSG_ERROR([invalid or missing build python binary "$with_build_python"]) fi From e4eff12e133862a50a7d8694c94ca9ad50034db7 Mon Sep 17 00:00:00 2001 From: Christian Heimes Date: Mon, 29 Nov 2021 16:33:02 +0100 Subject: [PATCH 7/7] blurb --- Misc/NEWS.d/next/Build/2021-11-29-16-32-55.bpo-45881.7597J6.rst | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 Misc/NEWS.d/next/Build/2021-11-29-16-32-55.bpo-45881.7597J6.rst diff --git a/Misc/NEWS.d/next/Build/2021-11-29-16-32-55.bpo-45881.7597J6.rst b/Misc/NEWS.d/next/Build/2021-11-29-16-32-55.bpo-45881.7597J6.rst new file mode 100644 index 00000000000000..7ee57d0db1a923 --- /dev/null +++ b/Misc/NEWS.d/next/Build/2021-11-29-16-32-55.bpo-45881.7597J6.rst @@ -0,0 +1,2 @@ +The :program:`configure` script now accepts ``--with-build-python`` and +``--with-freeze-module`` options to make cross compiling easier.