# We need to ensure our host tools get run during build, not the freshly # built cross-tools (this will not work), so we introduce HOSTPYTHON and HOSTPGEN. # Signed-Off: Michael 'Mickey' Lauer Index: Python-2.7.1/setup.py =================================================================== --- Python-2.7.1.orig/setup.py 2010-12-27 13:16:38.032631011 -0500 +++ Python-2.7.1/setup.py 2010-12-27 13:16:50.130290766 -0500 @@ -313,6 +313,7 @@ self.failed.append(ext.name) self.announce('*** WARNING: renaming "%s" since importing it' ' failed: %s' % (ext.name, why), level=3) + return assert not self.inplace basename, tail = os.path.splitext(ext_filename) newname = basename + "_failed" + tail @@ -347,8 +348,8 @@ def detect_modules(self): # Ensure that /usr/local is always used - add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') - add_dir_to_list(self.compiler.include_dirs, '/usr/local/include') + # add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') + # add_dir_to_list(self.compiler.include_dirs, '/usr/local/include') # Add paths specified in the environment variables LDFLAGS and # CPPFLAGS for header and library files. @@ -452,6 +453,9 @@ # XXX Omitted modules: gl, pure, dl, SGI-specific modules + lib_dirs = [ os.getenv( "STAGING_LIBDIR" ) ] + inc_dirs = [ os.getenv( "STAGING_INCDIR" ) ] + # # The following modules are all pretty straightforward, and compile # on pretty much any POSIXish platform. Index: Python-2.7.1/Makefile.pre.in =================================================================== --- Python-2.7.1.orig/Makefile.pre.in 2010-12-27 13:16:38.022628181 -0500 +++ Python-2.7.1/Makefile.pre.in 2010-12-27 13:17:31.870473931 -0500 @@ -201,6 +201,7 @@ ########################################################################## # Grammar +GRAMMAR_STAMP= $(srcdir)/grammar-stamp GRAMMAR_H= $(srcdir)/Include/graminit.h GRAMMAR_C= $(srcdir)/Python/graminit.c GRAMMAR_INPUT= $(srcdir)/Grammar/Grammar @@ -380,7 +381,7 @@ $(MAKE) all CFLAGS="$(CFLAGS) -fprofile-generate" LIBS="$(LIBS) -lgcov" run_profile_task: - ./$(BUILDPYTHON) $(PROFILE_TASK) + $(HOSTPYTHON) $(PROFILE_TASK) build_all_use_profile: $(MAKE) all CFLAGS="$(CFLAGS) -fprofile-use" @@ -398,14 +399,14 @@ $(BLDLIBRARY) $(LIBS) $(MODLIBS) $(SYSLIBS) $(LDLAST) platform: $(BUILDPYTHON) - $(RUNSHARED) ./$(BUILDPYTHON) -E -c 'import sys ; from sysconfig import get_platform ; print get_platform()+"-"+sys.version[0:3]' >platform + $(RUNSHARED) $(HOSTPYTHON) -E -c 'import sys ; from sysconfig import get_platform ; print get_platform()+"-"+sys.version[0:3]' >platform # Build the shared modules sharedmods: $(BUILDPYTHON) @case $$MAKEFLAGS in \ - *s*) $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' ./$(BUILDPYTHON) -E $(srcdir)/setup.py -q build;; \ - *) $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' ./$(BUILDPYTHON) -E $(srcdir)/setup.py build;; \ + *s*) $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' $(HOSTPYTHON) -E $(srcdir)/setup.py -q build;; \ + *) $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' $(HOSTPYTHON) -E $(srcdir)/setup.py build;; \ esac # Build static library @@ -535,10 +536,24 @@ Modules/python.o: $(srcdir)/Modules/python.c $(MAINCC) -c $(PY_CFLAGS) -o $@ $(srcdir)/Modules/python.c +# GNU "make" interprets rules with two dependents as two copies of the rule. +# +# In a parallel build this can lead to pgen being run twice, once for each of +# GRAMMAR_H and GRAMMAR_C, leading to race conditions in which the compiler +# reads a partially-overwritten copy of one of these files, leading to syntax +# errors (or linker errors if the fragment happens to be syntactically valid C) +# +# See http://www.gnu.org/software/hello/manual/automake/Multiple-Outputs.html +# for more information. +# +# Introduce ".grammar-stamp" as a contrived single output from PGEN to avoid +# this: +$(GRAMMAR_H) $(GRAMMAR_C): $(GRAMMAR_STAMP) -$(GRAMMAR_H) $(GRAMMAR_C): $(PGEN) $(GRAMMAR_INPUT) +$(GRAMMAR_STAMP): $(PGEN) $(GRAMMAR_INPUT) -@$(INSTALL) -d Include -$(PGEN) $(GRAMMAR_INPUT) $(GRAMMAR_H) $(GRAMMAR_C) + touch $(GRAMMAR_STAMP) $(PGEN): $(PGENOBJS) $(CC) $(OPT) $(LDFLAGS) $(PGENOBJS) $(LIBS) -o $(PGEN) @@ -921,25 +936,25 @@ done $(INSTALL_DATA) $(srcdir)/LICENSE $(DESTDIR)$(LIBDEST)/LICENSE.txt PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \ - ./$(BUILDPYTHON) -Wi -tt $(DESTDIR)$(LIBDEST)/compileall.py \ + $(HOSTPYTHON) -Wi -tt $(DESTDIR)$(LIBDEST)/compileall.py \ -d $(LIBDEST) -f \ -x 'bad_coding|badsyntax|site-packages|lib2to3/tests/data' \ $(DESTDIR)$(LIBDEST) PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \ - ./$(BUILDPYTHON) -Wi -tt -O $(DESTDIR)$(LIBDEST)/compileall.py \ + $(HOSTPYTHON) -Wi -tt -O $(DESTDIR)$(LIBDEST)/compileall.py \ -d $(LIBDEST) -f \ -x 'bad_coding|badsyntax|site-packages|lib2to3/tests/data' \ $(DESTDIR)$(LIBDEST) -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \ - ./$(BUILDPYTHON) -Wi -t $(DESTDIR)$(LIBDEST)/compileall.py \ + $(HOSTPYTHON) -Wi -t $(DESTDIR)$(LIBDEST)/compileall.py \ -d $(LIBDEST)/site-packages -f \ -x badsyntax $(DESTDIR)$(LIBDEST)/site-packages -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \ - ./$(BUILDPYTHON) -Wi -t -O $(DESTDIR)$(LIBDEST)/compileall.py \ + $(HOSTPYTHON) -Wi -t -O $(DESTDIR)$(LIBDEST)/compileall.py \ -d $(LIBDEST)/site-packages -f \ -x badsyntax $(DESTDIR)$(LIBDEST)/site-packages -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \ - ./$(BUILDPYTHON) -Wi -t -c "import lib2to3.pygram, lib2to3.patcomp;lib2to3.patcomp.PatternCompiler()" + $(HOSTPYTHON) -Wi -t -c "import lib2to3.pygram, lib2to3.patcomp;lib2to3.patcomp.PatternCompiler()" # Create the PLATDIR source directory, if one wasn't distributed.. $(srcdir)/Lib/$(PLATDIR): @@ -1044,7 +1059,7 @@ # Install the dynamically loadable modules # This goes into $(exec_prefix) sharedinstall: sharedmods - $(RUNSHARED) ./$(BUILDPYTHON) -E $(srcdir)/setup.py install \ + $(RUNSHARED) $(HOSTPYTHON) -E $(srcdir)/setup.py install \ --prefix=$(prefix) \ --install-scripts=$(BINDIR) \ --install-platlib=$(DESTSHARED) \ @@ -1117,7 +1132,7 @@ # This installs a few of the useful scripts in Tools/scripts scriptsinstall: SRCDIR=$(srcdir) $(RUNSHARED) \ - ./$(BUILDPYTHON) $(srcdir)/Tools/scripts/setup.py install \ + $(HOSTPYTHON) $(srcdir)/Tools/scripts/setup.py install \ --prefix=$(prefix) \ --install-scripts=$(BINDIR) \ --root=/$(DESTDIR) @@ -1139,7 +1154,7 @@ # Run reindent on the library reindent: - ./$(BUILDPYTHON) $(srcdir)/Tools/scripts/reindent.py -r $(srcdir)/Lib + $(HOSTPYTHON) $(srcdir)/Tools/scripts/reindent.py -r $(srcdir)/Lib # Rerun configure with the same options as it was run last time, # provided the config.status script exists @@ -1242,7 +1257,7 @@ # Perform some verification checks on any modified files. patchcheck: - $(RUNSHARED) ./$(BUILDPYTHON) $(srcdir)/Tools/scripts/patchcheck.py + $(RUNSHARED) $(HOSTPYTHON) $(srcdir)/Tools/scripts/patchcheck.py # Dependencies