From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 27998382CB9A; Wed, 14 Dec 2022 18:01:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 27998382CB9A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1671040887; bh=/vRGZ5zoBFpqJQzwn9lN3g1xT6urnfMQfUd5H4Pwd1s=; h=From:To:Subject:Date:From; b=nZfrNirkhOEmqg2Z6vag6pxgU3v6pk0cbwIcvv3PkSu9gtzCeUdH1fXtU3W+qL85g WPCMB+SRYAexASL0fL7hBfsGdDIHzMkTy5b3+qc/ob7xV01Ac6uBAaZ5ZEKRovg6vr tLFjtM5mK0mAJ+Zt6HuK0zzTV8//0j+Ho2zdz45Q= From: "terra at gnome dot org" To: gcc-bugs@gcc.gnu.org Subject: [Bug other/108108] New: "gcc -MM" fails to list all dependencies Date: Wed, 14 Dec 2022 18:01:21 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: other X-Bugzilla-Version: 12.1.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: terra at gnome dot org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D108108 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=3Dgcc c.o=20 rm b.h echo '#error "this file was changed"' >b.h echo "------Compiling second time:" make CC=3Dgcc c.o=20 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 a= nd 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 expe= ct 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).=