Skip to content

Commit 04d8eb0

Browse files
committed
More docs
1 parent deab8e9 commit 04d8eb0

File tree

3 files changed

+80
-19
lines changed

3 files changed

+80
-19
lines changed

Doc/using/configure.rst

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,56 @@ See ``Mac/README.rst``.
513513
:option:`--enable-framework` is set (default: ``Python``).
514514

515515

516+
Cross Compiling Options
517+
-----------------------
518+
519+
Cross compiling, also known as cross building, can be used to build Python
520+
for another CPU architecture or platform. Cross compiling requires a Python
521+
interpreter and the :program:`_freeze_module` binary from another build. The
522+
version of the build Python and :program:`_freeze_module` command must be
523+
the same as the cross compiled host Python.
524+
525+
.. cmdoption:: --build=BUILD
526+
527+
configure for building on BUILD, usually guessed by :program:`config.guess`.
528+
529+
.. cmdoption:: --host=HOST
530+
531+
cross-compile to build programs to run on HOST (target platform)
532+
533+
.. cmdoption:: --with-freeze-module=Programs/_freeze_module
534+
535+
path to ``_freeze_module`` binary for cross compiling.
536+
537+
.. versionadded:: 3.11
538+
539+
.. cmdoption:: --with-build-python=python3.xx
540+
541+
path to build ``python`` binary for cross compiling
542+
543+
.. versionadded:: 3.11
544+
545+
.. cmdoption:: CONFIG_SITE=file
546+
547+
An environment variable that points to a file with configure overrides.
548+
549+
Example *config.site* file::
550+
551+
# config.site-aarch64
552+
ac_cv_buggy_getaddrinfo=no
553+
ac_cv_file__dev_ptmx=yes
554+
ac_cv_file__dev_ptc=no
555+
556+
557+
Cross compiling example::
558+
559+
CONFIG_SITE=config.site-aarch64 ../configure \
560+
--build=x86_64-pc-linux-gnu \
561+
--host=aarch64-unknown-linux-gnu \
562+
--with-freeze-module=../x86_64/Programs/_freeze_module \
563+
--with-build-python=../x86_64/python
564+
565+
516566
Python Build System
517567
===================
518568

configure

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1726,10 +1726,9 @@ Optional Packages:
17261726
--without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
17271727
--with-freeze-module=Programs/_freeze_module
17281728
path to _freeze_module binary for cross compiling
1729-
(default: self-hosted Programs/_freeze_module
1730-
binary)
1731-
--with-build-python path to build python binary for cross compiling
1732-
(default: self-hosted ./python binary)
1729+
--with-build-python=python3.11
1730+
path to build python binary for cross compiling
1731+
(default: python3.11)
17331732
--with-pkg-config=[yes|no|check]
17341733
use pkg-config to detect build options (default is
17351734
check)
@@ -3195,13 +3194,16 @@ fi
31953194
rm -f pybuilddir.txt
31963195

31973196

