public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: D.Yu.Bolkhovityanov@inp.nsk.su
To: gcc-gnats@gcc.gnu.org
Subject: preprocessor/3872: gcc -M... ignores "-o"
Date: Mon, 30 Jul 2001 00:36:00 -0000	[thread overview]
Message-ID: <20010730072935.2959.qmail@sourceware.cygnus.com> (raw)

>Number:         3872
>Category:       preprocessor
>Synopsis:       gcc -M... ignores "-o"
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Jul 30 00:36:00 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     D.Yu.Bolkhovityanov@inp.nsk.su
>Release:        gcc version 2.96 20000731 (Red Hat Linux 7.1 2.96-85)
>Organization:
>Environment:

>Description:
When gcc is ran with a following command line

gcc -M sourcefile.c -o depfile.dep

it prints a list of dependencies to stdout instead of "depfile.dep" (any "-M..." option may be used instead of just "-M" -- e.g. "-MM"). 

What it uses "-o" for is a filename before ":" in depfile -- i.e. there will be "depfile.dep: ..." instead of "sourcefile.o: ...".

In earlier versions (since ancient and at least up to egcs-2.91) this worked as expected.  Such a behaviour seems even more strange if taking into account a note in ChangeLog.CPP for 2001-01-08: "If -o given, use it as the target of any -M options" (or is *that* a cause of the bug?)

Sure, one can use ">depfile.dep" instead, but that's not a good idea, and I'll try to explain why.

When "gcc -M ..." is run from Makefile, and when cpp encounters an error (e.g. missing file in #include), in case of working "-o depfile.dep" it wouldn't touch depfile.dep, while in case of ">depfile.dep" the timestamp on the latter will become more recent than that of "sourcefile.c", and hence the immediately repeated "make" will "succeed" (since it wouldn't run "gcc -M..." at all).  Of course, the subsequent "gcc" w/o "-M" will fail, but such behaviour is undesired anyway.
>How-To-Repeat:
Issue the following commands:

echo "#include <stdio.h>" >sourcefile.c
gcc -E -M sourcefile.c -o depfile.dep

and you'll get a text describing "depfile.dep" (!!!) dependant on many system headers.  The "depfile.dep" isn't created as it should.
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


             reply	other threads:[~2001-07-30  0:36 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-07-30  0:36 D.Yu.Bolkhovityanov [this message]
2001-07-30  0:48 neil
2002-03-15  3:28 neil

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=20010730072935.2959.qmail@sourceware.cygnus.com \
    --to=d.yu.bolkhovityanov@inp.nsk.su \
    --cc=gcc-gnats@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).