Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 15 additions & 8 deletions cpython-unix/build-cpython.sh
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,15 @@ if [ -n "${PYTHON_MEETS_MAXIMUM_VERSION_3_12}" ]; then
patch -p1 -i "${ROOT}/patch-cpython-configure-target-triple-musl-3.12.patch"
fi

# Python 3.11 supports using a provided Python to use during bootstrapping
# (e.g. freezing). Normally it only uses this Python during cross-compiling.
# This patch forces always using it. See comment related to
# `--with-build-python` for more.
patch -p1 -i "${ROOT}/patch-always-build-python-for-freeze.patch"
# Link the native build helpers with only the modules from `Modules/Setup.bootstrap`
# so other built-in modules can depend on the helpers' output.
# https://github.com/python/cpython/pull/160537
patch -p1 -i "${ROOT}/patch-bootstrap-helpers.patch"
if [ "${PYTHON_MAJMIN_VERSION}" = "3.11" ]; then
patch -p1 -i "${ROOT}/patch-bootstrap-helpers-configure-3.11.patch"
else
patch -p1 -i "${ROOT}/patch-bootstrap-helpers-configure.patch"
fi

# Add a make target to write the PYTHON_FOR_BUILD variable so we can
# invoke the host Python on our own.
Expand Down Expand Up @@ -567,9 +571,7 @@ if [ -n "${CPYTHON_LTO}" ]; then
CONFIGURE_FLAGS="${CONFIGURE_FLAGS} --with-lto=full"
fi

# Python 3.11 introduces a --with-build-python to denote the host Python.
# It is required when cross-compiling. But we always build a host Python
# to avoid complexity with the bootstrap Python binary.
# Supply the matching host interpreter to CPython's build configuration.
CONFIGURE_FLAGS="${CONFIGURE_FLAGS} --with-build-python=${TOOLS_PATH}/host/bin/python${PYTHON_MAJMIN_VERSION}"

if [[ "${PYBUILD_PLATFORM}" = macos* ]]; then
Expand Down Expand Up @@ -1385,6 +1387,11 @@ for d in ${OBJECT_DIRS}; do
fi
done

# Exclude helper-specific objects that conflict with interpreter objects
# when downstream consumers relink them.
rm -f "${ROOT}/out/python/build/Modules"/{config_bootstrap,getbuildinfo_bootstrap,getpath_noop}.o
rm -f "${ROOT}/out/python/build/Programs"/{_bootstrap_python,_freeze_module}.o

# The object files need to be linked against library dependencies. So copy
# library files as well.
mkdir "${ROOT}/out/python/build/lib"
Expand Down
36 changes: 0 additions & 36 deletions cpython-unix/patch-always-build-python-for-freeze.patch

This file was deleted.

29 changes: 29 additions & 0 deletions cpython-unix/patch-bootstrap-helpers-configure-3.11.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
diff --git a/configure.ac b/configure.ac
--- a/configure.ac
+++ b/configure.ac
@@ -7148,8 +7148,8 @@
AC_MSG_NOTICE([creating Makefile])
$SHELL $srcdir/Modules/makesetup -c $srcdir/Modules/config.c.in \
-s Modules \
- Modules/Setup.local $MODULES_SETUP_STDLIB Modules/Setup.bootstrap $srcdir/Modules/Setup
-mv config.c Modules
+ Modules/Setup.local $MODULES_SETUP_STDLIB -b Modules/Setup.bootstrap $srcdir/Modules/Setup
+mv config.c config_bootstrap.c Modules

if test -z "$PKG_CONFIG"; then
AC_MSG_WARN([pkg-config is missing. Some dependencies may not be detected correctly.])
diff --git a/Makefile.pre.in b/Makefile.pre.in
--- a/Makefile.pre.in
+++ b/Makefile.pre.in
@@ -951,9 +951,9 @@
-s Modules \
Modules/Setup.local \
@MODULES_SETUP_STDLIB@ \
- Modules/Setup.bootstrap \
+ -b Modules/Setup.bootstrap \
$(srcdir)/Modules/Setup
- @mv config.c Modules
+ @mv config.c config_bootstrap.c Modules
@echo "The Makefile was updated, you may need to re-run make."

.PHONY: regen-test-frozenmain
33 changes: 33 additions & 0 deletions cpython-unix/patch-bootstrap-helpers-configure.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
diff --git a/configure.ac b/configure.ac
--- a/configure.ac
+++ b/configure.ac
@@ -7604,12 +7604,12 @@
AC_MSG_NOTICE([creating Makefile])
$SHELL $srcdir/Modules/makesetup -c $srcdir/Modules/config.c.in \
-s Modules \
- Modules/Setup.local Modules/Setup.stdlib Modules/Setup.bootstrap $srcdir/Modules/Setup
+ Modules/Setup.local Modules/Setup.stdlib -b Modules/Setup.bootstrap $srcdir/Modules/Setup
if test $? -ne 0; then
AC_MSG_ERROR([makesetup failed])
fi

-mv config.c Modules
+mv config.c config_bootstrap.c Modules

if test -z "$PKG_CONFIG"; then
AC_MSG_WARN([pkg-config is missing. Some dependencies may not be detected correctly.])
diff --git a/Makefile.pre.in b/Makefile.pre.in
--- a/Makefile.pre.in
+++ b/Makefile.pre.in
@@ -1039,9 +1039,9 @@
-s Modules \
Modules/Setup.local \
Modules/Setup.stdlib \
- Modules/Setup.bootstrap \
+ -b Modules/Setup.bootstrap \
$(srcdir)/Modules/Setup
- @mv config.c Modules
+ @mv config.c config_bootstrap.c Modules
@echo "The Makefile was updated, you may need to re-run make."

.PHONY: regen-test-frozenmain
Loading
Loading