From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 122815 invoked by alias); 20 Sep 2017 11:26:39 -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 122771 invoked by uid 89); 20 Sep 2017 11:26:38 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.9 required=5.0 tests=BAYES_00,GIT_PATCH_2,GIT_PATCH_3,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=itd, it'd, this! X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 20 Sep 2017 11:26:36 +0000 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id ABC355F723; Wed, 20 Sep 2017 11:26:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com ABC355F723 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=palves@redhat.com Received: from [127.0.0.1] (ovpn04.gateway.prod.ext.ams2.redhat.com [10.39.146.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id D253A5D6A4; Wed, 20 Sep 2017 11:26:34 +0000 (UTC) Subject: Re: [RFC] Replicate src dir in build dir To: Yao Qi , gdb-patches@sourceware.org References: <1505832159-23038-1-git-send-email-yao.qi@linaro.org> From: Pedro Alves Message-ID: <0aca31f3-4604-5630-baba-0584bb9d5c65@redhat.com> Date: Wed, 20 Sep 2017 11:26:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <1505832159-23038-1-git-send-email-yao.qi@linaro.org> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-SW-Source: 2017-09/txt/msg00481.txt.bz2 On 09/19/2017 03:42 PM, 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. For the record [since you already know this], I agree with the direction. Thanks for doing this! > @@ -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 agree with Simon; "rm -rf" is scary. > +# Create sub-directories for objects and depedencies. Typo: "depedencies" -> "dependencies". Appears several times. > --- a/gdb/configure.tgt > +++ b/gdb/configure.tgt > @@ -194,7 +194,7 @@ i[34567]86-*-darwin*) > i386-darwin-tdep.o solib-darwin.o" > if test "x$enable_64_bit_bfd" = "xyes"; then > # Target: GNU/Linux x86-64 > - gdb_target_obs="amd64-tdep.o amd64.o amd64-darwin-tdep.o ${gdb_target_obs}" > + gdb_target_obs="amd64-tdep.o arch/amd64.o amd64-darwin-tdep.o ${gdb_target_obs}" > fi > ;; > i[34567]86-*-dicos*) > @@ -225,7 +225,7 @@ i[34567]86-*-nto*) > ;; > i[34567]86-*-solaris2.1[0-9]* | x86_64-*-solaris2.1[0-9]*) > # Target: Solaris x86_64 > - gdb_target_obs="i386-tdep.o i386.o i387-tdep.o amd64-tdep.o amd64.o \ > + gdb_target_obs="i386-tdep.o i386.o i387-tdep.o amd64-tdep.o arch/amd64.o \ > amd64-sol2-tdep.o i386-sol2-tdep.o sol2-tdep.o \ > solib-svr4.o" We've had to touch these lists several times recently to add some object to a bunch of triplets. It'd be nice to move the common CPU-specific files to variables shared by the different OS triplets, so that we'd have simple places to edit them. Similar to srv_i386_linux_regobj etc. in gdbserver/configure.srv. Like e.g.: + i386_tobjs="i386-tdep.o i386.o i387-tdep.o" + amd64_tobjs="${i386_tobjs} amd64-tdep.o arch/amd64.o" And then use these variables throughout, like: x86_64-*-netbsd* | x86_64-*-knetbsd*-gnu) # Target: NetBSD/amd64 - gdb_target_obs="amd64-tdep.o amd64.o amd64-nbsd-tdep.o i386-tdep.o \ - i386.o i387-tdep.o nbsd-tdep.o solib-svr4.o" + gdb_target_obs="${amd64_tobjs} amd64-nbsd-tdep.o nbsd-tdep.o solib-svr4.o" Etc. Thanks, Pedro Alves