This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: gcc -E -MD -o behaves differently in 3.0.4 than in 2.95.2.
- From: Neil Booth <neil at daikokuya dot demon dot co dot uk>
- To: Sergei Organov <osv at javad dot ru>
- Cc: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 14 Feb 2002 23:00:39 +0000
- Subject: Re: gcc -E -MD -o behaves differently in 3.0.4 than in 2.95.2.
- References: <87vgd09mb5.fsf@osv.javad.ru>
Sergei Organov wrote:-
> used to send preprocessor output to 'file.out'. With gcc 3.0.4 (from
> anon-cvs) the former command (incorrectly) sends preprocessor output to stdout
> instead (while the latter command still behaves as before). It seems that gcc
> just doesn't pass "-o file.out" to the cpp when both -E and -MD are present. I
> observe the same (presumably incorrect) behavior with gcc 3.0.3 release.
The fundamental problem here is that the meaning of "-o" is overloaded;
it is used for both preprocessor output and object file output. We changed
-MD to be more clever about the specified output object file, and
as a result the driver now interprets the "-o" as indicating compiler
output.
I get a headache thinking about these things; I'm really not sure what
the best thing to do is. We spent a lot of time before 3.0 trying to
get it to do what people wanted, but we have only partly succeeded.
I'm not sure what to do; and so until someone who really wants to get
this done right steps forward to fix it, I suspect it will remain as it
is. Note that the current code can do everything (and a lot more) it
could do before, it's just that we lost backwards compatibility more
than we intended too. You can control dependency output finely with
-MF, -MQ, -MT and -MP with 3.x; all these options are new.
> /home/osv/try/lib/gcc-lib/i686-pc-linux-gnu/3.0.4/cpp0 -lang-c -v -M -MF file.d -MQ file.out -D__GNUC__=3 -D__GNUC_MINOR__=0 -D__GNUC_PATCHLEVEL__=4 -D__ELF__ -Dunix -Dlinux -D__ELF__ -D__unix__ -D__linux__ -D__unix -D__linux -Asystem=posix -D__NO_INLINE__ -D__STDC_HOSTED__=1 -Acpu=i386 -Amachine=i386 -Di386 -D__i386 -D__i386__ -D__tune_i686__ -D__tune_pentiumpro__ file.c
Here you see the driver has passed "-MQ file.out" to the preprocessor,
which tells it to interpret it as the (quoted) target of the dependency.
You can also see "-MF file.d" which is the file that contains the
dependency output.
Now that we have a released version with the new semantics, I think it's
simplest if we retain them, in that -MD is understood to be added to the
normal compiler "-c" command line, so that any "-o" options indicate the
output object file. If you want to change the dependency output file,
you can additionally -MF on the command line (note that this option was
new to 3.x), which will override the default output file.
Neil.