3198-
# Check whether --with-freeze_module was given.
3197+
# Check whether --with-freeze-module was given.
31993198
if test "${with_freeze_module+set}" = set; then :
32003199
withval=$with_freeze_module;
32013200
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for --with-freeze-module" >&5
32023201
$as_echo_n "checking for --with-freeze-module... " >&6; }
3203-
if test "$with_freeze_module" = yes -o "$with_freeze_module" = no; then
3204-
as_fn_error $? "invalid --with-freeze-module option: expect path, not \"$with_freeze_module\"" "$LINENO" 5
3202+
if test "x$cross_compiling" = xno; then :
3203+
as_fn_error $? "--with-freeze-module only applies to cross compiling" "$LINENO" 5
3204+
fi
3205+
if test "$with_freeze_module" = yes -o "$with_freeze_module" = no; then
3206+
as_fn_error $? "invalid --with-freeze-module option: expected path, not \"$with_freeze_module\"" "$LINENO" 5
32053207
fi
32063208
if ! $(command -v "$with_freeze_module" >/dev/null 2>&1); then
32073209
as_fn_error $? "invalid or missing freeze module binary \"$with_freeze_module\"" "$LINENO" 5
@@ -3229,20 +3231,28 @@ if test "${with_build_python+set}" = set; then :
32293231
withval=$with_build_python;
32303232
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for --with-build-python" >&5
32313233
$as_echo_n "checking for --with-build-python... " >&6; }
3232-
if test "$with_build_python" = yes -o "$with_build_python" = no; then
3233-
as_fn_error $? "invalid --with-freeze-module option: expect path, not \"$with_build_python\"" "$LINENO" 5
3234-
fi
3234+
3235+
if test "x$cross_compiling" = xno; then :
3236+
as_fn_error $? "--with-build-python only applies to cross compiling" "$LINENO" 5
3237+
fi
3238+
if test "x$with_build_python" = xyes; then :
3239+
with_build_python=python$PACKAGE_VERSION
3240+
fi
3241+
if test "x$with_build_python" = xno; then :
3242+
as_fn_error $? "invalid --with-build-python option: expected path, not \"no\"" "$LINENO" 5
3243+
fi
3244+
32353245
if ! $(command -v "$with_build_python" >/dev/null 2>&1); then
3236-
as_fn_error $? "invalid or missing build Python binary \"$with_build_python\"" "$LINENO" 5
3246+
as_fn_error $? "invalid or missing build python binary \"$with_build_python\"" "$LINENO" 5
32373247
fi
32383248
build_python_ver=$($with_build_python -c "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}')")
32393249
if test "$build_python_ver" != "$PACKAGE_VERSION"; then
32403250
as_fn_error $? "\"$with_build_python\" has incompatible version $build_python_ver (expected: $PACKAGE_VERSION)" "$LINENO" 5
32413251
fi
32423252
ac_cv_prog_PYTHON_FOR_REGEN=$with_build_python
32433253
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
3244-
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $PYTHON_FOR_BUILD" >&5
3245-
$as_echo "$PYTHON_FOR_BUILD" >&6; }
3254+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_build_python" >&5
3255+
$as_echo "$with_build_python" >&6; }
32463256

32473257
else
32483258

configure.ac

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ dnl cross-compiling needs a freeze_module binary for build platform
104104
AC_ARG_WITH(
105105
[freeze-module],
106106
[AS_HELP_STRING([--with-freeze-module=Programs/_freeze_module],
107-
[path to _freeze_module binary for cross compiling (default: self-hosted Programs/_freeze_module binary)])],
107+
[path to _freeze_module binary for cross compiling])],
108108
[
109109
AC_MSG_CHECKING([for --with-freeze-module])
110110
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])
127127

128128
AC_ARG_WITH(
129129
[build-python],
130-
[AS_HELP_STRING([--with-build-python],
131-
[path to build python binary for cross compiling (default: self-hosted ./python binary)])],
130+
[AS_HELP_STRING([--with-build-python=python]PYTHON_VERSION,
131+
[path to build python binary for cross compiling (default: python]PYTHON_VERSION[)])],
132132
[
133133
AC_MSG_CHECKING([for --with-build-python])
134+
134135
AS_VAR_IF([cross_compiling], [no], AC_MSG_ERROR([--with-build-python only applies to cross compiling]))
135-
if test "$with_build_python" = yes -o "$with_build_python" = no; then
136-
AC_MSG_ERROR([invalid -with-build-python option: expected path, not "$with_build_python"])
137-
fi
136+
AS_VAR_IF([with_build_python], [yes], [with_build_python=python$PACKAGE_VERSION])
137+
AS_VAR_IF([with_build_python], [no], [AC_MSG_ERROR([invalid --with-build-python option: expected path, not "no"])])
138+
138139
if ! $(command -v "$with_build_python" >/dev/null 2>&1); then
139140
AC_MSG_ERROR([invalid or missing build python binary "$with_build_python"])
140141
fi

0 commit comments

Comments
 (0)