public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug other/108108] New: "gcc -MM" fails to list all dependencies
@ 2022-12-14 18:01 terra at gnome dot org
  2022-12-14 18:05 ` [Bug preprocessor/108108] " pinskia at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: terra at gnome dot org @ 2022-12-14 18:01 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108108

            Bug ID: 108108
           Summary: "gcc -MM" fails to list all dependencies
           Product: gcc
           Version: 12.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: other
          Assignee: unassigned at gcc dot gnu.org
          Reporter: terra at gnome dot org
  Target Milestone: ---

This is a spin-off from bug 52566


#!/bin/sh

rm -f a.h b.h c.c c.o Makefile
(echo '#pragma once'; echo '// Killroy was here') > a.h
cp -p a.h b.h
# or even "ln a.h b.h"
(echo '#include "a.h"'; echo '#include "b.h"') > c.c
gcc -MM c.c > Makefile
echo "------The Makefile:"
cat Makefile

echo "------Compiling first time:"
make CC=gcc c.o 

rm b.h
echo '#error "this file was changed"' >b.h
echo "------Compiling second time:"
make CC=gcc c.o 


The output I get is

------The Makefile:
c.o: c.c a.h
------Compiling first time:
gcc    -c -o c.o c.c
------Compiling second time:
make: 'c.o' is up to date.


Notice that the second compilation does nothing.  That's quite wrong.  Make has
not been told that c.0 depends on b.h

As seen in bug 52566, this comes down to "#pragma once" deciding that a.h and
b.h are the same file.  One could certainly take that point of view for the
purposes of a single compilation.  I wouldn't, but fine.

However, "gcc -MM" involves the future.  It is not reasonable to assume that
a.h and b.h remain the same file forever.  I think it is reasonable to expect
that any quoted #include string will show up as a dependency with no
de-duplication.


Tested on gcc 7.5.0 (opensuse) and 12.1.0 (self-built).

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

end of thread, other threads:[~2022-12-14 18:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-14 18:01 [Bug other/108108] New: "gcc -MM" fails to list all dependencies terra at gnome dot org
2022-12-14 18:05 ` [Bug preprocessor/108108] " pinskia at gcc dot gnu.org
2022-12-14 18:11 ` pinskia at gcc dot gnu.org
2022-12-14 18:11 ` pinskia at gcc dot gnu.org
2022-12-14 18:40 ` terra at gnome 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).