public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug preprocessor/14238] New: Dependency tracking and PCH
@ 2004-02-21 17:24 carlo at gcc dot gnu dot org
  2004-02-21 17:25 ` [Bug preprocessor/14238] " carlo at gcc dot gnu dot org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: carlo at gcc dot gnu dot org @ 2004-02-21 17:24 UTC (permalink / raw)
  To: gcc-bugs

As automake generates, the usual way to create
automatic dependencies is by adding something like
-MD -MP -MT a.o -MF a.deps
to the normal compilation line, giving the benefit
of gcc's one-pass compile + make depend.

If we use PCH, one might need a compilation like:

g++ -include pch.h -c a.cc

and thus end up with doing:

g++ -include pch.h -c a.cc -MD -MP -MT a.o -MF a.deps

Often, the PCH (pch.h in this case) contains a LOT of header files,
and we don't want to recompile every compilation unit when we
touch a single header, even when all source files are including
this pch.h.  So, correctly, the dependency tracking is ignoring both
pch.h and whatever it includes.

The real dependency information is therefore gathered from
the #include's inside a.cc.  And here is the problem, when a.cc
does include "a.h", then this is recorded - but when a.h uses the
usual inclusion gard macros, and it is including "a2.h", then we
don't see that back in the output to a.deps!  After all, the pre-
processor thinks that gard macro of a.h is defined (which is the
case because a.h was included before from pch.h) and there does
not process the #include's in a.h for the same of dependency
tracking.

I've included a simple test case that demonstrates this.
Please untar and execute the commands:

make depend-pch
cat a.deps

The output will be:

a.o: a.cc a.h

a.h:

Compare this with:

>make depend-nopch
g++-cvs-3.4 -c a.cc -MD -MP -MT a.o -MF a.deps
g++-cvs-3.4 -c b.cc -MD -MP -MT b.o -MF b.deps

>cat a.deps
a.o: a.cc a.h a2.h

a.h:

a2.h:

-- 
           Summary: Dependency tracking and PCH
           Product: gcc
           Version: 3.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: preprocessor
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: carlo at gcc dot gnu dot org
                CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14238


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug preprocessor/14238] Dependency tracking and PCH
  2004-02-21 17:24 [Bug preprocessor/14238] New: Dependency tracking and PCH carlo at gcc dot gnu dot org
@ 2004-02-21 17:25 ` carlo at gcc dot gnu dot org
  2004-04-13  4:27 ` [Bug pch/14238] " pinskia at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: carlo at gcc dot gnu dot org @ 2004-02-21 17:25 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From carlo at gcc dot gnu dot org  2004-02-21 17:25 -------
Created an attachment (id=5781)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=5781&action=view)
Example case


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14238


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug pch/14238] Dependency tracking and PCH
  2004-02-21 17:24 [Bug preprocessor/14238] New: Dependency tracking and PCH carlo at gcc dot gnu dot org
  2004-02-21 17:25 ` [Bug preprocessor/14238] " carlo at gcc dot gnu dot org
@ 2004-04-13  4:27 ` pinskia at gcc dot gnu dot org
  2004-04-13 18:41 ` geoffk at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-04-13  4:27 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-04-13 04:21 -------
Confirmed, related to bug 14933.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
          Component|preprocessor                |pch
     Ever Confirmed|                            |1
   Last reconfirmed|0000-00-00 00:00:00         |2004-04-13 04:21:24
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14238


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug pch/14238] Dependency tracking and PCH
  2004-02-21 17:24 [Bug preprocessor/14238] New: Dependency tracking and PCH carlo at gcc dot gnu dot org
  2004-02-21 17:25 ` [Bug preprocessor/14238] " carlo at gcc dot gnu dot org
  2004-04-13  4:27 ` [Bug pch/14238] " pinskia at gcc dot gnu dot org
@ 2004-04-13 18:41 ` geoffk at gcc dot gnu dot org
  2004-04-14  0:07 ` carlo at gcc dot gnu dot org
  2004-04-14  8:04 ` geoffk at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: geoffk at gcc dot gnu dot org @ 2004-04-13 18:41 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From geoffk at gcc dot gnu dot org  2004-04-13 18:35 -------
This is correct behaviour.  When the PCH is in use, a2.h is not directly used in the compilation of a.o.  
You could delete a2.h and the compilation would still succeed.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14238


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug pch/14238] Dependency tracking and PCH
  2004-02-21 17:24 [Bug preprocessor/14238] New: Dependency tracking and PCH carlo at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2004-04-13 18:41 ` geoffk at gcc dot gnu dot org
@ 2004-04-14  0:07 ` carlo at gcc dot gnu dot org
  2004-04-14  8:04 ` geoffk at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: carlo at gcc dot gnu dot org @ 2004-04-14  0:07 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From carlo at gcc dot gnu dot org  2004-04-13 23:51 -------
It is not correct behaviour.
If you delete a2.h then the PCH file SHOULD be made
(it depends on a2.h) and would fail.  Deleting it is
no different than changing it.  When you change it,
then you want both, the PCH file to be remade as well
as all compilation units depending on a2.h (not pch.h).

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|INVALID                     |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14238


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug pch/14238] Dependency tracking and PCH
  2004-02-21 17:24 [Bug preprocessor/14238] New: Dependency tracking and PCH carlo at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2004-04-14  0:07 ` carlo at gcc dot gnu dot org
@ 2004-04-14  8:04 ` geoffk at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: geoffk at gcc dot gnu dot org @ 2004-04-14  8:04 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From geoffk at gcc dot gnu dot org  2004-04-14 06:14 -------
> It is not correct behaviour.
> If you delete a2.h then the PCH file SHOULD be made
> (it depends on a2.h) and would fail.  Deleting it is
> no different than changing it.  When you change it,
> then you want both, the PCH file to be remade as well
> as all compilation units depending on a2.h (not pch.h).

Right, but a.o does not directly depend on a2.h.  a.o depends on pch.h.gch which depends on a2.h.

It sounds like what you want is the answer to the question "if the -include was not passed, what would 
the dependencies of a.o be?"  You can get that answer by asking that question: by using

g++-cvs-3.4 -E a.cc -MD -MP -MT a.o -MF a.deps -o /dev/null

Alternatively, you might be wanting the answer to the question "if PCH was not used, what would the 
dependencies of a.o be?"  You can get the answer to that question by using the -fpch-deps flag.

Bug 14933 already covers the problem that pch.h.gch is not mentioned in the dependency list of a.o.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
         Resolution|                            |INVALID


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14238


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2004-04-14  6:14 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-02-21 17:24 [Bug preprocessor/14238] New: Dependency tracking and PCH carlo at gcc dot gnu dot org
2004-02-21 17:25 ` [Bug preprocessor/14238] " carlo at gcc dot gnu dot org
2004-04-13  4:27 ` [Bug pch/14238] " pinskia at gcc dot gnu dot org
2004-04-13 18:41 ` geoffk at gcc dot gnu dot org
2004-04-14  0:07 ` carlo at gcc dot gnu dot org
2004-04-14  8:04 ` geoffk at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).