[Python-checkins] bpo-45950: Fix macOS framework builds of _bootstrap_python (GH-29936)

tiran webhook-mailer at python.org
Mon Dec 6 11:14:04 EST 2021


https://github.com/python/cpython/commit/612e59b53f0c730ce1b881f7c08dc6d49f02c123
commit: 612e59b53f0c730ce1b881f7c08dc6d49f02c123
branch: main
author: Christian Heimes <christian at python.org>
committer: tiran <christian at python.org>
date: 2021-12-06T17:13:53+01:00
summary:

bpo-45950: Fix macOS framework builds of _bootstrap_python (GH-29936)

files:
M Makefile.pre.in
M Modules/getpath.c
M configure
M configure.ac

diff --git a/Makefile.pre.in b/Makefile.pre.in
index 8e6e553554de1..94fc5c37209ef 100644
--- a/Makefile.pre.in
+++ b/Makefile.pre.in
@@ -954,9 +954,9 @@ BOOTSTRAP_HEADERS = \
 
 Programs/_bootstrap_python.o: Programs/_bootstrap_python.c $(BOOTSTRAP_HEADERS) $(PYTHON_HEADERS)
 
-_bootstrap_python: $(LIBRARY_OBJS_OMIT_FROZEN) Programs/_bootstrap_python.o Modules/getpath.o Modules/Setup.local
+_bootstrap_python: $(LIBRARY_OBJS_OMIT_FROZEN) Programs/_bootstrap_python.o Modules/getpath_bootstrap.o Modules/Setup.local
 	$(LINKCC) $(PY_LDFLAGS_NOLTO) -o $@ $(LIBRARY_OBJS_OMIT_FROZEN) \
-		Programs/_bootstrap_python.o Modules/getpath.o $(LIBS) $(MODLIBS) $(SYSLIBS)
+		Programs/_bootstrap_python.o Modules/getpath_bootstrap.o $(LIBS) $(MODLIBS) $(SYSLIBS)
 
 ############################################################################
 # Deepfreeze targets
@@ -1205,6 +1205,18 @@ Modules/getpath.o: $(srcdir)/Modules/getpath.c Python/frozen_modules/getpath.h M
 		-DPLATLIBDIR='"$(PLATLIBDIR)"' \
 		-o $@ $(srcdir)/Modules/getpath.c
 
+# like getpath.o with additional -DPY_BOOTSTRAP_PYTHON=1
+Modules/getpath_bootstrap.o: $(srcdir)/Modules/getpath.c Python/frozen_modules/getpath.h Makefile $(PYTHON_HEADERS)
+	$(CC) -c $(PY_CORE_CFLAGS) -DPYTHONPATH='"$(PYTHONPATH)"' \
+		-DPREFIX='"$(prefix)"' \
+		-DEXEC_PREFIX='"$(exec_prefix)"' \
+		-DVERSION='"$(VERSION)"' \
+		-DVPATH='"$(VPATH)"' \
+		-DPLATLIBDIR='"$(PLATLIBDIR)"' \
+		-DPY_BOOTSTRAP_PYTHON=1 \
+		-o $@ $(srcdir)/Modules/getpath.c
+
+
 Programs/python.o: $(srcdir)/Programs/python.c
 	$(MAINCC) -c $(PY_CORE_CFLAGS) -o $@ $(srcdir)/Programs/python.c
 
diff --git a/Modules/getpath.c b/Modules/getpath.c
index f77b18eee95b6..8f90a7008625f 100644
--- a/Modules/getpath.c
+++ b/Modules/getpath.c
@@ -754,7 +754,8 @@ library_to_dict(PyObject *dict, const char *key)
     if (PyWin_DLLhModule) {
         return winmodule_to_dict(dict, key, PyWin_DLLhModule);
     }
-#elif defined(WITH_NEXT_FRAMEWORK)
+#elif defined(WITH_NEXT_FRAMEWORK) && !defined(PY_BOOTSTRAP_PYTHON)
+    // _bootstrap_python does not use framework and crashes
     static const char modPath[MAXPATHLEN + 1];
     static int modPathInitialized = -1;
     if (modPathInitialized < 0) {
diff --git a/configure b/configure
index 8582224dfd28f..fca9567c7102f 100755
--- a/configure
+++ b/configure
@@ -1736,7 +1736,7 @@ Optional Packages:
                           path to _freeze_module binary for cross compiling
   --with-build-python=python3.11
                           path to build python binary for cross compiling
-                          (default: python3.11)
+                          (default: _bootstrap_python or python3.11)
   --with-pkg-config=[yes|no|check]
                           use pkg-config to detect build options (default is
                           check)
@@ -3243,14 +3243,11 @@ if test "${with_build_python+set}" = set; then :
     { $as_echo "$as_me:${as_lineno-$LINENO}: checking for --with-build-python" >&5
 $as_echo_n "checking for --with-build-python... " >&6; }
 
-    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
+  as_fn_error $? "invalid --with-build-python option: expected path or \"yes\", not \"no\"" "$LINENO" 5
 fi
 
     if ! $(command -v "$with_build_python" >/dev/null 2>&1); then
diff --git a/configure.ac b/configure.ac
index 39890fe38f0a1..c7c71255a3a4c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -125,16 +125,16 @@ AC_ARG_WITH(
 )
 AC_SUBST([FREEZE_MODULE])
 
+dnl build-python is used for cross compiling and macOS framework builds.
 AC_ARG_WITH(
   [build-python],
   [AS_HELP_STRING([--with-build-python=python]PYTHON_VERSION,
-                  [path to build python binary for cross compiling (default: python]PYTHON_VERSION[)])],
+                  [path to build python binary for cross compiling (default: _bootstrap_python or 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]))
     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"])])
+    AS_VAR_IF([with_build_python], [no], [AC_MSG_ERROR([invalid --with-build-python option: expected path or "yes", 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"])



More information about the Python-checkins mailing list