Patchwork [pph] preliminary build support for stdc++.h.pph

login
register
mail settings
Submitter Benjamin Kosnik
Date March 22, 2012, 10:36 p.m.
Message ID <20120322153619.53191d8a@adair>
Download mbox | patch
Permalink /patch/148350/
State New
Headers show

Comments

Benjamin Kosnik - March 22, 2012, 10:36 p.m.
Seems like -fpph doesn't work on the pph branch anymore, and instead
-fpph-gen/-fpph-map/-fpph-hdr are used.

The thing is, how are these flags used?

unhelpful wiki page:
http://gcc.gnu.org/wiki/pph

Based on invoke.texi, I'm expecting something like this:


1. generate
g++ -fpph-gen all.h; 
// generates all.pph

2. use
g++ -fpph-hdr=all.h   foo.cc 
// like -include=all.h, but works with pph files

Is this right? 

-benjamin

2012-03-22  Benjamin Kosnik  <bkoz@redhat.com>

	    * include/Makefile.am (allcreated): Add pph build rule.
	    (pch1_source): ... to pre_1_source.
	    (pch2_source): ... to pre_2_source.
	    (pch3_source): ... to pre_3_source.
	    (pph_output): New.
	    (PPH_GEN_FLAGS): New.
	    * include/Makefile.in: Regenerate.

${pch3_output_builddir} @@ -891,6 +890,9 @@
 pch_build =
 endif
 
+pph_output = ${host_builddir}/stdc++.h.pph
+PPH_GEN_FLAGS = -x c++-header -nostdinc++ -fpph-gen
+
 # List of all timestamp files.  By keeping only one copy of this list,
both # CLEANFILES and all-local are kept up-to-date.
 allstamped = \
@@ -904,7 +906,8 @@
 allcreated = \
 	${host_builddir}/c++config.h \
 	${thread_host_headers} \
-	${pch_build}
+	${pch_build} \
+	${pph_output}
 
 # Here are the rules for building the headers
 all-local: ${allstamped} ${allcreated}
@@ -1153,25 +1156,30 @@
 	    < $< > $@
 
 # Build two precompiled C++ includes, stdc++.h.gch/*.gch
-${pch1a_output}: ${allstamped} ${host_builddir}/c++config.h
${pch1_source} +${pch1a_output}: ${allstamped}
${host_builddir}/c++config.h ${pre_1_source} -mkdir -p
${pch1_output_builddir}
-	$(CXX) $(PCHFLAGS) $(AM_CPPFLAGS) -O2 -g -std=gnu++0x
${pch1_source} \
+	$(CXX) $(PCHFLAGS) $(AM_CPPFLAGS) -O2 -g -std=gnu++0x
${pre_1_source} \ -o $@
 
-${pch1b_output}: ${allstamped} ${host_builddir}/c++config.h
${pch1_source} +${pch1b_output}: ${allstamped}
${host_builddir}/c++config.h ${pre_1_source} -mkdir -p
${pch1_output_builddir}
-	$(CXX) $(PCHFLAGS) $(AM_CPPFLAGS) -O2 -g ${pch1_source} -o $@
+	$(CXX) $(PCHFLAGS) $(AM_CPPFLAGS) -O2 -g ${pre_1_source} -o $@
 
 # Build a precompiled TR1 include, stdtr1c++.h.gch/O2.gch
-${pch2_output}: ${pch2_source} ${pch1_output}
+${pch2_output}: ${pre_2_source} ${pch1_output}
 	-mkdir -p ${pch2_output_builddir}
-	$(CXX) $(PCHFLAGS) $(AM_CPPFLAGS) -O2 -g ${pch2_source} -o $@
+	$(CXX) $(PCHFLAGS) $(AM_CPPFLAGS) -O2 -g ${pre_2_source} -o $@
 
 # Build a precompiled extension include, extc++.h.gch/O2.gch
-${pch3_output}: ${pch3_source} ${pch2_output}
+${pch3_output}: ${pre_3_source} ${pch2_output}
 	-mkdir -p ${pch3_output_builddir}
