File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -553,8 +553,18 @@ platform: $(BUILDPYTHON) pybuilddir.txt
553553# Create build directory and generate the sysconfig build-time data there.
554554# pybuilddir.txt contains the name of the build dir and is used for
555555# sys.path fixup -- see Modules/getpath.c.
556+ # Since this step runs before shared modules are built, try to avoid bootstrap
557+ # problems by creating a dummy pybuildstr.txt just to allow interpreter
558+ # initialization to succeed. It will be overwritten by generate-posix-vars
559+ # or removed in case of failure.
556560pybuilddir.txt: $(BUILDPYTHON)
557- $(RUNSHARED) $(PYTHON_FOR_BUILD) -S -m sysconfig --generate-posix-vars
561+ @echo "none" > ./pybuilddir.txt
562+ $(RUNSHARED) $(PYTHON_FOR_BUILD) -S -m sysconfig --generate-posix-vars ;\
563+ if test $$? -ne 0 ; then \
564+ echo "generate-posix-vars failed" ; \
565+ rm -f ./pybuilddir.txt ; \
566+ exit 1 ; \
567+ fi
558568
559569# Build the shared modules
560570# Under GNU make, MAKEFLAGS are sorted and normalized; the 's' for
Original file line number Diff line number Diff line change @@ -825,6 +825,9 @@ Build
825825
826826- Issue #21811: Anticipated fixes to support OS X versions > 10.9.
827827
828+ - Issue #21166: Prevent possible segfaults and other random failures of
829+ python --generate-posix-vars in pybuilddir.txt build target.
830+
828831C API
829832-----
830833
Original file line number Diff line number Diff line change @@ -2954,6 +2954,9 @@ case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac
29542954
29552955
29562956
2957+ # pybuilddir.txt will be created by --generate-posix-vars in the Makefile
2958+ rm -f pybuilddir.txt
2959+
29572960if test " $cross_compiling " = yes; then
29582961 { $as_echo " $as_me :${as_lineno-$LINENO } : checking for python interpreter for cross build" >&5
29592962$as_echo_n " checking for python interpreter for cross build... " >&6 ; }
Original file line number Diff line number Diff line change @@ -53,6 +53,9 @@ AC_CANONICAL_HOST
5353AC_SUBST ( build )
5454AC_SUBST ( host )
5555
56+ # pybuilddir.txt will be created by --generate-posix-vars in the Makefile
57+ rm -f pybuilddir.txt
58+
5659if test "$cross_compiling" = yes; then
5760 AC_MSG_CHECKING ( [ for python interpreter for cross build] )
5861 if test -z "$PYTHON_FOR_BUILD"; then
You can’t perform that action at this time.
0 commit comments