]> granicus.if.org Git - python/commitdiff
Issue #21166: Prevent possible segfaults and other random failures of
authorNed Deily <nad@acm.org>
Fri, 22 Aug 2014 20:30:59 +0000 (13:30 -0700)
committerNed Deily <nad@acm.org>
Fri, 22 Aug 2014 20:30:59 +0000 (13:30 -0700)
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.

Makefile.pre.in
Misc/NEWS
configure
configure.ac

index 80a09269e693412afd2fb95d971e1e187de7ccc7..c3568366e170b91379c277f1266f2c309c090d42 100644 (file)
@@ -447,8 +447,18 @@ platform: $(BUILDPYTHON) pybuilddir.txt
 # Create build directory and generate the sysconfig build-time data there.
 # pybuilddir.txt contains the name of the build dir and is used for
 # sys.path fixup -- see Modules/getpath.c.
+# Since this step runs before shared modules are built, try to avoid bootstrap
+# problems by creating a dummy pybuildstr.txt just to allow interpreter
+# initialization to succeed.  It will be overwritten by generate-posix-vars
+# or removed in case of failure.
 pybuilddir.txt: $(BUILDPYTHON)
-               $(RUNSHARED) $(PYTHON_FOR_BUILD) -S -m sysconfig --generate-posix-vars
+       @echo "none" > ./pybuilddir.txt
+       $(RUNSHARED) $(PYTHON_FOR_BUILD) -S -m sysconfig --generate-posix-vars ;\
+       if test $$? -ne 0 ; then \
+               echo "generate-posix-vars failed" ; \
+               rm -f ./pybuilddir.txt ; \
+               exit 1 ; \
+       fi
 
 # Build the shared modules
 # Under GNU make, MAKEFLAGS are sorted and normalized; the 's' for
index cbe93b11e345d48e3961c23fda9735724b094c85..b8dab3067d54fd6d899ff7c7bce431b13f68b0fb 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -120,6 +120,9 @@ Build
 - Issue #15759: "make suspicious", "make linkcheck" and "make doctest" in Doc/
   now display special message when and only when there are failures.
 
+- Issue #21166: Prevent possible segfaults and other random failures of
+  python --generate-posix-vars in pybuilddir.txt build target.
+
 Windows
 -------
 
index 2c1c82d815d02138d50cf25960dc4ae5739c7cdc..4a698f352a9d2ff3f66f64f7fbc4926c8dd44c4f 100755 (executable)
--- a/configure
+++ b/configure
@@ -2857,6 +2857,9 @@ case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac
 
 
 
+# pybuilddir.txt will be created by --generate-posix-vars in the Makefile
+rm -f pybuilddir.txt
+
 if test "$cross_compiling" = yes; then
     { $as_echo "$as_me:${as_lineno-$LINENO}: checking for python interpreter for cross build" >&5
 $as_echo_n "checking for python interpreter for cross build... " >&6; }
index 54f8c0f69f8815086e6960e6c1dc5d4254210285..16da9f39996b24d8fba3d7162317fb14a9f98f23 100644 (file)
@@ -16,6 +16,9 @@ AC_CANONICAL_HOST
 AC_SUBST(build)
 AC_SUBST(host)
 
+# pybuilddir.txt will be created by --generate-posix-vars in the Makefile
+rm -f pybuilddir.txt
+
 if test "$cross_compiling" = yes; then
     AC_MSG_CHECKING([for python interpreter for cross build])
     if test -z "$PYTHON_FOR_BUILD"; then