-	$(CXX) $(PCHFLAGS) $(AM_CPPFLAGS) -O2 -g ${pch3_source} -o $@
+	$(CXX) $(PCHFLAGS) $(AM_CPPFLAGS) -O2 -g ${pre_3_source} -o $@
 
+# Build a preprocessed C++ include stdc++.h.pph
+pph: ${pph_output}
+${pph_output}: ${allstamped} ${host_builddir}/c++config.h
${pre_1_source}
+	$(CXX) $(PPH_GEN_FLAGS) $(AM_CPPFLAGS) -O2 -g ${pre_1_source}
-o $@ +
 # For robustness sake (in light of junk files or in-source
 # configuration), copy from the build or source tree to the install
 # tree using only the human-maintained file lists and directory
@@ -1291,7 +1299,7 @@
 	  $(INSTALL_DATA) $${file} $(DESTDIR)${host_installdir}; done
 
 # By adding these files here, automake will remove them for 'make
clean' -CLEANFILES = ${pch_output} ${pch_output_anchors} stamp-host
+CLEANFILES = ${pch_output} ${pch_output_anchors} ${pph_output}
stamp-host 
 # To remove directories.
 clean-local:
Lawrence Crowl - March 22, 2012, 11:42 p.m.
On 3/22/12, Benjamin De Kosnik <bkoz@redhat.com> wrote:
> Seems like -fpph doesn't work on the pph branch anymore, and
> instead -fpph-gen/-fpph-map/-fpph-hdr are used.
>
> The thing is, how are these flags used?

-fpph-map=basename

   Enable reading PPH files, and instead of reading #include
   "basename.h", read "basename.pph".

-fpph-map=mapfile

   Enable reading pph files, and supply a file of mappings from
   #include directives to PPH file.  The file format is a sequence
   of lines, each with header and PPH file separated by a tab.

-fpph-gen whatever.h -o whatever.pph

  The -fpph-gen flag says a header is being compiled and a pph file
  should be generated.

> unhelpful wiki page:
> http://gcc.gnu.org/wiki/pph

Zero user documentation.  Hasn't been updated in a while.

> Based on invoke.texi, I'm expecting something like this:
>
> 1. generate
> g++ -fpph-gen all.h;
> // generates all.pph

Add -o.

> 2. use
> g++ -fpph-hdr=all.h   foo.cc
> // like -include=all.h, but works with pph files

No, that flag doesn't cause any input in and of itself.  It just
causes the #include to read a different file.

> Is this right?

Some notes below.  The main problem is that users would need to

  #include <precompiled/stdc++.h>

and the compiler would need to provide an implicit mapping.

We could probably modify -include to pick up PPH files, but that
wasn't in our use model.

So, it turns out that the hardest files for PPH to deal with are
system headers and C++ standard headers.  There are some headers
that we do not yet handle right, among others, the atomics header
is causing us grief.  That header gets include in others and thus
infects the others.

I think your use is ahead of the implementation, and maybe now is
not the time to work on integrating it into the build.

