[bug] -MT option and generating dependencies in one compiler pass.

Neil Booth neil@daikokuya.co.uk
Fri May 2 19:44:00 GMT 2003


Manu wrote:-

> A .cpp rule using 1 compiler pass:
> $(OBJDIR)/%.o : %.cpp
> #      $(MAKEDEPEND) $< -MT$@ > $(DEPDIR)/$*.Po
> #      $(COMPILE) -c $< -o $@
>         $(COMPILE) -MT$@ -MMD -MF$(DEPDIR)/$*.Po -c $< -o $@
> 
> 
> It seems to work at first glance:
> Invoking compiler...
> g++ -MM   file1.c -MT../obj/file1.o > _deps/file1.Po
> g++   -W -Wall   -O2 -c file1.c -o ../obj/file1.o
> g++   -W -Wall   -O2 -MT../obj/file2.o -MMD -MF_deps/file2.Po -c file2.cpp -o ../obj/file2.o
> g++  -O2 -s     ../obj/file1.o ../obj/file2.o -o .././new.exe 
> Performed successfully. (434 ms)
> 
> But in fact "src/_deps/file2.Po" is corrupted:
> ../obj/file2.o ../obj/file2.o: file2.cpp file1.h
> ^^^^^^^^^^^^^^^^^^^

-MMD implies an -MQ target.  Since you can specify multiple targets
for the dependency, your -MT is in addition to the implicit target,
and does not replace it.

Neil.



More information about the Gcc-bugs mailing list