churchyard / rpms / python3

Forked from rpms/python3 6 years ago
Clone

Blame python-3.1.2-fix-parallel-make.patch

4983daa
diff -up Python-3.1.2/Makefile.pre.in.fix-parallel-make Python-3.1.2/Makefile.pre.in
4983daa
--- Python-3.1.2/Makefile.pre.in.fix-parallel-make	2010-10-13 13:13:52.888849568 -0400
4983daa
+++ Python-3.1.2/Makefile.pre.in	2010-10-13 13:15:10.322184015 -0400
4983daa
@@ -215,6 +215,7 @@ IO_OBJS=	\
4983daa
 
4983daa
 ##########################################################################
4983daa
 # Grammar
4983daa
+GRAMMAR_STAMP=	$(srcdir)/grammar-stamp
4983daa
 GRAMMAR_H=	$(srcdir)/Include/graminit.h
4983daa
 GRAMMAR_C=	$(srcdir)/Python/graminit.c
4983daa
 GRAMMAR_INPUT=	$(srcdir)/Grammar/Grammar
4983daa
@@ -535,9 +536,24 @@ Modules/python.o: $(srcdir)/Modules/pyth
4983daa
 
4983daa
 $(IO_OBJS): $(IO_H)
4983daa
 
4983daa
-$(GRAMMAR_H) $(GRAMMAR_C): $(PGEN) $(GRAMMAR_INPUT)
4983daa
+# GNU "make" interprets rules with two dependents as two copies of the rule.
4983daa
+#
4983daa
+# In a parallel build this can lead to pgen being run twice, once for each of
4983daa
+# GRAMMAR_H and GRAMMAR_C, leading to race conditions in which the compiler
4983daa
+# reads a partially-overwritten copy of one of these files, leading to syntax
4983daa
+# errors (or linker errors if the fragment happens to be syntactically valid C)
4983daa
+#
4983daa
+# See http://www.gnu.org/software/hello/manual/automake/Multiple-Outputs.html
4983daa
+# for more information
4983daa
+#
4983daa
+# Introduce ".grammar-stamp" as a contrived single output from PGEN to avoid
4983daa
+# this:
4983daa
+$(GRAMMAR_H) $(GRAMMAR_C): $(GRAMMAR_STAMP)
4983daa
+
4983daa
+$(GRAMMAR_STAMP): $(PGEN) $(GRAMMAR_INPUT)
4983daa
 		-@$(INSTALL) -d Include
4983daa
 		-$(PGEN) $(GRAMMAR_INPUT) $(GRAMMAR_H) $(GRAMMAR_C)
4983daa
+		touch $(GRAMMAR_STAMP)
4983daa
 
4983daa
 $(PGEN):	$(PGENOBJS)
4983daa
 		$(CC) $(OPT) $(LDFLAGS) $(PGENOBJS) $(LIBS) -o $(PGEN)