>
> -benjamin
>
> 2012-03-22  Benjamin Kosnik  <bkoz@redhat.com>
>
> 	    * include/Makefile.am (allcreated): Add pph build rule.
> 	    (pch1_source): ... to pre_1_source.
> 	    (pch2_source): ... to pre_2_source.
> 	    (pch3_source): ... to pre_3_source.
> 	    (pph_output): New.
> 	    (PPH_GEN_FLAGS): New.
> 	    * include/Makefile.in: Regenerate.
>
> Index: include/Makefile.am
> ===================================================================
> --- include/Makefile.am	(revision 185703)
> +++ include/Makefile.am	(working copy)
> @@ -858,7 +858,7 @@
>  	${host_builddir}/gthr-default.h
>
>
> -pch1_source = ${glibcxx_srcdir}/include/precompiled/stdc++.h
> +pre_1_source = ${glibcxx_srcdir}/include/precompiled/stdc++.h
>  pch1_output_builddir = ${host_builddir}/stdc++.h.gch
>  pch1_output_anchor = ${host_builddir}/stdc++.h
>  pch1_output_installdir = ${host_installdir}/stdc++.h.gch
> @@ -866,19 +866,18 @@
>  pch1b_output = ${pch1_output_builddir}/O2g.gch
>  pch1_output = ${pch1a_output} ${pch1b_output}
>
> -pch2_source = ${glibcxx_srcdir}/include/precompiled/stdtr1c++.h
> +pre_2_source = ${glibcxx_srcdir}/include/precompiled/stdtr1c++.h
>  pch2_output_builddir = ${host_builddir}/stdtr1c++.h.gch
>  pch2_output_anchor = ${host_builddir}/stdtr1c++.h
>  pch2_output_installdir = ${host_installdir}/stdtr1c++.h.gch
>  pch2_output = ${pch2_output_builddir}/O2g.gch
>
> -pch3_source = ${glibcxx_srcdir}/include/precompiled/extc++.h
> +pre_3_source = ${glibcxx_srcdir}/include/precompiled/extc++.h
>  pch3_output_builddir = ${host_builddir}/extc++.h.gch
>  pch3_output_anchor = ${host_builddir}/extc++.h
>  pch3_output_installdir = ${host_installdir}/extc++.h.gch
>  pch3_output = ${pch3_output_builddir}/O2g.gch
>
> -
>  pch_output = ${pch1_output} ${pch2_output} ${pch3_output}
>  pch_output_dirs = \
>  	${pch1_output_builddir} ${pch2_output_builddir}
> ${pch3_output_builddir} @@ -891,6 +890,9 @@
>  pch_build =
>  endif
>
> +pph_output = ${host_builddir}/stdc++.h.pph
> +PPH_GEN_FLAGS = -x c++-header -nostdinc++ -fpph-gen
> +

The -x flag is not needed.

>  # List of all timestamp files.  By keeping only one copy of this list,
> both # CLEANFILES and all-local are kept up-to-date.
>  allstamped = \
> @@ -904,7 +906,8 @@
>  allcreated = \
>  	${host_builddir}/c++config.h \
>  	${thread_host_headers} \
> -	${pch_build}
> +	${pch_build} \
> +	${pph_output}
>
>  # Here are the rules for building the headers
>  all-local: ${allstamped} ${allcreated}
> @@ -1153,25 +1156,30 @@
>  	    < $< > $@
>
>  # Build two precompiled C++ includes, stdc++.h.gch/*.gch
> -${pch1a_output}: ${allstamped} ${host_builddir}/c++config.h
> ${pch1_source} +${pch1a_output}: ${allstamped}
> ${host_builddir}/c++config.h ${pre_1_source} -mkdir -p
> ${pch1_output_builddir}
> -	$(CXX) $(PCHFLAGS) $(AM_CPPFLAGS) -O2 -g -std=gnu++0x
> ${pch1_source} \
> +	$(CXX) $(PCHFLAGS) $(AM_CPPFLAGS) -O2 -g -std=gnu++0x
> ${pre_1_source} \ -o $@
>
> -${pch1b_output}: ${allstamped} ${host_builddir}/c++config.h
> ${pch1_source} +${pch1b_output}: ${allstamped}
> ${host_builddir}/c++config.h ${pre_1_source} -mkdir -p
> ${pch1_output_builddir}
> -	$(CXX) $(PCHFLAGS) $(AM_CPPFLAGS) -O2 -g ${pch1_source} -o $@
> +	$(CXX) $(PCHFLAGS) $(AM_CPPFLAGS) -O2 -g ${pre_1_source} -o $@

The command line is not a direct replacement for PCH.  Separate rules?

