United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-7175914 Usage of gcc with precompiled headers produces wrong build dependencies
JDK-7175914 : Usage of gcc with precompiled headers produces wrong build dependencies

Details
Type:
Bug
Submit Date:
2012-06-11
Status:
Resolved
Updated Date:
2013-06-19
Project Name:
JDK
Resolved Date:
2012-06-16
Component:
hotspot
OS:
linux
Sub-Component:
build
CPU:
generic
Priority:
P3
Resolution:
Fixed
Affected Versions:
8
Fixed Versions:
hs24 (b14)

Related Reports
Backport:
Backport:
Backport:

Sub Tasks

Description
gcc with -MMD does not output the dependencies of the precompiled header unless the -fpch-deps flag is also provided.
Volker Simonis writes:

Dependencies which are resolved from the precompiled headers file during
compilation are not by default listed as dependencies in the dependencies file
generated by gcc with the '-MMD' option. This leads to incomplete dependencies
and potentially bogus incremental builds. To fix the problem, we have to
additionally use the '-fpch-deps' option which instructs gcc to include
dependencies from the precompiled headers file as well.

Notice that the gcc documentation (at least for gcc 4.1 and 4.4) is imprecise
with respect to precompiled headers and dependencies genereation. The
description of the flags for the generation of the dependency-files (-M, -MM,
-MMD, ..) don't even mention that these flags may be impacted by the use of
precompiled headers. The description of '-fpch-deps' is wrong in the sense that
it claims that if it is not set, a dependency for the precompiled header file
will be generated. This is not true for gcc 4.1 and 4.4. If '-fpch-deps' is not
set, the generated dependencies file only contains dependencies which are not
resolved trough the precompiled headers file. If '-fpch-deps' is set, the
dependencies file contains all the dependencies, some of them even several
times! While this is not nice and unnecessarily bloats the dependencies files,
it is at least correct.

Another undocumented pitfall is the fact that the precompiled header file has
to be prepared with '-M' as well in order to make '-fpch-deps' work. This is at
least suggested by the gcc bug
"28483 - Dependency tracking should be on by default when copiling .gchs" [1].
Fortunately, the command line used by the HotSpot build to create the
precompiled headers file already contains these parameters, so we don't have to
do anything in this case.

And there's also another unresolved gcc bug
"14933 - missing pre-compiled header depends with -MD" [2]
which seems to be obsoleted by the '-fpch-deps' option but which I
want to mention here for reference.

Regards,
Volker

[1] http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28483
[2] http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14933

                                    

Comments
EVALUATION

http://hg.openjdk.java.net/hsx/hotspot-rt/hotspot/rev/4d399f013e5a
                                     
2012-06-11
EVALUATION

http://hg.openjdk.java.net/hsx/hotspot-main/hotspot/rev/4d399f013e5a
                                     
2012-06-14
EVALUATION

http://hg.openjdk.java.net/lambda/lambda/hotspot/rev/4d399f013e5a
                                     
2012-06-29



Hardware and Software, Engineered to Work Together