Currently, in order for the dependencies to be tracked and stored in a .gch file to be subsequently used with -fpch-deps, one must manually specify -MD switch when compiling the precompiled header. Otherwise, the dependency information is not recorded in the precompiled header, and subsequent compilation of a source file with -fpch-deps will erroneously lists no dependencies. For example:
caladan:~ >g++ -x c++header test.h caladan:~ >g++ test.cpp -MD -MP -MF deps.txt -o test.x will give caladan:~ >cat deps.txt test.x: test.cpp while caladan:~ >g++ -MD -MF /dev/null -x c++header test.h caladan:~ >g++ -fpch-deps test.cpp -MD -MP -MF deps.txt -o test.x produces the full list of dependencies in deps.txt. This is unfortunately both counter-intuitive and undocumented, leaving one in the dark as to why the seemingly correct code above does not produce the expected result. Attached is the proposed short patch which would by default activate dependency tracking (-MD) for .pch compilations. It has been tested on Linux (RHEL4) with GCC 4.1.1 and SVN HEAD, with no adverse sideeffects. -- Summary: Dependency tracking should be on by default when copiling .gchs Product: gcc Version: 4.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: pch AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: mjuric at astro dot princeton dot edu GCC build triplet: i686-pc-linux-gnu GCC host triplet: i686-pc-linux-gnu GCC target triplet: i686-pc-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28483