>
>  # Build a precompiled TR1 include, stdtr1c++.h.gch/O2.gch
> -${pch2_output}: ${pch2_source} ${pch1_output}
> +${pch2_output}: ${pre_2_source} ${pch1_output}
>  	-mkdir -p ${pch2_output_builddir}
> -	$(CXX) $(PCHFLAGS) $(AM_CPPFLAGS) -O2 -g ${pch2_source} -o $@
> +	$(CXX) $(PCHFLAGS) $(AM_CPPFLAGS) -O2 -g ${pre_2_source} -o $@
>
>  # Build a precompiled extension include, extc++.h.gch/O2.gch
> -${pch3_output}: ${pch3_source} ${pch2_output}
> +${pch3_output}: ${pre_3_source} ${pch2_output}
>  	-mkdir -p ${pch3_output_builddir}
> -	$(CXX) $(PCHFLAGS) $(AM_CPPFLAGS) -O2 -g ${pch3_source} -o $@
> +	$(CXX) $(PCHFLAGS) $(AM_CPPFLAGS) -O2 -g ${pre_3_source} -o $@
>
> +# Build a preprocessed C++ include stdc++.h.pph
> +pph: ${pph_output}
> +${pph_output}: ${allstamped} ${host_builddir}/c++config.h
> ${pre_1_source}
> +	$(CXX) $(PPH_GEN_FLAGS) $(AM_CPPFLAGS) -O2 -g ${pre_1_source}
> -o $@ +
>  # For robustness sake (in light of junk files or in-source
>  # configuration), copy from the build or source tree to the install
>  # tree using only the human-maintained file lists and directory
> @@ -1291,7 +1299,7 @@
>  	  $(INSTALL_DATA) $${file} $(DESTDIR)${host_installdir}; done
>
>  # By adding these files here, automake will remove them for 'make
> clean' -CLEANFILES = ${pch_output} ${pch_output_anchors} stamp-host
> +CLEANFILES = ${pch_output} ${pch_output_anchors} ${pph_output}
> stamp-host
>  # To remove directories.
>  clean-local:

Patch


2012-03-22  Benjamin Kosnik  <bkoz@redhat.com>

	    * include/Makefile.am (allcreated): Add pph build rule.
	    (pch1_source): ... to pre_1_source.
	    (pch2_source): ... to pre_2_source.
	    (pch3_source): ... to pre_3_source.
	    (pph_output): New.
	    (PPH_GEN_FLAGS): New.
	    * include/Makefile.in: Regenerate.

Index: include/Makefile.am
===================================================================
--- include/Makefile.am	(revision 185703)
+++ include/Makefile.am	(working copy)
@@ -858,7 +858,7 @@ 
 	${host_builddir}/gthr-default.h
 
 
-pch1_source = ${glibcxx_srcdir}/include/precompiled/stdc++.h
+pre_1_source = ${glibcxx_srcdir}/include/precompiled/stdc++.h
 pch1_output_builddir = ${host_builddir}/stdc++.h.gch
 pch1_output_anchor = ${host_builddir}/stdc++.h
 pch1_output_installdir = ${host_installdir}/stdc++.h.gch
@@ -866,19 +866,18 @@ 
 pch1b_output = ${pch1_output_builddir}/O2g.gch
 pch1_output = ${pch1a_output} ${pch1b_output}
 
-pch2_source = ${glibcxx_srcdir}/include/precompiled/stdtr1c++.h
+pre_2_source = ${glibcxx_srcdir}/include/precompiled/stdtr1c++.h
 pch2_output_builddir = ${host_builddir}/stdtr1c++.h.gch
 pch2_output_anchor = ${host_builddir}/stdtr1c++.h
 pch2_output_installdir = ${host_installdir}/stdtr1c++.h.gch
 pch2_output = ${pch2_output_builddir}/O2g.gch
 
-pch3_source = ${glibcxx_srcdir}/include/precompiled/extc++.h
+pre_3_source = ${glibcxx_srcdir}/include/precompiled/extc++.h
 pch3_output_builddir = ${host_builddir}/extc++.h.gch
 pch3_output_anchor = ${host_builddir}/extc++.h
 pch3_output_installdir = ${host_installdir}/extc++.h.gch
 pch3_output = ${pch3_output_builddir}/O2g.gch
 
-
 pch_output = ${pch1_output} ${pch2_output} ${pch3_output}
 pch_output_dirs = \
 	${pch1_output_builddir} ${pch2_output_builddir} ${pch3_output_builddir}
