public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "terra at gnome dot org" <gcc-bugzilla@gcc.gnu.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	[thread overview]
Message-ID: <bug-108108-4@http.gcc.gnu.org/bugzilla/> (raw)

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

             reply	other threads:[~2022-12-14 18:01 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-14 18:01 terra at gnome dot org [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-108108-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).