This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
[PATCH, v3] PR 35954: rebuild of precompiled headers
- From: Ralf Wildenhues <Ralf dot Wildenhues at gmx dot de>
- To: gcc-patches at gcc dot gnu dot org, libstdc++ at gcc dot gnu dot org
- Date: Fri, 18 Apr 2008 07:21:31 +0200
- Subject: [PATCH, v3] PR 35954: rebuild of precompiled headers
On my i686-unknown-linux-gnu system, configured with
.../configure -C --enable-languages=c,c++
each make invocation regenerates the precompiled headers anew, and
breaks builds with read-only source trees.
These are the relevant Makefile bits:
host_builddir = ./${host_alias}/bits
pch1_output_anchor = ${host_builddir}/stdc++.h
host_headers = \
[...]
${glibcxx_srcdir}/include/precompiled/stdc++.h \
${glibcxx_srcdir}/include/precompiled/stdtr1c++.h \
${glibcxx_srcdir}/include/precompiled/extc++.h
allstamped = \
[...]
stamp-tr1 stamp-tr1-impl stamp-debug stamp-parallel stamp-host
${pch1a_output}: ${allstamped} ${host_builddir}/c++config.h ${pch1_source}
if [ ! -d "${pch1_output_builddir}" ]; then \
mkdir -p ${pch1_output_builddir}; \
fi; \
$(CXX) $(PCHFLAGS) $(AM_CPPFLAGS) -O0 -g ${pch1_source} -o $@
touch ${pch1_output_anchor}
stamp-host: ${host_headers} ${host_headers_noinst} stamp-${host_alias}
@if [ ! -f stamp-host ]; then \
(cd ${host_builddir} ;\
$(LN_S) ${host_headers} . || true ;\
$(LN_S) ${glibcxx_srcdir}/$(BASIC_FILE_H) basic_file.h || true ;\
[...]
$(LN_S) ${glibcxx_srcdir}/$(CTIME_H) time_members.h || true);\
fi ;\
$(STAMP) stamp-host
but i686-unknown-linux-gnu/bits/stdc++.h is a symlink to
${glibcxx_srcdir}/include/precompiled/stdc++.h
so via the symlink there is a circular dependency between the stamp-host
and the ${pch1a_output} rule, it's just that make does not see that.
The 'touch' was added by
<http://gcc.gnu.org/ml/libstdc++/2006-07/msg00080.html>. IMVHO it is
superfluous: the header file is not newer just because a new precompiled
header exists for it. The precompiled header should not generate
rebuilds of depending files. I can only assume this touch was added
because of the bug fixed in
<http://gcc.gnu.org/ml/gcc-patches/2008-03/msg01103.html> which hasn't
been reviewed yet. But maybe there's another reason I'm not aware of?
While we're at it, let's inline the 'mkdir -p' here, too, as it saves a
fork during the first build, and doesn't increase the number of forks on
subsequent builds. (And would fix potential parallel build errors for
non-GNU make, not sure if that's relevant for libstdc++.)
OK for trunk and 4.3? I've had this patch for a while, but I'll be
bootstrapping it again just in case.
Thanks,
Ralf
libstdc++-v3/ChangeLog:
2008-04-18 Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
PR libstdc++/35954
* include/Makefile.am (pch*_output): Do not touch pch*_output_anchor.
Call 'mkdir -p' unconditionally, but ignore its return value.
* include/Makefile.in: Regenerate.
diff --git a/libstdc++-v3/include/Makefile.am b/libstdc++-v3/include/Makefile.am
index 68e8e35..1769a5e 100644
--- a/libstdc++-v3/include/Makefile.am
+++ b/libstdc++-v3/include/Makefile.am
@@ -1123,34 +1123,22 @@ ${host_builddir}/gthr-default.h: ${toplevel_srcdir}/gcc/${glibcxx_thread_h} \
# Build two precompiled C++ includes, stdc++.h.gch/*.gch
${pch1a_output}: ${allstamped} ${host_builddir}/c++config.h ${pch1_source}
- if [ ! -d "${pch1_output_builddir}" ]; then \
- mkdir -p ${pch1_output_builddir}; \
- fi; \
+ -mkdir -p ${pch1_output_builddir}
$(CXX) $(PCHFLAGS) $(AM_CPPFLAGS) -O0 -g ${pch1_source} -o $@
- touch ${pch1_output_anchor}
${pch1b_output}: ${allstamped} ${host_builddir}/c++config.h ${pch1_source}
- if [ ! -d "${pch1_output_builddir}" ]; then \
- mkdir -p ${pch1_output_builddir}; \
- fi; \
+ -mkdir -p ${pch1_output_builddir}
$(CXX) $(PCHFLAGS) $(AM_CPPFLAGS) -O2 -g ${pch1_source} -o $@
- touch ${pch1_output_anchor}
# Build a precompiled TR1 include, stdtr1c++.h.gch/O2.gch
${pch2_output}: ${pch2_source} ${pch1_output}
- if [ ! -d "${pch2_output_builddir}" ]; then \
- mkdir -p ${pch2_output_builddir}; \
- fi; \
+ -mkdir -p ${pch2_output_builddir}
$(CXX) $(PCHFLAGS) $(AM_CPPFLAGS) -O2 -g ${pch2_source} -o $@
- touch ${pch2_output_anchor}
# Build a precompiled extension include, extc++.h.gch/O2.gch
${pch3_output}: ${pch3_source} ${pch2_output}
- if [ ! -d "${pch3_output_builddir}" ]; then \
- mkdir -p ${pch3_output_builddir}; \
- fi; \
+ -mkdir -p ${pch3_output_builddir}
$(CXX) $(PCHFLAGS) $(AM_CPPFLAGS) -O2 -g ${pch3_source} -o $@
- touch ${pch3_output_anchor}
# For robustness sake (in light of junk files or in-source
# configuration), copy from the build or source tree to the install