Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: Yao Qi <qiyaoltc@gmail.com>, gdb-patches@sourceware.org
Subject: Re: [RFC] Replicate src dir in build dir
Date: Wed, 20 Sep 2017 11:26:00 -0000	[thread overview]
Message-ID: <0aca31f3-4604-5630-baba-0584bb9d5c65@redhat.com> (raw)
In-Reply-To: <1505832159-23038-1-git-send-email-yao.qi@linaro.org>

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


  parent reply	other threads:[~2017-09-20 11:26 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-19 14:42 Yao Qi
2017-09-19 20:44 ` Simon Marchi
2017-09-20  8:04   ` Yao Qi
2017-09-20  8:17     ` Simon Marchi
2017-09-20 14:26       ` Yao Qi
2017-09-20 11:26 ` Pedro Alves [this message]
2017-09-20 16:49   ` Yao Qi
2017-09-20 17:45     ` Pedro Alves
2017-09-29 19:23       ` Yao Qi
2017-10-03 20:02         ` Pedro Alves
2017-10-03 20:14           ` Kamil Rytarowski
2017-10-03 22:04             ` Pedro Alves
2017-10-04  9:46               ` Kamil Rytarowski
2017-10-06  9:29               ` Yao Qi
2017-10-04 11:41           ` Pedro Alves
2017-10-06 10:21           ` Yao Qi
2017-10-08  3:24 ` Tom Tromey
2017-10-08 21:04   ` Yao Qi
2017-10-11  1:25   ` Yao Qi
2017-10-11  3:26     ` Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0aca31f3-4604-5630-baba-0584bb9d5c65@redhat.com \
    --to=palves@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=qiyaoltc@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox