Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fcbc246

Browse files
committed
Issue #21166: Prevent possible segfaults and other random failures of
python --generate-posix-vars in pybuilddir.txt build target by ensuring that pybuilddir.txt is always regenerated when configure is run and that the newly built skeleton python does not inadvertently import modules from previously installed instances.
1 parent 0242f79 commit fcbc246

4 files changed

Lines changed: 20 additions & 1 deletion

File tree

Makefile.pre.in

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,8 +546,18 @@ platform: $(BUILDPYTHON) pybuilddir.txt
546546
# Create build directory and generate the sysconfig build-time data there.
547547
# pybuilddir.txt contains the name of the build dir and is used for
548548
# sys.path fixup -- see Modules/getpath.c.
549+
# Since this step runs before shared modules are built, try to avoid bootstrap
550+
# problems by creating a dummy pybuildstr.txt just to allow interpreter
551+
# initialization to succeed. It will be overwritten by generate-posix-vars
552+
# or removed in case of failure.
549553
pybuilddir.txt: $(BUILDPYTHON)
550-
$(RUNSHARED) $(PYTHON_FOR_BUILD) -S -m sysconfig --generate-posix-vars
554+
@echo "none" > ./pybuilddir.txt
555+
$(RUNSHARED) $(PYTHON_FOR_BUILD) -S -m sysconfig --generate-posix-vars ;\
556+
if test $$? -ne 0 ; then \
557+
echo "generate-posix-vars failed" ; \
558+
rm -f ./pybuilddir.txt ; \
559+
exit 1 ; \
560+
fi
551561

552562
# Build the shared modules
553563
# Under GNU make, MAKEFLAGS are sorted and normalized; the 's' for

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,9 @@ Build
242242

243243
- Issue #21811: Anticipated fixes to support OS X versions > 10.9.
244244

245+
- Issue #21166: Prevent possible segfaults and other random failures of
246+
python --generate-posix-vars in pybuilddir.txt build target.
247+
245248
IDLE
246249
----
247250

configure

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2950,6 +2950,9 @@ case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac
29502950

29512951

29522952

2953+
# pybuilddir.txt will be created by --generate-posix-vars in the Makefile
2954+
rm -f pybuilddir.txt
2955+
29532956
if test "$cross_compiling" = yes; then
29542957
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for python interpreter for cross build" >&5
29552958
$as_echo_n "checking for python interpreter for cross build... " >&6; }

configure.ac

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ AC_CANONICAL_HOST
5353
AC_SUBST(build)
5454
AC_SUBST(host)
5555

56+
# pybuilddir.txt will be created by --generate-posix-vars in the Makefile
57+
rm -f pybuilddir.txt
58+
5659
if test "$cross_compiling" = yes; then
5760
AC_MSG_CHECKING([for python interpreter for cross build])
5861
if test -z "$PYTHON_FOR_BUILD"; then

0 commit comments

Comments
 (0)