@@ -891,6 +890,9 @@ 
 pch_build =
 endif
 
+pph_output = ${host_builddir}/stdc++.h.pph
+PPH_GEN_FLAGS = -x c++-header -nostdinc++ -fpph-gen
+
 # List of all timestamp files.  By keeping only one copy of this list, both
 # CLEANFILES and all-local are kept up-to-date.
 allstamped = \
@@ -904,7 +906,8 @@ 
 allcreated = \
 	${host_builddir}/c++config.h \
 	${thread_host_headers} \
-	${pch_build}
+	${pch_build} \
+	${pph_output}
 
 # Here are the rules for building the headers
 all-local: ${allstamped} ${allcreated}
@@ -1153,25 +1156,30 @@ 
 	    < $< > $@
 
 # Build two precompiled C++ includes, stdc++.h.gch/*.gch
-${pch1a_output}: ${allstamped} ${host_builddir}/c++config.h ${pch1_source}
+${pch1a_output}: ${allstamped} ${host_builddir}/c++config.h ${pre_1_source}
 	-mkdir -p ${pch1_output_builddir}
-	$(CXX) $(PCHFLAGS) $(AM_CPPFLAGS) -O2 -g -std=gnu++0x ${pch1_source} \
+	$(CXX) $(PCHFLAGS) $(AM_CPPFLAGS) -O2 -g -std=gnu++0x ${pre_1_source} \
 	-o $@
 
-${pch1b_output}: ${allstamped} ${host_builddir}/c++config.h ${pch1_source}
+${pch1b_output}: ${allstamped} ${host_builddir}/c++config.h ${pre_1_source}
 	-mkdir -p ${pch1_output_builddir}
-	$(CXX) $(PCHFLAGS) $(AM_CPPFLAGS) -O2 -g ${pch1_source} -o $@
+	$(CXX) $(PCHFLAGS) $(AM_CPPFLAGS) -O2 -g ${pre_1_source} -o $@
 
 # Build a precompiled TR1 include, stdtr1c++.h.gch/O2.gch
-${pch2_output}: ${pch2_source} ${pch1_output}
+${pch2_output}: ${pre_2_source} ${pch1_output}
 	-mkdir -p ${pch2_output_builddir}
-	$(CXX) $(PCHFLAGS) $(AM_CPPFLAGS) -O2 -g ${pch2_source} -o $@
+	$(CXX) $(PCHFLAGS) $(AM_CPPFLAGS) -O2 -g ${pre_2_source} -o $@
 
 # Build a precompiled extension include, extc++.h.gch/O2.gch
-${pch3_output}: ${pch3_source} ${pch2_output}
+${pch3_output}: ${pre_3_source} ${pch2_output}
 	-mkdir -p ${pch3_output_builddir}
-	$(CXX) $(PCHFLAGS) $(AM_CPPFLAGS) -O2 -g ${pch3_source} -o $@
+	$(CXX) $(PCHFLAGS) $(AM_CPPFLAGS) -O2 -g ${pre_3_source} -o $@
 
+# Build a preprocessed C++ include stdc++.h.pph
+pph: ${pph_output}
+${pph_output}: ${allstamped} ${host_builddir}/c++config.h ${pre_1_source}
+	$(CXX) $(PPH_GEN_FLAGS) $(AM_CPPFLAGS) -O2 -g ${pre_1_source} -o $@
+
 # For robustness sake (in light of junk files or in-source
 # configuration), copy from the build or source tree to the install
 # tree using only the human-maintained file lists and directory
@@ -1291,7 +1299,7 @@ 
 	  $(INSTALL_DATA) $${file} $(DESTDIR)${host_installdir}; done
 
 # By adding these files here, automake will remove them for 'make clean'
-CLEANFILES = ${pch_output} ${pch_output_anchors} stamp-host
+CLEANFILES = ${pch_output} ${pch_output_anchors} ${pph_output} stamp-host
 
 # To remove directories.
 clean-local: