This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

preprocessor/3872: gcc -M... ignores "-o"



>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:


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]