This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: [bug] -MT option and generating dependencies in one compiler pass.
- From: "Manu" <manubee at wanadoo dot fr>
- To: "Neil Booth" <neil at daikokuya dot co dot uk>
- Cc: "mingw-users" <mingw-users at lists dot sourceforge dot net>,<gcc-bugs at gcc dot gnu dot org>
- Date: Fri, 2 May 2003 23:39:26 +0200
- Subject: Re: [bug] -MT option and generating dependencies in one compiler pass.
- References: <007301c310cf$9b5ddb40$88fb0950@tbird1000> <20030502193624.GJ6385@daikokuya.co.uk>
Neil Booth wrote:
> 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.
Ok, I see.
Though, I have the same result with -MQ:
$(OBJDIR)/%.o : %.c
$(COMPILE) -MQ$@ -MMD -MF$(DEPDIR)/$*.Po -c $< -o $@
Result:
../obj/file1.o ../obj/file1.o: file1.c file1.h
OTOH, if I remove -MT or -MQ, it works as expected:
$(OBJDIR)/%.o : %.cpp
$(COMPILE) -MMD -MF$(DEPDIR)/$*.Po -c $< -o $@
Result:
../obj/file2.o: file2.cpp file1.h
So, if I understand well, I must not use -MT / -MQ ?
This confuses me, because the manual says "With `-MT' you can specify a
target yourself, overriding the default one."
Can you confirm that the following is correct:
$(OBJDIR)/%.o : %.cpp
$(COMPILE) -MMD -MF$(DEPDIR)/$*.Po -c $< -o $@
Manu.