[Bug c/14935] New: -MD and -MMD can write to the wrong file
dfries at mail dot win dot org
gcc-bugzilla@gcc.gnu.org
Tue Apr 13 04:25:00 GMT 2004
I debated on submitting this one and came up with a case that might
make an argument for it.
SpacedOut:/tmp/test$ gcc -MMD headers.h
> saves the dependency output to headers.d
SpacedOut:/tmp/test$ gcc -MMD main.c
> saves the dependency output to main.d
> commonly source code will have a common base name for the header and
> source code.
SpacedOut:/tmp/test$ cp headers.h main.h
SpacedOut:/tmp/test$ gcc -MMD main.h
> oops, we just wrote over the dependency file for main.c
-MD -MD is equivalent to -M -MF file, except that -E is
not implied. The driver determines file based on
whether an -o option is given. If it is, the driver
uses its argument but with a suffix of .d, otherwise
it take the basename of the input file and applies a
.d suffix.
Makes it sound to me like these two should save to the same dependency
file, but they don't, headers.d and headers.h.d files.
gcc -MMD headers.h
gcc -MMD headers.h -o headers.h.gch
I'm more looking to start a discussion and have someone determine if
the current behavior is what is wanted or if the pre-compiled headers
need an exception to output to headername.h.d to be consistent with
the output if -o headername.h.gch was given. After all I would expect
to get the same result if you were to specify using -o the same target
as the default target.
I guess the same argument applies for the default executable name,
SpacedOut:/tmp/test$ gcc -MMD main.c
SpacedOut:/tmp/test$ cat main.d
main.o: main.c
SpacedOut:/tmp/test$ gcc -MMD main.c -o a.out
SpacedOut:/tmp/test$ cat a.d
a.out: main.c
They both seem wrong, main.o isn't ever created and a.d seems like the
wrong file to put it, but I'll let someone else make that call.
SpacedOut:/tmp/test$ gcc -v
Reading specs from /home/david/WorkProjects/OpenSceneGraph/DevelGcc/install/lib/gcc/i686-pc-linux-gnu/3.5.0/specs
Configured with: ../gcc_src/configure --enable-languages=c++ --prefix=/home/david/WorkProjects/OpenSceneGraph/DevelGcc/install
--exec-prefix=/home/david/WorkProjects/OpenSceneGraph/DevelGcc/install
Thread model: posix
gcc version 3.5.0 20040412 (experimental)
header.h:
#ifndef _HEADERS_H
#define _HEADERS_H 1
const int value=32;
#endif /* _HEADERS_H */
main.c:
#include "headers.h"
int main(int argc, char ** argv)
{
return value;
}
--
Summary: -MD and -MMD can write to the wrong file
Product: gcc
Version: 3.4.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: dfries at mail dot win dot org
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i386-linux
GCC host triplet: i386-linux
GCC target triplet: i386-linux
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14935
More information about the Gcc-bugs
mailing list