From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 64387 invoked by alias); 19 Sep 2017 20:44:21 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 64371 invoked by uid 89); 19 Sep 2017 20:44:20 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 spammy=i X-HELO: smtp.polymtl.ca Received: from smtp.polymtl.ca (HELO smtp.polymtl.ca) (132.207.4.11) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 19 Sep 2017 20:44:19 +0000 Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id v8JKiCSu018554 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 19 Sep 2017 16:44:16 -0400 Received: by simark.ca (Postfix, from userid 112) id 02F881ED03; Tue, 19 Sep 2017 16:44:12 -0400 (EDT) Received: from simark.ca (localhost [127.0.0.1]) by simark.ca (Postfix) with ESMTP id 88B8C1EA1D; Tue, 19 Sep 2017 16:44:04 -0400 (EDT) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Tue, 19 Sep 2017 20:44:00 -0000 From: Simon Marchi To: Yao Qi Cc: gdb-patches@sourceware.org Subject: Re: [RFC] Replicate src dir in build dir In-Reply-To: <1505832159-23038-1-git-send-email-yao.qi@linaro.org> References: <1505832159-23038-1-git-send-email-yao.qi@linaro.org> Message-ID: X-Sender: simon.marchi@polymtl.ca User-Agent: Roundcube Webmail/1.3.0 X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Tue, 19 Sep 2017 20:44:12 +0000 X-IsSubscribed: yes X-SW-Source: 2017-09/txt/msg00471.txt.bz2 On 2017-09-19 16:42, Yao Qi wrote: > Nowadays, GDB build tree is almost flat, but source tree isn't. We > have arch/ nat/ target/ common/ cli/ mi/ tui/ python/ guile/ > directories. > We need to some rules in Makefile for source files in different source > directories, like, > > # Rules for compiling .c files in the various source subdirectories. > %.o: ${srcdir}/arch/%.c > $(COMPILE) $< > $(POSTCOMPILE) > > %.o: ${srcdir}/nat/%.c > $(COMPILE) $< > $(POSTCOMPILE) > > so we should take care of some special case that files' base name is > the > same, like, > > # Specify an explicit rule for gdb/common/agent.c, to avoid a clash > with the > # object file generate by gdb/agent.c. > common-agent.o: $(srcdir)/common/agent.c > $(COMPILE) $(srcdir)/common/agent.c > $(POSTCOMPILE) > > As we add more and more files in different directories, it becomes > tricky > to name files, because we need take this into account. > > This patch takes the first step toward "Replicate src dir in build > dir", > that is, we create arch/ directory in buildtree, and put amd64.o there > as an example. Dependency tracking is updated for files with directory > name. Currently, when we build amd64.o, > > "-c -o amd64.o -MT amd64.o -MMD -MP -MF .deps/amd64.Tpo" > > with this patch applied, it becomes, > > "-c -o arch/amd64.o -MT arch/amd64.o -MMD -MP -MF > arch/.deps/amd64.o.Tpo" > > "make clean" removes the object files, and "make distclean" removes > .deps > additionally. configure file create .deps directory in each of > CONFIG_SRC_SUBDIR, and pass it to Makefile.in, so that "make clean" and > "make distclean" can remove stuffs there. > > If people agree with this change, I'll add more directories to > CONFIG_SRC_SUBDIR. I want to do the same to GDBserver, but I haven't > looked at GDBserver configure/Makefile yet. Hi Yao, I like the idea. I tried to do that when I cleaned up the Makefiles some time ago, but since it wasn't obvious I let it go. > # This used to depend on c-exp.c m2-exp.c TAGS > # I believe this is wrong; the makefile standards for distclean just > @@ -2317,6 +2322,9 @@ distclean: clean > rm -f config.log config.cache > rm -f Makefile > rm -rf $(DEPDIR) > + @for i in $(CONFIG_SRC_SUBDIR); do \ > + rm -rf $$i/$(DEPDIR); \ > + done I'm always a bit uncomfortable with putting some rm -rf commands in scripts, if we can avoid it. Can we replace that with rmdir, since the clean target should have emptied that directory just before? Also I wouldn't silence the commands (the @), it's always good to be able to read what's being executed. > > maintainer-clean: local-maintainer-clean do-maintainer-clean distclean > realclean: maintainer-clean > @@ -2941,9 +2949,9 @@ ifeq ($(DEPMODE),depmode=gcc3) > # into place if the compile succeeds. We need this because gcc does > # not atomically write the dependency output file. > override COMPILE.post = -c -o $@ -MT $@ -MMD -MP \ > - -MF $(DEPDIR)/$(basename $(@F)).Tpo > -override POSTCOMPILE = @mv $(DEPDIR)/$(basename $(@F)).Tpo \ > - $(DEPDIR)/$(basename $(@F)).Po > + -MF $(@D)/$(DEPDIR)/$(@F).Tpo > +override POSTCOMPILE = @mv $(@D)/$(DEPDIR)/$(@F).Tpo \ > + $(@D)/$(DEPDIR)/$(@F).Po > else > override COMPILE.pre = source='$<' object='$@' libtool=no \ > DEPDIR=$(DEPDIR) $(DEPMODE) $(depcomp) $(CC) I have never tested it, but I assume the "depcomp" mode of dependency management will have to be updated too. Thanks! Simon