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).