This is the mail archive of the
mailing list for the GCC project.
[PATCH]: Fix PR bootstrap/29402 parallel make bug
- From: "Kaveh R. GHAZI" <ghazi at caip dot rutgers dot edu>
- To: gcc-patches at gcc dot gnu dot org
- Date: Thu, 12 Oct 2006 12:11:33 -0400 (EDT)
- Subject: [PATCH]: Fix PR bootstrap/29402 parallel make bug
This patch fixes PR 29402, a problem with parallel make unique to
mainline. In the PR I noted that I was having the problem with
--disable-bootstrap. However it can actually manifest itself in any gcc
configuration using parallel make.
The root of this lies in a non-portable construct used in the shell code
which creates ALL_GTFILES_H. That variable controls the dependencies we
need and when it's incorrectly set it leads to the failure I saw. (Thanks
to Andrew Pinski for pointing me at ALL_GTFILES_H.)
The non-portable construct is the use of '\n' in the tr program. I found
some shell magic in autoconf sources (written in 1999) that works around
this issue. Given how old it is, I have a high degree of confidence it is
safe and portable. I've copied that code plus the explanitory comment
into gcc/Makefile.in and it solved the problem.
Tested on sparc-sun-solaris2.10 with a "make -j4". The build error noted
in the PR no longer occurs.
Okay to install?
2006-10-12 Kaveh R. Ghazi <email@example.com>
* Makefile.in (ALL_GTFILES_H): Don't assume '\n' works in tr.
diff -rup orig/egcc-SVN20061011/gcc/Makefile.in egcc-SVN20061011/gcc/Makefile.in
--- orig/egcc-SVN20061011/gcc/Makefile.in 2006-10-10 20:01:28.000000000 -0400
+++ egcc-SVN20061011/gcc/Makefile.in 2006-10-12 11:09:13.170034040 -0400
@@ -2882,8 +2882,15 @@ GTFILES_FILES_FILES_C = $(subst $(srcdir
GTFILES_FILES_FILES_H = $(addprefix gt-, \
GTFILES_LANG_DIR_NAMES_H = $(foreach d,$(GTFILES_LANG_DIR_NAMES), gtype-$(d).h)
-ALL_GTFILES_H := $(shell echo $(GTFILES_FILES_FILES_H) \
- $(GTFILES_LANG_DIR_NAMES_H) | tr ' ' '\n' | sort -u)
+# We use echo to avoid assuming a particular line-breaking character.
+# The extra dot is to prevent the shell from consuming trailing
+# line-breaks from the sub-command output. A line-break within
+# single-quotes doesn't work because, if this script is created in a
+# platform that uses two characters for line-breaks (e.g., DOS), tr
+# would break.
+ALL_GTFILES_H := $(shell gcc_LF_and_dot=`echo; echo .` ;\
+ echo $(GTFILES_FILES_FILES_H) \
+ $(GTFILES_LANG_DIR_NAMES_H) | tr ' .' "$$gcc_LF_and_dot" | sort -u)
$(ALL_GTFILES_H) : s-gtype ; @true