This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFC] Replicate src dir in build dir
- From: Tom Tromey <tom at tromey dot com>
- To: Yao Qi <qiyaoltc at gmail dot com>
- Cc: gdb-patches at sourceware dot org
- Date: Sat, 07 Oct 2017 21:24:36 -0600
- Subject: Re: [RFC] Replicate src dir in build dir
- Authentication-results: sourceware.org; auth=none
- References: <1505832159-23038-1-git-send-email-yao.qi@linaro.org>
>>>>> "Yao" == Yao Qi <qiyaoltc@gmail.com> writes:
Yao> This patch takes the first step toward "Replicate src dir in build dir",
Yao> that is, we create arch/ directory in buildtree, and put amd64.o there
Yao> as an example.
I think this is very nice. Thanks for doing it.
But, there are a couple of bugs; one serious, one probably not.
Yao> override COMPILE.post = -c -o $@ -MT $@ -MMD -MP \
Yao> - -MF $(DEPDIR)/$(basename $(@F)).Tpo
Yao> -override POSTCOMPILE = @mv $(DEPDIR)/$(basename $(@F)).Tpo \
Yao> - $(DEPDIR)/$(basename $(@F)).Po
Yao> + -MF $(@D)/$(DEPDIR)/$(@F).Tpo
Yao> +override POSTCOMPILE = @mv $(@D)/$(DEPDIR)/$(@F).Tpo \
Yao> + $(@D)/$(DEPDIR)/$(@F).Po
Yao> else
Yao> override COMPILE.pre = source='$<' object='$@' libtool=no \
Yao> DEPDIR=$(DEPDIR) $(DEPMODE) $(depcomp) $(CC)
This hunk removed the $(basename ...) wrapper. This renames the
dependency files from "basename.Tpo" to "basename.o.Tpo".
However, it didn't change the dependencies include near the end of the
Makefile:
-include $(patsubst %.o, $(DEPDIR)/%.Po, $(all_object_files))
So, because the names differ, automatic dependency tracking no longer
works. I was really puzzled today when my rebuilds were so fast! :-)
I think the correct solution is to add the $(basename ...) back. I
thought at first that the "-include" line could be fixed, but this won't
work in case where "depcomp" is used -- because the name choice also has
to coincide with what depcomp does.
Finally, I think the arch/ change might not work properly with depcomp.
The COMPILE.pre override (quoted in the context of the patch hunk above)
probably needs a tweak to DEPDIR, I would guess DEPDIR=$(@D)/$(DEPDIR).
However, I didn't try this case. (I think when I wrote this I tested
the depcomp case by hacking the generated Makefile to ensure that the
depcomp code was used; otherwise you need a non-capable compiler.)
Tom