public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [RFC] Replicate src dir in build dir
@ 2017-09-19 14:42 Yao Qi
  2017-09-19 20:44 ` Simon Marchi
                   ` (2 more replies)
  0 siblings, 3 replies; 20+ messages in thread
From: Yao Qi @ 2017-09-19 14:42 UTC (permalink / raw)
  To: gdb-patches

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.

gdb:

2017-09-19  Yao Qi  <yao.qi@linaro.org>

	* Makefile.in (CONFIG_SRC_SUBDIR): New.
	(ALL_64_TARGET_OBS): Replace amd64.o with arch/amd64.o.
	(clean): Remove object files and dependency files.
	(distclean): Remove the directory.
	* configure.ac: Invoke AC_CONFIG_COMMANDS.
	* configure: Re-generated.
	* configure.tgt: Replace amd64.o with arch/amd64.o.
---
 gdb/Makefile.in   | 16 ++++++++++++----
 gdb/configure     | 15 +++++++++++++++
 gdb/configure.ac  | 11 +++++++++++
 gdb/configure.tgt | 24 ++++++++++++------------
 4 files changed, 50 insertions(+), 16 deletions(-)

diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index 1438f20..a660a27 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -632,6 +632,7 @@ CONFIG_ALL = @CONFIG_ALL@
 CONFIG_CLEAN = @CONFIG_CLEAN@
 CONFIG_INSTALL = @CONFIG_INSTALL@
 CONFIG_UNINSTALL = @CONFIG_UNINSTALL@
+CONFIG_SRC_SUBDIR = @CONFIG_SRC_SUBDIR@
 HAVE_NATIVE_GCORE_TARGET = @HAVE_NATIVE_GCORE_TARGET@
 
 # -I. for config files.
@@ -767,7 +768,6 @@ ALL_64_TARGET_OBS = \
 	alpha-nbsd-tdep.o \
 	alpha-obsd-tdep.o \
 	alpha-tdep.o \
-	amd64.o \
 	amd64-darwin-tdep.o \
 	amd64-dicos-tdep.o \
 	amd64-fbsd-tdep.o \
@@ -777,6 +777,7 @@ ALL_64_TARGET_OBS = \
 	amd64-sol2-tdep.o \
 	amd64-tdep.o \
 	amd64-windows-tdep.o \
+	arch/amd64.o \
 	ia64-linux-tdep.o \
 	ia64-tdep.o \
 	ia64-vms-tdep.o \
@@ -2299,6 +2300,10 @@ clean mostlyclean: $(CONFIG_CLEAN)
 	rm -f test-cp-name-parser$(EXEEXT)
 	rm -f xml-builtin.c stamp-xml
 	rm -f $(DEPDIR)/*
+	@for i in $(CONFIG_SRC_SUBDIR); do \
+		rm -f $$i/*.o;	\
+		rm -f $$i/$(DEPDIR)/*; \
+	done
 
 # 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
 
 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)
diff --git a/gdb/configure b/gdb/configure
index c7746fc..41b884b 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -733,6 +733,7 @@ LIBINTL_DEP
 LIBINTL
 USE_NLS
 CCDEPMODE
+CONFIG_SRC_SUBDIR
 DEPDIR
 am__leading_dot
 CXX_DIALECT
@@ -5949,6 +5950,13 @@ DEPDIR="${am__leading_dot}deps"
 ac_config_commands="$ac_config_commands depdir"
 
 
+# Create sub-directories for objects and depedencies.
+CONFIG_SRC_SUBDIR="arch"
+
+
+ac_config_commands="$ac_config_commands gdbdepdir"
+
+
 depcc="$CC"   am_compiler_list=
 
 am_depcomp=$ac_aux_dir/depcomp
@@ -18171,6 +18179,7 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 # INIT-COMMANDS
 #
 ac_aux_dir=$ac_aux_dir DEPDIR=$DEPDIR
+ac_aux_dir=$ac_aux_dir DEPDIR=$DEPDIR CONFIG_SRC_SUBDIR="$CONFIG_SRC_SUBDIR"
 
 _ACEOF
 
@@ -18182,6 +18191,7 @@ do
   case $ac_config_target in
     "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h:config.in" ;;
     "depdir") CONFIG_COMMANDS="$CONFIG_COMMANDS depdir" ;;
+    "gdbdepdir") CONFIG_COMMANDS="$CONFIG_COMMANDS gdbdepdir" ;;
     "jit-reader.h") CONFIG_FILES="$CONFIG_FILES jit-reader.h:jit-reader.in" ;;
     "$ac_config_links_1") CONFIG_LINKS="$CONFIG_LINKS $ac_config_links_1" ;;
     "gcore") CONFIG_FILES="$CONFIG_FILES gcore" ;;
@@ -18805,6 +18815,11 @@ $as_echo "$as_me: executing $ac_file commands" >&6;}
 
   case $ac_file$ac_mode in
     "depdir":C) $SHELL $ac_aux_dir/mkinstalldirs $DEPDIR ;;
+    "gdbdepdir":C)
+  for subdir in ${CONFIG_SRC_SUBDIR}
+  do
+      $SHELL $ac_aux_dir/mkinstalldirs $subdir/$DEPDIR
+  done ;;
     "gcore":F) chmod +x gcore ;;
     "Makefile":F)
 case x$CONFIG_HEADERS in
diff --git a/gdb/configure.ac b/gdb/configure.ac
index b4d7a87..081c4c9 100644
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -44,6 +44,17 @@ AX_CXX_COMPILE_STDCXX(11, , mandatory)
 
 # Dependency checking.
 ZW_CREATE_DEPDIR
+# Create sub-directories for objects and depedencies.
+CONFIG_SRC_SUBDIR="arch"
+AC_SUBST(CONFIG_SRC_SUBDIR)
+
+AC_CONFIG_COMMANDS([gdbdepdir],[
+  for subdir in ${CONFIG_SRC_SUBDIR}
+  do
+      $SHELL $ac_aux_dir/mkinstalldirs $subdir/$DEPDIR
+  done],
+  [ac_aux_dir=$ac_aux_dir DEPDIR=$DEPDIR CONFIG_SRC_SUBDIR="$CONFIG_SRC_SUBDIR"])
+
 ZW_PROG_COMPILER_DEPENDENCIES([CC])
 
 gnulib_extra_configure_args=
diff --git a/gdb/configure.tgt b/gdb/configure.tgt
index 321a739..a7d89c7 100644
--- 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"
 	;;
@@ -242,7 +242,7 @@ i[34567]86-*-linux*)
 			linux-tdep.o linux-record.o"
 	if test "x$enable_64_bit_bfd" = "xyes"; then
 	    # Target: GNU/Linux x86-64
-	    gdb_target_obs="amd64-tdep.o amd64.o amd64-linux-tdep.o ${gdb_target_obs}"
+	    gdb_target_obs="amd64-tdep.o arch/amd64.o amd64-linux-tdep.o ${gdb_target_obs}"
 	fi
 	build_gdbserver=yes
 	;;
@@ -671,52 +671,52 @@ vax-*-*)
 
 x86_64-*-darwin*)
 	# Target: Darwin/x86-64
-	gdb_target_obs="amd64-tdep.o amd64.o i386-tdep.o i386.o i387-tdep.o \
+	gdb_target_obs="amd64-tdep.o arch/amd64.o i386-tdep.o i386.o i387-tdep.o \
 			i386-darwin-tdep.o amd64-darwin-tdep.o \
                         solib-darwin.o"
 	;;
 
 x86_64-*-dicos*)
 	# Target: DICOS/x86-64
-	gdb_target_obs="amd64-tdep.o amd64.o i386-tdep.o i386.o i387-tdep.o \
+	gdb_target_obs="amd64-tdep.o arch/amd64.o i386-tdep.o i386.o i387-tdep.o \
 			dicos-tdep.o i386-dicos-tdep.o amd64-dicos-tdep.o"
 	;;
 x86_64-*-elf*)
-	gdb_target_obs="amd64-tdep.o amd64.o i386-tdep.o i386.o i387-tdep.o"
+	gdb_target_obs="amd64-tdep.o arch/amd64.o i386-tdep.o i386.o i387-tdep.o"
 	;;
 x86_64-*-linux*)
 	# Target: GNU/Linux x86-64
-	gdb_target_obs="amd64-tdep.o amd64-linux-tdep.o amd64.o i386-tdep.o \
+	gdb_target_obs="amd64-tdep.o amd64-linux-tdep.o arch/amd64.o i386-tdep.o \
 			i387-tdep.o i386.o i386-linux-tdep.o glibc-tdep.o \
 			solib-svr4.o symfile-mem.o linux-tdep.o linux-record.o"
 	build_gdbserver=yes
 	;;
 x86_64-*-freebsd* | x86_64-*-kfreebsd*-gnu)
 	# Target: FreeBSD/amd64
-	gdb_target_obs="amd64-tdep.o amd64.o amd64-fbsd-tdep.o i386-tdep.o \
+	gdb_target_obs="amd64-tdep.o arch/amd64.o amd64-fbsd-tdep.o i386-tdep.o \
 			i386.o i387-tdep.o i386-bsd-tdep.o i386-fbsd-tdep.o \
 			fbsd-tdep.o solib-svr4.o"
 	;;
 x86_64-*-mingw* | x86_64-*-cygwin*)
         # Target: MingW/amd64
-	gdb_target_obs="amd64-tdep.o amd64.o amd64-windows-tdep.o \
+	gdb_target_obs="amd64-tdep.o arch/amd64.o amd64-windows-tdep.o \
                         i386-tdep.o i386.o i386-cygwin-tdep.o i387-tdep.o \
                         windows-tdep.o"
 	build_gdbserver=yes
         ;;
 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 \
+	gdb_target_obs="amd64-tdep.o arch/amd64.o amd64-nbsd-tdep.o i386-tdep.o \
 			i386.o i387-tdep.o nbsd-tdep.o solib-svr4.o"
 	;;
 x86_64-*-openbsd*)
 	# Target: OpenBSD/amd64
-	gdb_target_obs="amd64-tdep.o amd64.o amd64-obsd-tdep.o i386-tdep.o \
+	gdb_target_obs="amd64-tdep.o arch/amd64.o amd64-obsd-tdep.o i386-tdep.o \
 			i387-tdep.o i386-bsd-tdep.o i386-obsd-tdep.o \
 			i386.o obsd-tdep.o bsd-uthread.o solib-svr4.o"
 	;;
 x86_64-*-rtems*)
-	gdb_target_obs="amd64-tdep.o amd64.o i386-tdep.o i386.o i387-tdep.o \
+	gdb_target_obs="amd64-tdep.o arch/amd64.o i386-tdep.o i386.o i387-tdep.o \
 			i386-bsd-tdep.o"
 	;;
 xtensa*-*-linux*)	gdb_target=linux
-- 
1.9.1

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [RFC] Replicate src dir in build dir
  2017-09-19 14:42 [RFC] Replicate src dir in build dir Yao Qi
@ 2017-09-19 20:44 ` Simon Marchi
  2017-09-20  8:04   ` Yao Qi
  2017-09-20 11:26 ` Pedro Alves
  2017-10-08  3:24 ` Tom Tromey
  2 siblings, 1 reply; 20+ messages in thread
From: Simon Marchi @ 2017-09-19 20:44 UTC (permalink / raw)
  To: Yao Qi; +Cc: gdb-patches

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

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [RFC] Replicate src dir in build dir
  2017-09-19 20:44 ` Simon Marchi
@ 2017-09-20  8:04   ` Yao Qi
  2017-09-20  8:17     ` Simon Marchi
  0 siblings, 1 reply; 20+ messages in thread
From: Yao Qi @ 2017-09-20  8:04 UTC (permalink / raw)
  To: Simon Marchi; +Cc: gdb-patches

Simon Marchi <simon.marchi@polymtl.ca> writes:

> 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.
>

OK, I'll change to rmdir and remove @.

>>
>>  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.

I don't understand this comment.  The only change in on dependency
tracking is that .Po file is moved to a new place (.deps/amd64.Po ->
./arch/.deps/amd64.o.Po).  The file contents don't change.

$ diff -u .deps/amd64.Po ./arch/.deps/amd64.o.Po 
--- .deps/amd64.Po	2017-09-20 07:57:04.903381133 +0000
+++ ./arch/.deps/amd64.o.Po	2017-09-20 07:40:35.995718460 +0000
@@ -1,4 +1,4 @@
-amd64.o: ../../binutils-gdb/gdb/arch/amd64.c \
+arch/amd64.o: ../../binutils-gdb/gdb/arch/amd64.c \
  ../../binutils-gdb/gdb/arch/amd64.h ../../binutils-gdb/gdb/arch/tdesc.h \
  build-gnulib/import/stdint.h ../../binutils-gdb/gdb/common/x86-xstate.h \
  build-gnulib/import/stdlib.h \

-- 
Yao (齐尧)

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [RFC] Replicate src dir in build dir
  2017-09-20  8:04   ` Yao Qi
@ 2017-09-20  8:17     ` Simon Marchi
  2017-09-20 14:26       ` Yao Qi
  0 siblings, 1 reply; 20+ messages in thread
From: Simon Marchi @ 2017-09-20  8:17 UTC (permalink / raw)
  To: Yao Qi; +Cc: gdb-patches

On 2017-09-20 10:02, Yao Qi wrote:
>>> @@ -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.
> 
> I don't understand this comment.  The only change in on dependency
> tracking is that .Po file is moved to a new place (.deps/amd64.Po ->
> ./arch/.deps/amd64.o.Po).  The file contents don't change.
> 
> $ diff -u .deps/amd64.Po ./arch/.deps/amd64.o.Po
> --- .deps/amd64.Po	2017-09-20 07:57:04.903381133 +0000
> +++ ./arch/.deps/amd64.o.Po	2017-09-20 07:40:35.995718460 +0000
> @@ -1,4 +1,4 @@
> -amd64.o: ../../binutils-gdb/gdb/arch/amd64.c \
> +arch/amd64.o: ../../binutils-gdb/gdb/arch/amd64.c \
>   ../../binutils-gdb/gdb/arch/amd64.h 
> ../../binutils-gdb/gdb/arch/tdesc.h \
>   build-gnulib/import/stdint.h 
> ../../binutils-gdb/gdb/common/x86-xstate.h \
>   build-gnulib/import/stdlib.h \

I was wondering if this line needed changing

override COMPILE.pre = source='$<' object='$@' libtool=no \
	DEPDIR=$(DEPDIR) $(DEPMODE) $(depcomp) $(CC)

In particular, is DEPDIR treated as relative to the created object file 
or relative to the current working directory by depcomp.  I honestly 
don't even know when this actually used.

Simon

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [RFC] Replicate src dir in build dir
  2017-09-19 14:42 [RFC] Replicate src dir in build dir Yao Qi
  2017-09-19 20:44 ` Simon Marchi
@ 2017-09-20 11:26 ` Pedro Alves
  2017-09-20 16:49   ` Yao Qi
  2017-10-08  3:24 ` Tom Tromey
  2 siblings, 1 reply; 20+ messages in thread
From: Pedro Alves @ 2017-09-20 11:26 UTC (permalink / raw)
  To: Yao Qi, gdb-patches

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

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [RFC] Replicate src dir in build dir
  2017-09-20  8:17     ` Simon Marchi
@ 2017-09-20 14:26       ` Yao Qi
  0 siblings, 0 replies; 20+ messages in thread
From: Yao Qi @ 2017-09-20 14:26 UTC (permalink / raw)
  To: Simon Marchi; +Cc: gdb-patches

Simon Marchi <simon.marchi@polymtl.ca> writes:

> I was wondering if this line needed changing
>
> override COMPILE.pre = source='$<' object='$@' libtool=no \
> 	DEPDIR=$(DEPDIR) $(DEPMODE) $(depcomp) $(CC)
>
> In particular, is DEPDIR treated as relative to the created object
> file or relative to the current working directory by depcomp.  I
> honestly don't even know when this actually used.

depcomp has already taken care of it,

# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.

I hack Makefile, to set "depmode=gcc",

# Dependency tracking information.
DEPMODE = depmode=gcc

and "make arch/amd64.o",

source='../../binutils-gdb/gdb/arch/amd64.c' object='arch/amd64.o' libtool=no DEPDIR=.deps depmode=gcc /bin/bash ../../binutils-gdb/gdb/../depcomp g++ -x c++ -std=gnu++11 -g -O2   -I. -I../../binutils-gdb/gdb -I../../binutils-gdb/gdb/common -I../../binutils-gdb/gdb/config -DLOCALEDIR="\"/usr/local/share/locale\"" -DHAVE_CONFIG_H -I../../binutils-gdb/gdb/../include/opcode -I../../binutils-gdb/gdb/../opcodes/.. -I../../binutils-gdb/gdb/../readline/.. -I../../binutils-gdb/gdb/../zlib -I../bfd -I../../binutils-gdb/gdb/../bfd -I../../binutils-gdb/gdb/../include -I../libdecnumber -I../../binutils-gdb/gdb/../libdecnumber  -I../../binutils-gdb/gdb/gnulib/import -Ibuild-gnulib/import   -DTUI=1   -pthread -I/usr/include/guile/2.0 -I/usr/include/python2.7 -I/usr/include/python2.7 -Wall -Wpointer-arith -Wno-unused -Wunused-value -Wunused-function -Wno-switch -Wno-char-subscripts -Wempty-body -Wunused-but-set-parameter -Wunused-but-set-variable -Wno-sign-compare -Wno-narrowing -Wno-error=maybe-uninitialized -Wformat-nonliteral -Werror -c -o arch/amd64.o ../../binutils-gdb/gdb/arch/amd64.c

and the dependency file is generated in arch/.deps/amd64.Po, which looks
right to me.

-- 
Yao (齐尧)

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [RFC] Replicate src dir in build dir
  2017-09-20 11:26 ` Pedro Alves
@ 2017-09-20 16:49   ` Yao Qi
  2017-09-20 17:45     ` Pedro Alves
  0 siblings, 1 reply; 20+ messages in thread
From: Yao Qi @ 2017-09-20 16:49 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches

Pedro Alves <palves@redhat.com> writes:

> 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.

This is about common CPU-specific files shared by different triplets.
This makes think a little bit further, how do we handle common
OS-specific files shared by different triplets?  We can match triplet
CPU part and OS part respectively, and append the right objects to
gdb_target_obs, like this,

i386_tobjs="i386-tdep.o i386.o i387-tdep.o"
amd64_tobjs="amd64-tdep.o arch/amd64.o"
gdb_target_obs=""

# Fill in gdb_target_obs according to CPU.

case "${targ}" in
aarch64*-*-*)
        gdb_target_obs="aarch64-tdep.o aarch64-insn.o ${gdb_target_obs}";;
arm*-*-*)
        gdb_target_obs="arm.o arm-get-next-pcs.o arm-tdep.o ${gdb_target_obs}";;
i[34567]86-*-*)
        gdb_target_obs="${i386_tobjs} ${gdb_target_obs}";;
	if test "x$enable_64_bit_bfd" = "xyes"; then
	    gdb_target_obs="${amd64_tobjs} ${gdb_target_obs}"
	fi
sparc-*-*)
        gdb_target_obs="sparc-tdep.o ravenscar-thread.o sparc-ravenscar-thread.o ${gdb_target_obs}";;

sparc64-*-*)
        gdb_target_obs="sparc-tdep.o sparc64-tdep.o ravenscar-thread.o sparc-ravenscar-thread.o ${gdb_target_obs}";;

x86_64-*-*)
        gdb_target_obs="${i386_tobjs} ${amd64_tobjs} ${gdb_target_obs}";;
esac

# Fill in gdb_target_obs according to OS.

case "${targ}" in
*-*-freebsd*)
        gdb_target_obs="fbsd-tdep.o solib-svr4.o ${gdb_target_obs}";;
*-*-netbsd*)
        gdb_target_obs="nbsd-tdep.o solib-svr4.o ${gdb_target_obs}";;
*-*-openbsd*)
        gdb_target_obs="obsd-tdep.o solib-svr4.o ${gdb_target_obs}";;
esac

# Fill in the rest according to the triplet.
...

What do you think?

>
> 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"

-- 
Yao (齐尧)

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [RFC] Replicate src dir in build dir
  2017-09-20 16:49   ` Yao Qi
@ 2017-09-20 17:45     ` Pedro Alves
  2017-09-29 19:23       ` Yao Qi
  0 siblings, 1 reply; 20+ messages in thread
From: Pedro Alves @ 2017-09-20 17:45 UTC (permalink / raw)
  To: Yao Qi; +Cc: gdb-patches

On 09/20/2017 05:49 PM, Yao Qi wrote:
> Pedro Alves <palves@redhat.com> writes:
> 
>> 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.
> 
> This is about common CPU-specific files shared by different triplets.
> This makes think a little bit further, how do we handle common
> OS-specific files shared by different triplets?  We can match triplet
> CPU part and OS part respectively, and append the right objects to
> gdb_target_obs, like this,
> 
> i386_tobjs="i386-tdep.o i386.o i387-tdep.o"
> amd64_tobjs="amd64-tdep.o arch/amd64.o"
> gdb_target_obs=""
> 
> # Fill in gdb_target_obs according to CPU.
> 
> case "${targ}" in
> aarch64*-*-*)
>         gdb_target_obs="aarch64-tdep.o aarch64-insn.o ${gdb_target_obs}";;
> arm*-*-*)
>         gdb_target_obs="arm.o arm-get-next-pcs.o arm-tdep.o ${gdb_target_obs}";;
> i[34567]86-*-*)
>         gdb_target_obs="${i386_tobjs} ${gdb_target_obs}";;
> 	if test "x$enable_64_bit_bfd" = "xyes"; then
> 	    gdb_target_obs="${amd64_tobjs} ${gdb_target_obs}"
> 	fi
> sparc-*-*)
>         gdb_target_obs="sparc-tdep.o ravenscar-thread.o sparc-ravenscar-thread.o ${gdb_target_obs}";;
> 
> sparc64-*-*)
>         gdb_target_obs="sparc-tdep.o sparc64-tdep.o ravenscar-thread.o sparc-ravenscar-thread.o ${gdb_target_obs}";;
> 
> x86_64-*-*)
>         gdb_target_obs="${i386_tobjs} ${amd64_tobjs} ${gdb_target_obs}";;
> esac
> 
> # Fill in gdb_target_obs according to OS.
> 
> case "${targ}" in
> *-*-freebsd*)
>         gdb_target_obs="fbsd-tdep.o solib-svr4.o ${gdb_target_obs}";;
> *-*-netbsd*)
>         gdb_target_obs="nbsd-tdep.o solib-svr4.o ${gdb_target_obs}";;
> *-*-openbsd*)
>         gdb_target_obs="obsd-tdep.o solib-svr4.o ${gdb_target_obs}";;
> esac
> 
> # Fill in the rest according to the triplet.
> ...
> 
> What do you think?

Yes, that works for me too.

Meeting in the middle, using separate variables for arch and OS
objects would allow getting rid of the need for spelling out
gdb_target_obs twice per line, like:

 case "${targ}" in
 aarch64*-*-*)
         cpu_obs="aarch64-tdep.o aarch64-insn.o";;
 arm*-*-*)
         cpu_obs="arm.o arm-get-next-pcs.o arm-tdep.o";;
 esac

 case "${targ}" in
 *-*-freebsd*)
         os_obs="fbsd-tdep.o solib-svr4.o";;
 *-*-netbsd*)
         os_obs="nbsd-tdep.o solib-svr4.o";;
 *-*-openbsd*)
         os_obs="obsd-tdep.o solib-svr4.o";;
 esac
 
 gdb_target_obs="${cpu_obs} ${os_obs}"

Thanks,
Pedro Alves

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [RFC] Replicate src dir in build dir
  2017-09-20 17:45     ` Pedro Alves
@ 2017-09-29 19:23       ` Yao Qi
  2017-10-03 20:02         ` Pedro Alves
  0 siblings, 1 reply; 20+ messages in thread
From: Yao Qi @ 2017-09-29 19:23 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches

Pedro Alves <palves@redhat.com> writes:

> Meeting in the middle, using separate variables for arch and OS
> objects would allow getting rid of the need for spelling out
> gdb_target_obs twice per line, like:
>
>  case "${targ}" in
>  aarch64*-*-*)
>          cpu_obs="aarch64-tdep.o aarch64-insn.o";;
>  arm*-*-*)
>          cpu_obs="arm.o arm-get-next-pcs.o arm-tdep.o";;
>  esac
>
>  case "${targ}" in
>  *-*-freebsd*)
>          os_obs="fbsd-tdep.o solib-svr4.o";;
>  *-*-netbsd*)
>          os_obs="nbsd-tdep.o solib-svr4.o";;
>  *-*-openbsd*)
>          os_obs="obsd-tdep.o solib-svr4.o";;
>  esac
>  
>  gdb_target_obs="${cpu_obs} ${os_obs}"

Sorry for the delayed response, still in travel.  How about the patch
below?  This patch applied on top of my "Replicate src dir in build dir" patch.

-- 
Yao (齐尧)
From 9a3fcb10a05fd9bd3dacabf3b718eda09d8bd3ba Mon Sep 17 00:00:00 2001
From: Yao Qi <yao.qi@linaro.org>
Date: Wed, 20 Sep 2017 18:02:51 +0100
Subject: [PATCH] Share code updating gdb_target_obs

Nowadays, there are much duplications in configure.tgt to update
gdb_target_obs, some cpu specific object files are added to gdb_target_obs
to some different target triplets of the same cpu.  The same problem
exists for os specific object files too.  It is fragile to update them,
and build with all targets enabled doesn't find the problem.

This patch splits the gdb_target_obs update to three steps, cpu steps, os
steps, and the rest.

I tested this patch by build gdb for each different target triplets
respectively,

aarch64-elf aarch64-rtems aarch64-freebsd aarch64-linux alpha-elf
alpha-linux alpha-netbsd alpha-openbsd arm-elf arm-wince-pe arm-linux
arm-netbsd arm-symbianelf avr cris-elf frv-elf h8300-elf i386-elf
i386-darwin i386-dicos i386-freebsd i386-netbsdelf i386-openbsd
i386-nto i386-solaris i386-linux i386-gnu i386-cygwin i386-mingw32
i386-go32 ia64-linux-gnu ia64-vms lm32-elf m32c-elf m32r-elf m32r-linux
m68hc11-elf m68k-elf m68k-linux m68k-netbsd m68k-openbsd m88k-openbsd
mep-elf microblaze-xilinx-elf microblaze-linux-gnu mips-elf moxie-elf
ms1-elf nios2-elf nios2-linux-gnu hppa-elf hppa-linux hppa-netbsd
hppa-openbsd powerpc-eabi powerpc-freebsd powerpc-netbsd powerpc-openbsd
powerpc-linux powerpc-lynx178 rl78-elf rx-elf s390-linux-gnu score-elf
sh-elf sh-linux sh-openbsd sh64-elf sh64-linux sh64-openbsd sparc64-linux
sparc-linux sparc-freebsd sparc64-freebsd sparc-netbsd sparc64-netbsd
sparc-openbsd sparc64-openbsd spu-elf tic6x-elf tic6x-uclinux v850-elf
vax-netbsd vax-openbsd x86_64-linux-gnu x86_64-darwin x86_64-dicos
x86_64-elf x86_64-freebsd x86_64-mingw32 x86_64-netbsd x86_64-openbsd
x86_64-rtems xstormy16-elf xtensa-elf xtensa-linux

gdb:

2017-09-29  Yao Qi  <yao.qi@linaro.org>

	* configure.tgt (i386_tobjs): New variable.
	(amd64_tobjs): New variable.
	Set $cpu_obs and $os_obs.

diff --git a/gdb/configure.tgt b/gdb/configure.tgt
index 40c44b7..659afd3 100644
--- a/gdb/configure.tgt
+++ b/gdb/configure.tgt
@@ -36,23 +36,78 @@ case $targ in
     ;;
 esac
 
+i386_tobjs="i386-tdep.o i386.o i387-tdep.o"
+amd64_tobjs="amd64-tdep.o arch/amd64.o"
+
+case "${targ}" in
+aarch64*-*-*)
+	cpu_obs="aarch64-tdep.o aarch64-insn.o";;
+
+alpha*-*-*)
+	# Target: Alpha
+	cpu_obs="alpha-tdep.o"
+	;;
+
+arc*-*-*)
+	# Target: Unidentified ARC target
+	cpu_obs="arc-tdep.o"
+	;;
+
+arm*-*-*)
+	cpu_obs="arm.o arm-get-next-pcs.o arm-tdep.o";;
+
+hppa*-*-*)
+	# Target: HP PA-RISC
+	cpu_obs="hppa-tdep.o"
+	;;
+
+i[34567]86-*-*)
+	cpu_obs="${i386_tobjs}"
+	if test "x$enable_64_bit_bfd" = "xyes"; then
+	   cpu_obs="${amd64_tobjs} ${cpu_obs}"
+	fi
+	;;
+
+ia64*-*-*)
+	# Target: Intel IA-64
+	cpu_obs="ia64-tdep.o"
+	;;
+
+x86_64-*-*)
+	cpu_obs="${i386_tobjs} ${amd64_tobjs}";;
+
+xtensa*)
+	# Target: Tensilica Xtensa processors
+	cpu_obs="xtensa-tdep.o xtensa-config.o solib-svr4.o"
+	;;
+
+esac
+
+case "${targ}" in
+*-*-freebsd* | *-*-kfreebsd*-gnu)
+	os_obs="fbsd-tdep.o solib-svr4.o";;
+*-*-netbsd* | *-*-knetbsd*-gnu)
+	os_obs="nbsd-tdep.o solib-svr4.o";;
+*-*-openbsd*)
+	os_obs="obsd-tdep.o solib-svr4.o";;
+esac
+
 # map target info into gdb names.
 
 case "${targ}" in
 aarch64*-*-elf | aarch64*-*-rtems*)
 	# Target: AArch64 embedded system
-	gdb_target_obs="aarch64-tdep.o aarch64-newlib-tdep.o aarch64-insn.o"
+	gdb_target_obs="aarch64-newlib-tdep.o"
 	;;
 
 aarch64*-*-freebsd*)
 	# Target: FreeBSD/aarch64
-	gdb_target_obs="aarch64-tdep.o aarch64-fbsd-tdep.o aarch64-insn.o \
-			fbsd-tdep.o solib-svr4.o"
+	gdb_target_obs="aarch64-fbsd-tdep.o"
 	;;
 
 aarch64*-*-linux*)
 	# Target: AArch64 linux
-	gdb_target_obs="aarch64-tdep.o aarch64-linux-tdep.o aarch64-insn.o \
+	gdb_target_obs="aarch64-linux-tdep.o \
 			arm.o arm-linux.o arm-get-next-pcs.o arm-tdep.o \
 			arm-linux-tdep.o \
 			glibc-tdep.o linux-tdep.o solib-svr4.o \
@@ -62,23 +117,18 @@ aarch64*-*-linux*)
 
 alpha*-*-linux*)
 	# Target: Little-endian Alpha running Linux
-	gdb_target_obs="alpha-tdep.o alpha-mdebug-tdep.o alpha-linux-tdep.o \
+	gdb_target_obs="alpha-mdebug-tdep.o alpha-linux-tdep.o \
 			linux-tdep.o solib-svr4.o"
 	;;
 alpha*-*-netbsd* | alpha*-*-knetbsd*-gnu)
 	# Target: NetBSD/alpha
-	gdb_target_obs="alpha-tdep.o alpha-mdebug-tdep.o alpha-bsd-tdep.o \
-			alpha-nbsd-tdep.o nbsd-tdep.o solib-svr4.o"
+	gdb_target_obs="alpha-mdebug-tdep.o alpha-bsd-tdep.o \
+			alpha-nbsd-tdep.o"
 	;;
 alpha*-*-openbsd*)
 	# Target: OpenBSD/alpha
-	gdb_target_obs="alpha-tdep.o alpha-mdebug-tdep.o alpha-bsd-tdep.o \
-			alpha-nbsd-tdep.o alpha-obsd-tdep.o nbsd-tdep.o \
-			obsd-tdep.o solib-svr4.o"
-	;;
-alpha*-*-*)
-	# Target: Alpha
-	gdb_target_obs="alpha-tdep.o"
+	gdb_target_obs="alpha-mdebug-tdep.o alpha-bsd-tdep.o \
+			alpha-nbsd-tdep.o alpha-obsd-tdep.o nbsd-tdep.o"
 	;;
 
 am33_2.0*-*-linux*)
@@ -89,44 +139,34 @@ am33_2.0*-*-linux*)
 
 arc*-*-elf32)
 	# Target: baremetal ARC elf32 (newlib) target
-	gdb_target_obs="arc-newlib-tdep.o arc-tdep.o"
-	;;
-
-arc*-*-*)
-	# Target: Unidentified ARC target
-	gdb_target_obs="arc-tdep.o"
+	gdb_target_obs="arc-newlib-tdep.o"
 	;;
 
 arm*-wince-pe | arm*-*-mingw32ce*)
 	# Target: ARM based machine running Windows CE (win32)
-	gdb_target_obs="arm.o arm-get-next-pcs.o arm-tdep.o \
-			arm-wince-tdep.o windows-tdep.o"
+	gdb_target_obs="arm-wince-tdep.o windows-tdep.o"
 	build_gdbserver=yes
 	;;
 arm*-*-linux*)
 	# Target: ARM based machine running GNU/Linux
-	gdb_target_obs="arm.o arm-linux.o arm-get-next-pcs.o arm-tdep.o \
-                        arm-linux-tdep.o glibc-tdep.o \
+	gdb_target_obs="arm-linux.o arm-linux-tdep.o glibc-tdep.o \
 			solib-svr4.o symfile-mem.o linux-tdep.o linux-record.o"
 	build_gdbserver=yes
 	;;
 arm*-*-netbsd* | arm*-*-knetbsd*-gnu)
 	# Target: NetBSD/arm
-	gdb_target_obs="arm.o arm-get-next-pcs.o arm-tdep.o arm-nbsd-tdep.o \
-			solib-svr4.o"
+	gdb_target_obs="arm-nbsd-tdep.o"
 	;;
 arm*-*-openbsd*)
 	# Target: OpenBSD/arm
-	gdb_target_obs="arm.o arm-get-next-pcs.o arm-tdep.o arm-bsd-tdep.o \
-			arm-obsd-tdep.o obsd-tdep.o solib-svr4.o"
+	gdb_target_obs="arm-bsd-tdep.o arm-obsd-tdep.o"
 	;;
 arm*-*-symbianelf*)
 	# Target: SymbianOS/arm
-	gdb_target_obs="arm.o arm-get-next-pcs.o arm-tdep.o arm-symbian-tdep.o"
+	gdb_target_obs="arm-symbian-tdep.o"
 	;;
 arm*-*-*)
 	# Target: ARM embedded system
-	gdb_target_obs="arm.o arm-get-next-pcs.o arm-tdep.o"
 	gdb_sim=../sim/arm/libsim.a
 	;;
 
@@ -172,113 +212,94 @@ h8300-*-*)
 
 hppa*-*-linux*)
 	# Target: HP PA-RISC running Linux
-	gdb_target_obs="hppa-tdep.o hppa-linux-tdep.o glibc-tdep.o \
+	gdb_target_obs="hppa-linux-tdep.o glibc-tdep.o \
 			linux-tdep.o solib-svr4.o symfile-mem.o"
 	;;
 hppa*-*-netbsd*)
 	# Target: NetBSD/hppa
-	gdb_target_obs="hppa-tdep.o hppa-bsd-tdep.o hppa-nbsd-tdep.o solib-svr4.o"
+	gdb_target_obs="hppa-bsd-tdep.o hppa-nbsd-tdep.o solib-svr4.o"
 	;;
 hppa*-*-openbsd*)
 	# Target: OpenBSD/hppa
-	gdb_target_obs="hppa-tdep.o hppa-bsd-tdep.o hppa-obsd-tdep.o solib-svr4.o"
-	;;
-hppa*-*-*)
-	# Target: HP PA-RISC
-	gdb_target_obs="hppa-tdep.o"
+	gdb_target_obs="hppa-bsd-tdep.o hppa-obsd-tdep.o solib-svr4.o"
 	;;
 
 i[34567]86-*-darwin*)
 	# Target: Darwin/i386
-	gdb_target_obs="i386-tdep.o i386.o i387-tdep.o \
-			i386-darwin-tdep.o solib-darwin.o"
+	gdb_target_obs="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 arch/amd64.o amd64-darwin-tdep.o ${gdb_target_obs}"
+	    gdb_target_obs="amd64-darwin-tdep.o ${gdb_target_obs}"
 	fi
 	;;
 i[34567]86-*-dicos*)
 	# Target: DICOS/i386
-	gdb_target_obs="i386-tdep.o i386.o i387-tdep.o dicos-tdep.o i386-dicos-tdep.o"
+	gdb_target_obs="dicos-tdep.o i386-dicos-tdep.o"
 	;;
 i[34567]86-*-freebsd* | i[34567]86-*-kfreebsd*-gnu)
 	# Target: FreeBSD/i386
-	gdb_target_obs="i386-tdep.o i386.o i387-tdep.o i386-bsd-tdep.o \
-			i386-fbsd-tdep.o fbsd-tdep.o solib-svr4.o"
+	gdb_target_obs="i386-bsd-tdep.o i386-fbsd-tdep.o "
 	;;
 i[34567]86-*-netbsd* | i[34567]86-*-knetbsd*-gnu)
 	# Target: NetBSD/i386
-	gdb_target_obs="i386-tdep.o i386.o i387-tdep.o i386-bsd-tdep.o \
-			i386-nbsd-tdep.o nbsd-tdep.o solib-svr4.o"
+	gdb_target_obs="i386-bsd-tdep.o i386-nbsd-tdep.o "
 	;;
 i[34567]86-*-openbsd*)
 	# Target: OpenBSD/i386
-	gdb_target_obs="i386-tdep.o i386.o i387-tdep.o i386-bsd-tdep.o \
-			i386-obsd-tdep.o obsd-tdep.o bsd-uthread.o \
-			solib-svr4.o"
+	gdb_target_obs="i386-bsd-tdep.o i386-obsd-tdep.o bsd-uthread.o"
 	;;
 i[34567]86-*-nto*)
 	# Target: Intel 386 running qnx6.
-	gdb_target_obs="i386-tdep.o i386.o i387-tdep.o solib-svr4.o \
+	gdb_target_obs="solib-svr4.o \
 			i386-nto-tdep.o nto-tdep.o"
 	build_gdbserver=yes
 	;;
 i[34567]86-*-solaris2* | x86_64-*-solaris2*)
 	# Target: Solaris x86_64
-	gdb_target_obs="i386-tdep.o i386.o i387-tdep.o amd64-tdep.o arch/amd64.o \
+	gdb_target_obs="${i386_tobjs} ${amd64_tobjs} \
 			 amd64-sol2-tdep.o i386-sol2-tdep.o sol2-tdep.o \
 			 solib-svr4.o"
 	;;
 i[34567]86-*-linux*)
 	# Target: Intel 386 running GNU/Linux
-	gdb_target_obs="i386-tdep.o i386.o i386-linux-tdep.o \
-			glibc-tdep.o i387-tdep.o \
+	gdb_target_obs="i386-linux-tdep.o \
+			glibc-tdep.o \
 			solib-svr4.o symfile-mem.o \
 			linux-tdep.o linux-record.o"
 	if test "x$enable_64_bit_bfd" = "xyes"; then
 	    # Target: GNU/Linux x86-64
-	    gdb_target_obs="amd64-tdep.o arch/amd64.o amd64-linux-tdep.o ${gdb_target_obs}"
+	    gdb_target_obs="amd64-linux-tdep.o ${gdb_target_obs}"
 	fi
 	build_gdbserver=yes
 	;;
 i[34567]86-*-gnu*)
 	# Target: Intel 386 running the GNU Hurd
-	gdb_target_obs="i386-tdep.o i386.o i387-tdep.o i386-gnu-tdep.o solib-svr4.o"
+	gdb_target_obs="i386-gnu-tdep.o solib-svr4.o"
 	;;
 i[34567]86-*-cygwin*)
 	# Target: Intel 386 running win32
-	gdb_target_obs="i386-tdep.o i386.o i386-cygwin-tdep.o i387-tdep.o \
-			windows-tdep.o"
+	gdb_target_obs="i386-cygwin-tdep.o windows-tdep.o"
 	build_gdbserver=yes
 	;;
 i[34567]86-*-mingw32*)
 	# Target: Intel 386 running win32
-	gdb_target_obs="i386-tdep.o i386.o i386-cygwin-tdep.o i387-tdep.o \
-			windows-tdep.o"
+	gdb_target_obs="i386-cygwin-tdep.o windows-tdep.o"
 	build_gdbserver=yes
 	;;
 i[34567]86-*-go32* | i[34567]86-*-msdosdjgpp*)
 	# Target: i386 running DJGPP/go32.
-	gdb_target_obs="i386-tdep.o i386.o i387-tdep.o i386-go32-tdep.o"
-	;;
-i[34567]86-*-*)
-	# Target: i386
-	gdb_target_obs="i386-tdep.o i386.o i387-tdep.o"
+	gdb_target_obs="i386-go32-tdep.o"
 	;;
 
 ia64-*-linux*)
 	# Target: Intel IA-64 running GNU/Linux
-	gdb_target_obs="ia64-tdep.o ia64-linux-tdep.o linux-tdep.o \
+	gdb_target_obs="ia64-linux-tdep.o linux-tdep.o \
 			solib-svr4.o symfile-mem.o"
 	build_gdbserver=yes
 	;;
 ia64-*-*vms*)
 	# Target: Intel IA-64 running OpenVMS
-	gdb_target_obs="ia64-tdep.o ia64-vms-tdep.o"
-	;;
-ia64*-*-*)
-	# Target: Intel IA-64
-	gdb_target_obs="ia64-tdep.o"
+	gdb_target_obs="ia64-vms-tdep.o"
 	;;
 
 iq2000-*-*)
@@ -332,11 +353,11 @@ m68*-*-linux*)
 	;;
 m68*-*-netbsd* | m68*-*-knetbsd*-gnu)
 	# Target: NetBSD/m68k
-	gdb_target_obs="m68k-tdep.o m68k-bsd-tdep.o solib-svr4.o"
+	gdb_target_obs="m68k-tdep.o m68k-bsd-tdep.o"
 	;;
 m68*-*-openbsd*)
 	# Target: OpenBSD/m68k
-	gdb_target_obs="m68k-tdep.o m68k-bsd-tdep.o solib-svr4.o"
+	gdb_target_obs="m68k-tdep.o m68k-bsd-tdep.o"
 	;;
 
 m88*-*-openbsd*)
@@ -371,17 +392,17 @@ mips*-*-linux*)
 	;;
 mips*-*-netbsd* | mips*-*-knetbsd*-gnu)
 	# Target: MIPS running NetBSD
-	gdb_target_obs="mips-tdep.o mips-nbsd-tdep.o solib-svr4.o nbsd-tdep.o"
+	gdb_target_obs="mips-tdep.o mips-nbsd-tdep.o"
 	gdb_sim=../sim/mips/libsim.a
 	;;
 mips*-*-freebsd*)
 	# Target: MIPS running FreeBSD
-	gdb_target_obs="mips-tdep.o mips-fbsd-tdep.o solib-svr4.o fbsd-tdep.o"
+	gdb_target_obs="mips-tdep.o mips-fbsd-tdep.o"
 	gdb_sim=../sim/mips/libsim.a
 	;;
 mips64*-*-openbsd*)
 	# Target: OpenBSD/mips64
-	gdb_target_obs="mips-tdep.o mips64-obsd-tdep.o obsd-tdep.o solib-svr4.o"
+	gdb_target_obs="mips-tdep.o mips64-obsd-tdep.o"
 	;;
 mips*-sde*-elf*)
 	# Target: MIPS SDE
@@ -434,21 +455,19 @@ nios2*-*-*)
 powerpc*-*-freebsd*)
 	# Target: FreeBSD/powerpc
 	gdb_target_obs="rs6000-tdep.o ppc-sysv-tdep.o ppc64-tdep.o \
-		        ppc-fbsd-tdep.o fbsd-tdep.o solib-svr4.o \
+		        ppc-fbsd-tdep.o \
 			ravenscar-thread.o ppc-ravenscar-thread.o"
 	;;
 
 powerpc-*-netbsd* | powerpc-*-knetbsd*-gnu)
 	# Target: NetBSD/powerpc
 	gdb_target_obs="rs6000-tdep.o ppc-sysv-tdep.o ppc-nbsd-tdep.o \
-			solib-svr4.o \
 			ravenscar-thread.o ppc-ravenscar-thread.o"
 	gdb_sim=../sim/ppc/libsim.a
 	;;
 powerpc-*-openbsd*)
 	# Target: OpenBSD/powerpc
 	gdb_target_obs="rs6000-tdep.o ppc-sysv-tdep.o ppc-obsd-tdep.o \
-			solib-svr4.o \
 			ravenscar-thread.o ppc-ravenscar-thread.o"
 	;;
 powerpc-*-aix* | rs6000-*-* | powerpc64-*-aix*)
@@ -516,12 +535,12 @@ sh*-*-linux*)
 	;;
 sh*-*-netbsdelf* | sh*-*-knetbsd*-gnu)
 	# Target: NetBSD/sh
-	gdb_target_obs="sh-tdep.o sh-nbsd-tdep.o solib-svr4.o"
+	gdb_target_obs="sh-tdep.o sh-nbsd-tdep.o"
 	gdb_sim=../sim/sh/libsim.a
 	;;
 sh*-*-openbsd*)
 	# Target: OpenBSD/sh
-	gdb_target_obs="sh-tdep.o sh64-tdep.o sh-nbsd-tdep.o solib-svr4.o"
+	gdb_target_obs="sh-tdep.o sh64-tdep.o sh-nbsd-tdep.o"
 	;;
 sh64-*-elf*)
 	# Target: Renesas/Super-H 64 bit with simulator
@@ -558,32 +577,30 @@ sparc64-*-linux*)
 sparc*-*-freebsd* | sparc*-*-kfreebsd*-gnu)
 	# Target: FreeBSD/sparc64
 	gdb_target_obs="sparc-tdep.o sparc64-tdep.o sparc64-fbsd-tdep.o \
-			fbsd-tdep.o solib-svr4.o \
 			ravenscar-thread.o sparc-ravenscar-thread.o"
 	;;
 sparc-*-netbsd* | sparc-*-knetbsd*-gnu)
 	# Target: NetBSD/sparc
-	gdb_target_obs="sparc-tdep.o sparc-nbsd-tdep.o nbsd-tdep.o \
-			solib-svr4.o \
+	gdb_target_obs="sparc-tdep.o sparc-nbsd-tdep.o \
 			ravenscar-thread.o sparc-ravenscar-thread.o"
 	;;
 sparc64-*-netbsd* | sparc64-*-knetbsd*-gnu)
 	# Target: NetBSD/sparc64
 	gdb_target_obs="sparc64-tdep.o sparc64-nbsd-tdep.o sparc-tdep.o \
-			sparc-nbsd-tdep.o nbsd-tdep.o solib-svr4.o \
+			sparc-nbsd-tdep.o \
 			ravenscar-thread.o sparc-ravenscar-thread.o"
 	;;
 sparc-*-openbsd*)
 	# Target: OpenBSD/sparc
 	gdb_target_obs="sparc-tdep.o sparc-nbsd-tdep.o sparc-obsd-tdep.o \
-			nbsd-tdep.o obsd-tdep.o bsd-uthread.o solib-svr4.o \
+			nbsd-tdep.o bsd-uthread.o \
 			ravenscar-thread.o sparc-ravenscar-thread.o"
 	;;
 sparc64-*-openbsd*)
 	# Target: OpenBSD/sparc64
 	gdb_target_obs="sparc64-tdep.o sparc64-nbsd-tdep.o sparc64-obsd-tdep.o \
 			sparc-tdep.o sparc-nbsd-tdep.o sparc-obsd-tdep.o \
-			nbsd-tdep.o obsd-tdep.o bsd-uthread.o solib-svr4.o \
+			nbsd-tdep.o bsd-uthread.o \
 			ravenscar-thread.o sparc-ravenscar-thread.o"
 	;;
 sparc-*-solaris2* | sparcv9-*-solaris2* | sparc64-*-solaris2*)
@@ -660,67 +677,61 @@ vax-*-*)
 
 x86_64-*-darwin*)
 	# Target: Darwin/x86-64
-	gdb_target_obs="amd64-tdep.o arch/amd64.o i386-tdep.o i386.o i387-tdep.o \
+	gdb_target_obs="${i386_tobjs} \
 			i386-darwin-tdep.o amd64-darwin-tdep.o \
                         solib-darwin.o"
 	;;
 
 x86_64-*-dicos*)
 	# Target: DICOS/x86-64
-	gdb_target_obs="amd64-tdep.o arch/amd64.o i386-tdep.o i386.o i387-tdep.o \
+	gdb_target_obs="${i386_tobjs} \
 			dicos-tdep.o i386-dicos-tdep.o amd64-dicos-tdep.o"
 	;;
 x86_64-*-elf*)
-	gdb_target_obs="amd64-tdep.o arch/amd64.o i386-tdep.o i386.o i387-tdep.o"
+	gdb_target_obs="${i386_tobjs}"
 	;;
 x86_64-*-linux*)
 	# Target: GNU/Linux x86-64
-	gdb_target_obs="amd64-tdep.o amd64-linux-tdep.o arch/amd64.o i386-tdep.o \
-			i387-tdep.o i386.o i386-linux-tdep.o glibc-tdep.o \
+	gdb_target_obs="amd64-linux-tdep.o ${i386_tobjs}  \
+			i386-linux-tdep.o glibc-tdep.o \
 			solib-svr4.o symfile-mem.o linux-tdep.o linux-record.o"
 	build_gdbserver=yes
 	;;
 x86_64-*-freebsd* | x86_64-*-kfreebsd*-gnu)
 	# Target: FreeBSD/amd64
-	gdb_target_obs="amd64-tdep.o arch/amd64.o amd64-fbsd-tdep.o i386-tdep.o \
-			i386.o i387-tdep.o i386-bsd-tdep.o i386-fbsd-tdep.o \
-			fbsd-tdep.o solib-svr4.o"
+	gdb_target_obs="amd64-fbsd-tdep.o ${i386_tobjs} \
+			i386-bsd-tdep.o i386-fbsd-tdep.o"
 	;;
 x86_64-*-mingw* | x86_64-*-cygwin*)
         # Target: MingW/amd64
-	gdb_target_obs="amd64-tdep.o arch/amd64.o amd64-windows-tdep.o \
-                        i386-tdep.o i386.o i386-cygwin-tdep.o i387-tdep.o \
+	gdb_target_obs="amd64-windows-tdep.o \
+                        ${i386_tobjs} i386-cygwin-tdep.o \
                         windows-tdep.o"
 	build_gdbserver=yes
         ;;
 x86_64-*-netbsd* | x86_64-*-knetbsd*-gnu)
 	# Target: NetBSD/amd64
-	gdb_target_obs="amd64-tdep.o arch/amd64.o amd64-nbsd-tdep.o i386-tdep.o \
-			i386.o i387-tdep.o nbsd-tdep.o solib-svr4.o"
+	gdb_target_obs="amd64-nbsd-tdep.o ${i386_tobjs}"
 	;;
 x86_64-*-openbsd*)
 	# Target: OpenBSD/amd64
-	gdb_target_obs="amd64-tdep.o arch/amd64.o amd64-obsd-tdep.o i386-tdep.o \
-			i387-tdep.o i386-bsd-tdep.o i386-obsd-tdep.o \
-			i386.o obsd-tdep.o bsd-uthread.o solib-svr4.o"
+	gdb_target_obs="amd64-obsd-tdep.o ${i386_tobjs} \
+			i386-bsd-tdep.o i386-obsd-tdep.o \
+			bsd-uthread.o"
 	;;
 x86_64-*-rtems*)
-	gdb_target_obs="amd64-tdep.o arch/amd64.o i386-tdep.o i386.o i387-tdep.o \
-			i386-bsd-tdep.o"
+	gdb_target_obs="${amd64_tobjs} ${i386_tobjs} i386-bsd-tdep.o"
 	;;
 xtensa*-*-linux*)	gdb_target=linux
 	# Target: GNU/Linux Xtensa
-	gdb_target_obs="xtensa-tdep.o xtensa-config.o xtensa-linux-tdep.o \
-			solib-svr4.o symfile-mem.o linux-tdep.o"
+	gdb_target_obs="xtensa-linux-tdep.o symfile-mem.o linux-tdep.o"
 	build_gdbserver=yes
 	;;
-xtensa*)
-	# Target: Tensilica Xtensa processors
-	gdb_target_obs="xtensa-tdep.o xtensa-config.o solib-svr4.o"
-	;;
 
 esac
 
+gdb_target_obs="${cpu_obs} ${os_obs} ${gdb_target_obs}"
+
 # map target onto default OS ABI
 
 case "${targ}" in

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [RFC] Replicate src dir in build dir
  2017-09-29 19:23       ` Yao Qi
@ 2017-10-03 20:02         ` Pedro Alves
  2017-10-03 20:14           ` Kamil Rytarowski
                             ` (2 more replies)
  0 siblings, 3 replies; 20+ messages in thread
From: Pedro Alves @ 2017-10-03 20:02 UTC (permalink / raw)
  To: Yao Qi; +Cc: gdb-patches

On 09/29/2017 08:23 PM, Yao Qi wrote:

> 
> I tested this patch by build gdb for each different target triplets
> respectively,
> 
> aarch64-elf aarch64-rtems aarch64-freebsd aarch64-linux alpha-elf
> alpha-linux alpha-netbsd alpha-openbsd arm-elf arm-wince-pe arm-linux
> arm-netbsd arm-symbianelf avr cris-elf frv-elf h8300-elf i386-elf
> i386-darwin i386-dicos i386-freebsd i386-netbsdelf i386-openbsd
> i386-nto i386-solaris i386-linux i386-gnu i386-cygwin i386-mingw32
> i386-go32 ia64-linux-gnu ia64-vms lm32-elf m32c-elf m32r-elf m32r-linux
> m68hc11-elf m68k-elf m68k-linux m68k-netbsd m68k-openbsd m88k-openbsd
> mep-elf microblaze-xilinx-elf microblaze-linux-gnu mips-elf moxie-elf
> ms1-elf nios2-elf nios2-linux-gnu hppa-elf hppa-linux hppa-netbsd
> hppa-openbsd powerpc-eabi powerpc-freebsd powerpc-netbsd powerpc-openbsd
> powerpc-linux powerpc-lynx178 rl78-elf rx-elf s390-linux-gnu score-elf
> sh-elf sh-linux sh-openbsd sh64-elf sh64-linux sh64-openbsd sparc64-linux
> sparc-linux sparc-freebsd sparc64-freebsd sparc-netbsd sparc64-netbsd
> sparc-openbsd sparc64-openbsd spu-elf tic6x-elf tic6x-uclinux v850-elf
> vax-netbsd vax-openbsd x86_64-linux-gnu x86_64-darwin x86_64-dicos
> x86_64-elf x86_64-freebsd x86_64-mingw32 x86_64-netbsd x86_64-openbsd
> x86_64-rtems xstormy16-elf xtensa-elf xtensa-linux

OOC, this wasn't with gdb/gdb_buildall.sh, was it?

> +
> +case "${targ}" in
> +*-*-freebsd* | *-*-kfreebsd*-gnu)
> +	os_obs="fbsd-tdep.o solib-svr4.o";;
> +*-*-netbsd* | *-*-knetbsd*-gnu)
> +	os_obs="nbsd-tdep.o solib-svr4.o";;
> +*-*-openbsd*)
> +	os_obs="obsd-tdep.o solib-svr4.o";;

I'm surprised that there's no case for GNU/Linux
here, with at least linux-tdep.c and solib-svr4.o,
off hand.  Maybe glibc-tdep.o too.

There could be a case here for mingw/cygwin ports,
containing windows-tdep.o.

And case for darwin ports with solib-darwin.o.

But none of that are blockers.  I'm totally fine with
incremental progress.  We can always improve on top.

> +esac
> +
>  # map target info into gdb names.

I think IBWN to add a comment before each of the
arch / os sections, so that it's really obvious
what the different sections are about to new readers.
This "map target info ..." preexisting comment just above
might use an update too.

But generally, I'm happy with this.  Thanks much for doing it.

Thanks,
Pedro Alves

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [RFC] Replicate src dir in build dir
  2017-10-03 20:02         ` Pedro Alves
@ 2017-10-03 20:14           ` Kamil Rytarowski
  2017-10-03 22:04             ` Pedro Alves
  2017-10-04 11:41           ` Pedro Alves
  2017-10-06 10:21           ` Yao Qi
  2 siblings, 1 reply; 20+ messages in thread
From: Kamil Rytarowski @ 2017-10-03 20:14 UTC (permalink / raw)
  To: Pedro Alves, Yao Qi; +Cc: gdb-patches


[-- Attachment #1.1: Type: text/plain, Size: 430 bytes --]

On 03.10.2017 22:02, Pedro Alves wrote:
> On 09/29/2017 08:23 PM, Yao Qi wrote:
>> +
>> +case "${targ}" in
>> +*-*-freebsd* | *-*-kfreebsd*-gnu)
>> +	os_obs="fbsd-tdep.o solib-svr4.o";;
>> +*-*-netbsd* | *-*-knetbsd*-gnu)
>> +	os_obs="nbsd-tdep.o solib-svr4.o";;
>> +*-*-openbsd*)
>> +	os_obs="obsd-tdep.o solib-svr4.o";;

There does not exist any GNU/kNetBSD distribution and nobody is doing
it. Please drop it.



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [RFC] Replicate src dir in build dir
  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
  0 siblings, 2 replies; 20+ messages in thread
From: Pedro Alves @ 2017-10-03 22:04 UTC (permalink / raw)
  To: Kamil Rytarowski, Yao Qi; +Cc: gdb-patches

On 10/03/2017 09:16 PM, Kamil Rytarowski wrote:
> On 03.10.2017 22:02, Pedro Alves wrote:
>> On 09/29/2017 08:23 PM, Yao Qi wrote:
>>> +
>>> +case "${targ}" in
>>> +*-*-freebsd* | *-*-kfreebsd*-gnu)
>>> +	os_obs="fbsd-tdep.o solib-svr4.o";;
>>> +*-*-netbsd* | *-*-knetbsd*-gnu)
>>> +	os_obs="nbsd-tdep.o solib-svr4.o";;
>>> +*-*-openbsd*)
>>> +	os_obs="obsd-tdep.o solib-svr4.o";;
> 
> There does not exist any GNU/kNetBSD distribution and nobody is doing
> it. Please drop it.

Well, "does not exist" is a bit misleading, since there's
https://www.debian.org/ports/netbsd/ .  (I had no idea about it,
but google found it...)

However, that page does say:

  This porting effort has long been abandoned. It has had no updates since october 2002.
  The informations in this page are only for historical purposes. 

So it really sounds like we could zap it.  Ideally that should be a
separate commit, with a gdb/NEWS entry change, and we'd drop
it everywhere it's mentioned, not just configure.tgt.

"git grep knetbsd" finds hits in bfd and ld too, btw.

GCC dropped support last year, BTW:

  https://gcc.gnu.org/ml/gcc-patches/2016-06/msg01370.html

which is another nail in the coffin...

Thanks,
Pedro Alves

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [RFC] Replicate src dir in build dir
  2017-10-03 22:04             ` Pedro Alves
@ 2017-10-04  9:46               ` Kamil Rytarowski
  2017-10-06  9:29               ` Yao Qi
  1 sibling, 0 replies; 20+ messages in thread
From: Kamil Rytarowski @ 2017-10-04  9:46 UTC (permalink / raw)
  To: Pedro Alves, Yao Qi; +Cc: gdb-patches


[-- Attachment #1.1: Type: text/plain, Size: 1814 bytes --]

On 04.10.2017 00:04, Pedro Alves wrote:
> On 10/03/2017 09:16 PM, Kamil Rytarowski wrote:
>> On 03.10.2017 22:02, Pedro Alves wrote:
>>> On 09/29/2017 08:23 PM, Yao Qi wrote:
>>>> +
>>>> +case "${targ}" in
>>>> +*-*-freebsd* | *-*-kfreebsd*-gnu)
>>>> +	os_obs="fbsd-tdep.o solib-svr4.o";;
>>>> +*-*-netbsd* | *-*-knetbsd*-gnu)
>>>> +	os_obs="nbsd-tdep.o solib-svr4.o";;
>>>> +*-*-openbsd*)
>>>> +	os_obs="obsd-tdep.o solib-svr4.o";;
>>
>> There does not exist any GNU/kNetBSD distribution and nobody is doing
>> it. Please drop it.
> 
> Well, "does not exist" is a bit misleading, since there's
> https://www.debian.org/ports/netbsd/ .  (I had no idea about it,
> but google found it...)
> 

It was never finished and quickly abandoned. There was never a
functional GNU/kNetBSD distribution and nobody from the NetBSD community
aims for one.

There were other projects like reuse Gentoo portage on NetBSD, but this
does not replace the base distribution, just host the packaging tool on top.

> However, that page does say:
> 
>   This porting effort has long been abandoned. It has had no updates since october 2002.
>   The informations in this page are only for historical purposes. 
> 
> So it really sounds like we could zap it.  Ideally that should be a
> separate commit, with a gdb/NEWS entry change, and we'd drop
> it everywhere it's mentioned, not just configure.tgt.
> 
> "git grep knetbsd" finds hits in bfd and ld too, btw.
> 
> GCC dropped support last year, BTW:
> 
>   https://gcc.gnu.org/ml/gcc-patches/2016-06/msg01370.html
> 
> which is another nail in the coffin...
> 

Right, I prompted to drop it in GCC and asked on a NetBSD mailing-list
whether someone is interested in such project - without volunteers.

> Thanks,
> Pedro Alves
> 



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [RFC] Replicate src dir in build dir
  2017-10-03 20:02         ` Pedro Alves
  2017-10-03 20:14           ` Kamil Rytarowski
@ 2017-10-04 11:41           ` Pedro Alves
  2017-10-06 10:21           ` Yao Qi
  2 siblings, 0 replies; 20+ messages in thread
From: Pedro Alves @ 2017-10-04 11:41 UTC (permalink / raw)
  To: Yao Qi; +Cc: gdb-patches

On 10/03/2017 09:02 PM, Pedro Alves wrote:
> On 09/29/2017 08:23 PM, Yao Qi wrote:
> 
>> > 
>> > I tested this patch by build gdb for each different target triplets
>> > respectively,
>> > 
>> > aarch64-elf aarch64-rtems aarch64-freebsd aarch64-linux alpha-elf
>> > alpha-linux alpha-netbsd alpha-openbsd arm-elf arm-wince-pe arm-linux
>> > arm-netbsd arm-symbianelf avr cris-elf frv-elf h8300-elf i386-elf
>> > i386-darwin i386-dicos i386-freebsd i386-netbsdelf i386-openbsd
>> > i386-nto i386-solaris i386-linux i386-gnu i386-cygwin i386-mingw32
>> > i386-go32 ia64-linux-gnu ia64-vms lm32-elf m32c-elf m32r-elf m32r-linux
>> > m68hc11-elf m68k-elf m68k-linux m68k-netbsd m68k-openbsd m88k-openbsd
>> > mep-elf microblaze-xilinx-elf microblaze-linux-gnu mips-elf moxie-elf
>> > ms1-elf nios2-elf nios2-linux-gnu hppa-elf hppa-linux hppa-netbsd
>> > hppa-openbsd powerpc-eabi powerpc-freebsd powerpc-netbsd powerpc-openbsd
>> > powerpc-linux powerpc-lynx178 rl78-elf rx-elf s390-linux-gnu score-elf
>> > sh-elf sh-linux sh-openbsd sh64-elf sh64-linux sh64-openbsd sparc64-linux
>> > sparc-linux sparc-freebsd sparc64-freebsd sparc-netbsd sparc64-netbsd
>> > sparc-openbsd sparc64-openbsd spu-elf tic6x-elf tic6x-uclinux v850-elf
>> > vax-netbsd vax-openbsd x86_64-linux-gnu x86_64-darwin x86_64-dicos
>> > x86_64-elf x86_64-freebsd x86_64-mingw32 x86_64-netbsd x86_64-openbsd
>> > x86_64-rtems xstormy16-elf xtensa-elf xtensa-linux
> OOC, this wasn't with gdb/gdb_buildall.sh, was it?
> 

BTW, I was thinking how you don't really need to build gdb to test this.

All you need is to make sure that gdb_target_obs is the same list of
objects before and after the patch.  So you could drop this script
in gdb/ , and call it for each for the triplets above, before and
after the patch, and diff the output.

~~~
$ cat test-configure.tgt
set -e

targ=$1

if [ $targ == "" ]; then
   echo "no target specified"
   exit 1
fi

source ./configure.tgt
echo "target: $targ"
objs=$(echo $gdb_target_obs | sort -u)
echo "gdb_target_obs: $objs"
~~~

$ ./test-configure.tgt i686-unknown-linux-gnu
target: i686-unknown-linux-gnu
gdb_target_obs: i386-tdep.o i386.o i386-linux-tdep.o glibc-tdep.o i387-tdep.o solib-svr4.o symfile-mem.o linux-tdep.o linux-record.o

That's going to be way faster...

Might be worth it to add something like this to the tree.

Thanks,
Pedro Alves

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [RFC] Replicate src dir in build dir
  2017-10-03 22:04             ` Pedro Alves
  2017-10-04  9:46               ` Kamil Rytarowski
@ 2017-10-06  9:29               ` Yao Qi
  1 sibling, 0 replies; 20+ messages in thread
From: Yao Qi @ 2017-10-06  9:29 UTC (permalink / raw)
  To: Pedro Alves; +Cc: Kamil Rytarowski, gdb-patches

Pedro Alves <palves@redhat.com> writes:

> So it really sounds like we could zap it.  Ideally that should be a
> separate commit, with a gdb/NEWS entry change, and we'd drop
> it everywhere it's mentioned, not just configure.tgt.
>
> "git grep knetbsd" finds hits in bfd and ld too, btw.

I agree.  It should be a separate commit or commits to drop it.

-- 
Yao (齐尧)

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [RFC] Replicate src dir in build dir
  2017-10-03 20:02         ` Pedro Alves
  2017-10-03 20:14           ` Kamil Rytarowski
  2017-10-04 11:41           ` Pedro Alves
@ 2017-10-06 10:21           ` Yao Qi
  2 siblings, 0 replies; 20+ messages in thread
From: Yao Qi @ 2017-10-06 10:21 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches

Pedro Alves <palves@redhat.com> writes:

> OOC, this wasn't with gdb/gdb_buildall.sh, was it?
>

It is gdb_mbuild.sh, but they are similar.

>> +
>> +case "${targ}" in
>> +*-*-freebsd* | *-*-kfreebsd*-gnu)
>> +	os_obs="fbsd-tdep.o solib-svr4.o";;
>> +*-*-netbsd* | *-*-knetbsd*-gnu)
>> +	os_obs="nbsd-tdep.o solib-svr4.o";;
>> +*-*-openbsd*)
>> +	os_obs="obsd-tdep.o solib-svr4.o";;
>
> I'm surprised that there's no case for GNU/Linux
> here, with at least linux-tdep.c and solib-svr4.o,
> off hand.  Maybe glibc-tdep.o too.

I intended to add a case for linux here, but stop there due to some
special cases, s390*-*-linux* doesn't have glibc-tdep.o.  tic6x-*-*linux
doesn't have solib-svr4.o (because it is actually uclinux).  Anyway, I
agree we need a case for linux, but still need to examine each special
cases.

>
> There could be a case here for mingw/cygwin ports,
> containing windows-tdep.o.

arm*-wince-pe is a special case here.  "wince" doesn't appear in the
"os" part of target triplet (machine-vendor-os).

>
> And case for darwin ports with solib-darwin.o.

Right.

>
> But none of that are blockers.  I'm totally fine with
> incremental progress.  We can always improve on top.
>
>> +esac
>> +
>>  # map target info into gdb names.
>
> I think IBWN to add a comment before each of the
> arch / os sections, so that it's really obvious
> what the different sections are about to new readers.
> This "map target info ..." preexisting comment just above
> might use an update too.

Added some comments.

>
> But generally, I'm happy with this.  Thanks much for doing it.

Thanks for the review, patch below is what I pushed in.

-- 
Yao (齐尧)
From d97987e219b80c670e37eb0e25e31b36fa295509 Mon Sep 17 00:00:00 2001
From: Yao Qi <yao.qi@linaro.org>
Date: Fri, 6 Oct 2017 11:18:48 +0100
Subject: [PATCH] Share code updating gdb_target_obs

Nowadays, there are much duplications in configure.tgt to update
gdb_target_obs, some cpu specific object files are added to gdb_target_obs
to some different target triplets of the same cpu.  The same problem
exists for os specific object files too.  It is fragile to update them,
and build with all targets enabled doesn't find the problem.

This patch splits the gdb_target_obs update to three steps, cpu steps, os
steps, and the rest.

I tested this patch by build gdb for each different target triplets
respectively,

aarch64-elf aarch64-rtems aarch64-freebsd aarch64-linux alpha-elf
alpha-linux alpha-netbsd alpha-openbsd arm-elf arm-wince-pe arm-linux
arm-netbsd arm-symbianelf avr cris-elf frv-elf h8300-elf i386-elf
i386-darwin i386-dicos i386-freebsd i386-netbsdelf i386-openbsd
i386-nto i386-solaris i386-linux i386-gnu i386-cygwin i386-mingw32
i386-go32 ia64-linux-gnu ia64-vms lm32-elf m32c-elf m32r-elf m32r-linux
m68hc11-elf m68k-elf m68k-linux m68k-netbsd m68k-openbsd m88k-openbsd
mep-elf microblaze-xilinx-elf microblaze-linux-gnu mips-elf moxie-elf
ms1-elf nios2-elf nios2-linux-gnu hppa-elf hppa-linux hppa-netbsd
hppa-openbsd powerpc-eabi powerpc-freebsd powerpc-netbsd powerpc-openbsd
powerpc-linux powerpc-lynx178 rl78-elf rx-elf s390-linux-gnu score-elf
sh-elf sh-linux sh-openbsd sh64-elf sh64-linux sh64-openbsd sparc64-linux
sparc-linux sparc-freebsd sparc64-freebsd sparc-netbsd sparc64-netbsd
sparc-openbsd sparc64-openbsd spu-elf tic6x-elf tic6x-uclinux v850-elf
vax-netbsd vax-openbsd x86_64-linux-gnu x86_64-darwin x86_64-dicos
x86_64-elf x86_64-freebsd x86_64-mingw32 x86_64-netbsd x86_64-openbsd
x86_64-rtems xstormy16-elf xtensa-elf xtensa-linux

gdb:

2017-10-06  Yao Qi  <yao.qi@linaro.org>

	* configure.tgt (i386_tobjs): New variable.
	(amd64_tobjs): New variable.
	Set $cpu_obs and $os_obs.

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 93389b2..0f92439 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,11 @@
 2017-10-06  Yao Qi  <yao.qi@linaro.org>
 
+	* configure.tgt (i386_tobjs): New variable.
+	(amd64_tobjs): New variable.
+	Set $cpu_obs and $os_obs.
+
+2017-10-06  Yao Qi  <yao.qi@linaro.org>
+
 	* Makefile.in (CONFIG_SRC_SUBDIR): New.
 	(ALL_64_TARGET_OBS): Replace amd64.o with arch/amd64.o.
 	(clean): Remove object files and dependency files.
diff --git a/gdb/configure.tgt b/gdb/configure.tgt
index 40c44b7..96cc7ee 100644
--- a/gdb/configure.tgt
+++ b/gdb/configure.tgt
@@ -36,23 +36,85 @@ case $targ in
     ;;
 esac
 
-# map target info into gdb names.
+i386_tobjs="i386-tdep.o i386.o i387-tdep.o"
+amd64_tobjs="amd64-tdep.o arch/amd64.o"
+
+# Here are three sections to get a list of target specific object
+# files according to target triplet $TARG.
+
+# 1. Get the objects per cpu in $TARG.
+
+case "${targ}" in
+aarch64*-*-*)
+	cpu_obs="aarch64-tdep.o aarch64-insn.o";;
+
+alpha*-*-*)
+	# Target: Alpha
+	cpu_obs="alpha-tdep.o"
+	;;
+
+arc*-*-*)
+	# Target: Unidentified ARC target
+	cpu_obs="arc-tdep.o"
+	;;
+
+arm*-*-*)
+	cpu_obs="arm.o arm-get-next-pcs.o arm-tdep.o";;
+
+hppa*-*-*)
+	# Target: HP PA-RISC
+	cpu_obs="hppa-tdep.o"
+	;;
+
+i[34567]86-*-*)
+	cpu_obs="${i386_tobjs}"
+	if test "x$enable_64_bit_bfd" = "xyes"; then
+	   cpu_obs="${amd64_tobjs} ${cpu_obs}"
+	fi
+	;;
+
+ia64*-*-*)
+	# Target: Intel IA-64
+	cpu_obs="ia64-tdep.o"
+	;;
+
+x86_64-*-*)
+	cpu_obs="${i386_tobjs} ${amd64_tobjs}";;
+
+xtensa*)
+	# Target: Tensilica Xtensa processors
+	cpu_obs="xtensa-tdep.o xtensa-config.o solib-svr4.o"
+	;;
+
+esac
+
+# 2. Get the objects per os in $TARG.
+
+case "${targ}" in
+*-*-freebsd* | *-*-kfreebsd*-gnu)
+	os_obs="fbsd-tdep.o solib-svr4.o";;
+*-*-netbsd* | *-*-knetbsd*-gnu)
+	os_obs="nbsd-tdep.o solib-svr4.o";;
+*-*-openbsd*)
+	os_obs="obsd-tdep.o solib-svr4.o";;
+esac
+
+# 3. Get the rest of objects.
 
 case "${targ}" in
 aarch64*-*-elf | aarch64*-*-rtems*)
 	# Target: AArch64 embedded system
-	gdb_target_obs="aarch64-tdep.o aarch64-newlib-tdep.o aarch64-insn.o"
+	gdb_target_obs="aarch64-newlib-tdep.o"
 	;;
 
 aarch64*-*-freebsd*)
 	# Target: FreeBSD/aarch64
-	gdb_target_obs="aarch64-tdep.o aarch64-fbsd-tdep.o aarch64-insn.o \
-			fbsd-tdep.o solib-svr4.o"
+	gdb_target_obs="aarch64-fbsd-tdep.o"
 	;;
 
 aarch64*-*-linux*)
 	# Target: AArch64 linux
-	gdb_target_obs="aarch64-tdep.o aarch64-linux-tdep.o aarch64-insn.o \
+	gdb_target_obs="aarch64-linux-tdep.o \
 			arm.o arm-linux.o arm-get-next-pcs.o arm-tdep.o \
 			arm-linux-tdep.o \
 			glibc-tdep.o linux-tdep.o solib-svr4.o \
@@ -62,23 +124,18 @@ aarch64*-*-linux*)
 
 alpha*-*-linux*)
 	# Target: Little-endian Alpha running Linux
-	gdb_target_obs="alpha-tdep.o alpha-mdebug-tdep.o alpha-linux-tdep.o \
+	gdb_target_obs="alpha-mdebug-tdep.o alpha-linux-tdep.o \
 			linux-tdep.o solib-svr4.o"
 	;;
 alpha*-*-netbsd* | alpha*-*-knetbsd*-gnu)
 	# Target: NetBSD/alpha
-	gdb_target_obs="alpha-tdep.o alpha-mdebug-tdep.o alpha-bsd-tdep.o \
-			alpha-nbsd-tdep.o nbsd-tdep.o solib-svr4.o"
+	gdb_target_obs="alpha-mdebug-tdep.o alpha-bsd-tdep.o \
+			alpha-nbsd-tdep.o"
 	;;
 alpha*-*-openbsd*)
 	# Target: OpenBSD/alpha
-	gdb_target_obs="alpha-tdep.o alpha-mdebug-tdep.o alpha-bsd-tdep.o \
-			alpha-nbsd-tdep.o alpha-obsd-tdep.o nbsd-tdep.o \
-			obsd-tdep.o solib-svr4.o"
-	;;
-alpha*-*-*)
-	# Target: Alpha
-	gdb_target_obs="alpha-tdep.o"
+	gdb_target_obs="alpha-mdebug-tdep.o alpha-bsd-tdep.o \
+			alpha-nbsd-tdep.o alpha-obsd-tdep.o nbsd-tdep.o"
 	;;
 
 am33_2.0*-*-linux*)
@@ -89,44 +146,34 @@ am33_2.0*-*-linux*)
 
 arc*-*-elf32)
 	# Target: baremetal ARC elf32 (newlib) target
-	gdb_target_obs="arc-newlib-tdep.o arc-tdep.o"
-	;;
-
-arc*-*-*)
-	# Target: Unidentified ARC target
-	gdb_target_obs="arc-tdep.o"
+	gdb_target_obs="arc-newlib-tdep.o"
 	;;
 
 arm*-wince-pe | arm*-*-mingw32ce*)
 	# Target: ARM based machine running Windows CE (win32)
-	gdb_target_obs="arm.o arm-get-next-pcs.o arm-tdep.o \
-			arm-wince-tdep.o windows-tdep.o"
+	gdb_target_obs="arm-wince-tdep.o windows-tdep.o"
 	build_gdbserver=yes
 	;;
 arm*-*-linux*)
 	# Target: ARM based machine running GNU/Linux
-	gdb_target_obs="arm.o arm-linux.o arm-get-next-pcs.o arm-tdep.o \
-                        arm-linux-tdep.o glibc-tdep.o \
+	gdb_target_obs="arm-linux.o arm-linux-tdep.o glibc-tdep.o \
 			solib-svr4.o symfile-mem.o linux-tdep.o linux-record.o"
 	build_gdbserver=yes
 	;;
 arm*-*-netbsd* | arm*-*-knetbsd*-gnu)
 	# Target: NetBSD/arm
-	gdb_target_obs="arm.o arm-get-next-pcs.o arm-tdep.o arm-nbsd-tdep.o \
-			solib-svr4.o"
+	gdb_target_obs="arm-nbsd-tdep.o"
 	;;
 arm*-*-openbsd*)
 	# Target: OpenBSD/arm
-	gdb_target_obs="arm.o arm-get-next-pcs.o arm-tdep.o arm-bsd-tdep.o \
-			arm-obsd-tdep.o obsd-tdep.o solib-svr4.o"
+	gdb_target_obs="arm-bsd-tdep.o arm-obsd-tdep.o"
 	;;
 arm*-*-symbianelf*)
 	# Target: SymbianOS/arm
-	gdb_target_obs="arm.o arm-get-next-pcs.o arm-tdep.o arm-symbian-tdep.o"
+	gdb_target_obs="arm-symbian-tdep.o"
 	;;
 arm*-*-*)
 	# Target: ARM embedded system
-	gdb_target_obs="arm.o arm-get-next-pcs.o arm-tdep.o"
 	gdb_sim=../sim/arm/libsim.a
 	;;
 
@@ -172,113 +219,94 @@ h8300-*-*)
 
 hppa*-*-linux*)
 	# Target: HP PA-RISC running Linux
-	gdb_target_obs="hppa-tdep.o hppa-linux-tdep.o glibc-tdep.o \
+	gdb_target_obs="hppa-linux-tdep.o glibc-tdep.o \
 			linux-tdep.o solib-svr4.o symfile-mem.o"
 	;;
 hppa*-*-netbsd*)
 	# Target: NetBSD/hppa
-	gdb_target_obs="hppa-tdep.o hppa-bsd-tdep.o hppa-nbsd-tdep.o solib-svr4.o"
+	gdb_target_obs="hppa-bsd-tdep.o hppa-nbsd-tdep.o solib-svr4.o"
 	;;
 hppa*-*-openbsd*)
 	# Target: OpenBSD/hppa
-	gdb_target_obs="hppa-tdep.o hppa-bsd-tdep.o hppa-obsd-tdep.o solib-svr4.o"
-	;;
-hppa*-*-*)
-	# Target: HP PA-RISC
-	gdb_target_obs="hppa-tdep.o"
+	gdb_target_obs="hppa-bsd-tdep.o hppa-obsd-tdep.o solib-svr4.o"
 	;;
 
 i[34567]86-*-darwin*)
 	# Target: Darwin/i386
-	gdb_target_obs="i386-tdep.o i386.o i387-tdep.o \
-			i386-darwin-tdep.o solib-darwin.o"
+	gdb_target_obs="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 arch/amd64.o amd64-darwin-tdep.o ${gdb_target_obs}"
+	    gdb_target_obs="amd64-darwin-tdep.o ${gdb_target_obs}"
 	fi
 	;;
 i[34567]86-*-dicos*)
 	# Target: DICOS/i386
-	gdb_target_obs="i386-tdep.o i386.o i387-tdep.o dicos-tdep.o i386-dicos-tdep.o"
+	gdb_target_obs="dicos-tdep.o i386-dicos-tdep.o"
 	;;
 i[34567]86-*-freebsd* | i[34567]86-*-kfreebsd*-gnu)
 	# Target: FreeBSD/i386
-	gdb_target_obs="i386-tdep.o i386.o i387-tdep.o i386-bsd-tdep.o \
-			i386-fbsd-tdep.o fbsd-tdep.o solib-svr4.o"
+	gdb_target_obs="i386-bsd-tdep.o i386-fbsd-tdep.o "
 	;;
 i[34567]86-*-netbsd* | i[34567]86-*-knetbsd*-gnu)
 	# Target: NetBSD/i386
-	gdb_target_obs="i386-tdep.o i386.o i387-tdep.o i386-bsd-tdep.o \
-			i386-nbsd-tdep.o nbsd-tdep.o solib-svr4.o"
+	gdb_target_obs="i386-bsd-tdep.o i386-nbsd-tdep.o "
 	;;
 i[34567]86-*-openbsd*)
 	# Target: OpenBSD/i386
-	gdb_target_obs="i386-tdep.o i386.o i387-tdep.o i386-bsd-tdep.o \
-			i386-obsd-tdep.o obsd-tdep.o bsd-uthread.o \
-			solib-svr4.o"
+	gdb_target_obs="i386-bsd-tdep.o i386-obsd-tdep.o bsd-uthread.o"
 	;;
 i[34567]86-*-nto*)
 	# Target: Intel 386 running qnx6.
-	gdb_target_obs="i386-tdep.o i386.o i387-tdep.o solib-svr4.o \
+	gdb_target_obs="solib-svr4.o \
 			i386-nto-tdep.o nto-tdep.o"
 	build_gdbserver=yes
 	;;
 i[34567]86-*-solaris2* | x86_64-*-solaris2*)
 	# Target: Solaris x86_64
-	gdb_target_obs="i386-tdep.o i386.o i387-tdep.o amd64-tdep.o arch/amd64.o \
+	gdb_target_obs="${i386_tobjs} ${amd64_tobjs} \
 			 amd64-sol2-tdep.o i386-sol2-tdep.o sol2-tdep.o \
 			 solib-svr4.o"
 	;;
 i[34567]86-*-linux*)
 	# Target: Intel 386 running GNU/Linux
-	gdb_target_obs="i386-tdep.o i386.o i386-linux-tdep.o \
-			glibc-tdep.o i387-tdep.o \
+	gdb_target_obs="i386-linux-tdep.o \
+			glibc-tdep.o \
 			solib-svr4.o symfile-mem.o \
 			linux-tdep.o linux-record.o"
 	if test "x$enable_64_bit_bfd" = "xyes"; then
 	    # Target: GNU/Linux x86-64
-	    gdb_target_obs="amd64-tdep.o arch/amd64.o amd64-linux-tdep.o ${gdb_target_obs}"
+	    gdb_target_obs="amd64-linux-tdep.o ${gdb_target_obs}"
 	fi
 	build_gdbserver=yes
 	;;
 i[34567]86-*-gnu*)
 	# Target: Intel 386 running the GNU Hurd
-	gdb_target_obs="i386-tdep.o i386.o i387-tdep.o i386-gnu-tdep.o solib-svr4.o"
+	gdb_target_obs="i386-gnu-tdep.o solib-svr4.o"
 	;;
 i[34567]86-*-cygwin*)
 	# Target: Intel 386 running win32
-	gdb_target_obs="i386-tdep.o i386.o i386-cygwin-tdep.o i387-tdep.o \
-			windows-tdep.o"
+	gdb_target_obs="i386-cygwin-tdep.o windows-tdep.o"
 	build_gdbserver=yes
 	;;
 i[34567]86-*-mingw32*)
 	# Target: Intel 386 running win32
-	gdb_target_obs="i386-tdep.o i386.o i386-cygwin-tdep.o i387-tdep.o \
-			windows-tdep.o"
+	gdb_target_obs="i386-cygwin-tdep.o windows-tdep.o"
 	build_gdbserver=yes
 	;;
 i[34567]86-*-go32* | i[34567]86-*-msdosdjgpp*)
 	# Target: i386 running DJGPP/go32.
-	gdb_target_obs="i386-tdep.o i386.o i387-tdep.o i386-go32-tdep.o"
-	;;
-i[34567]86-*-*)
-	# Target: i386
-	gdb_target_obs="i386-tdep.o i386.o i387-tdep.o"
+	gdb_target_obs="i386-go32-tdep.o"
 	;;
 
 ia64-*-linux*)
 	# Target: Intel IA-64 running GNU/Linux
-	gdb_target_obs="ia64-tdep.o ia64-linux-tdep.o linux-tdep.o \
+	gdb_target_obs="ia64-linux-tdep.o linux-tdep.o \
 			solib-svr4.o symfile-mem.o"
 	build_gdbserver=yes
 	;;
 ia64-*-*vms*)
 	# Target: Intel IA-64 running OpenVMS
-	gdb_target_obs="ia64-tdep.o ia64-vms-tdep.o"
-	;;
-ia64*-*-*)
-	# Target: Intel IA-64
-	gdb_target_obs="ia64-tdep.o"
+	gdb_target_obs="ia64-vms-tdep.o"
 	;;
 
 iq2000-*-*)
@@ -332,11 +360,11 @@ m68*-*-linux*)
 	;;
 m68*-*-netbsd* | m68*-*-knetbsd*-gnu)
 	# Target: NetBSD/m68k
-	gdb_target_obs="m68k-tdep.o m68k-bsd-tdep.o solib-svr4.o"
+	gdb_target_obs="m68k-tdep.o m68k-bsd-tdep.o"
 	;;
 m68*-*-openbsd*)
 	# Target: OpenBSD/m68k
-	gdb_target_obs="m68k-tdep.o m68k-bsd-tdep.o solib-svr4.o"
+	gdb_target_obs="m68k-tdep.o m68k-bsd-tdep.o"
 	;;
 
 m88*-*-openbsd*)
@@ -371,17 +399,17 @@ mips*-*-linux*)
 	;;
 mips*-*-netbsd* | mips*-*-knetbsd*-gnu)
 	# Target: MIPS running NetBSD
-	gdb_target_obs="mips-tdep.o mips-nbsd-tdep.o solib-svr4.o nbsd-tdep.o"
+	gdb_target_obs="mips-tdep.o mips-nbsd-tdep.o"
 	gdb_sim=../sim/mips/libsim.a
 	;;
 mips*-*-freebsd*)
 	# Target: MIPS running FreeBSD
-	gdb_target_obs="mips-tdep.o mips-fbsd-tdep.o solib-svr4.o fbsd-tdep.o"
+	gdb_target_obs="mips-tdep.o mips-fbsd-tdep.o"
 	gdb_sim=../sim/mips/libsim.a
 	;;
 mips64*-*-openbsd*)
 	# Target: OpenBSD/mips64
-	gdb_target_obs="mips-tdep.o mips64-obsd-tdep.o obsd-tdep.o solib-svr4.o"
+	gdb_target_obs="mips-tdep.o mips64-obsd-tdep.o"
 	;;
 mips*-sde*-elf*)
 	# Target: MIPS SDE
@@ -434,21 +462,19 @@ nios2*-*-*)
 powerpc*-*-freebsd*)
 	# Target: FreeBSD/powerpc
 	gdb_target_obs="rs6000-tdep.o ppc-sysv-tdep.o ppc64-tdep.o \
-		        ppc-fbsd-tdep.o fbsd-tdep.o solib-svr4.o \
+		        ppc-fbsd-tdep.o \
 			ravenscar-thread.o ppc-ravenscar-thread.o"
 	;;
 
 powerpc-*-netbsd* | powerpc-*-knetbsd*-gnu)
 	# Target: NetBSD/powerpc
 	gdb_target_obs="rs6000-tdep.o ppc-sysv-tdep.o ppc-nbsd-tdep.o \
-			solib-svr4.o \
 			ravenscar-thread.o ppc-ravenscar-thread.o"
 	gdb_sim=../sim/ppc/libsim.a
 	;;
 powerpc-*-openbsd*)
 	# Target: OpenBSD/powerpc
 	gdb_target_obs="rs6000-tdep.o ppc-sysv-tdep.o ppc-obsd-tdep.o \
-			solib-svr4.o \
 			ravenscar-thread.o ppc-ravenscar-thread.o"
 	;;
 powerpc-*-aix* | rs6000-*-* | powerpc64-*-aix*)
@@ -516,12 +542,12 @@ sh*-*-linux*)
 	;;
 sh*-*-netbsdelf* | sh*-*-knetbsd*-gnu)
 	# Target: NetBSD/sh
-	gdb_target_obs="sh-tdep.o sh-nbsd-tdep.o solib-svr4.o"
+	gdb_target_obs="sh-tdep.o sh-nbsd-tdep.o"
 	gdb_sim=../sim/sh/libsim.a
 	;;
 sh*-*-openbsd*)
 	# Target: OpenBSD/sh
-	gdb_target_obs="sh-tdep.o sh64-tdep.o sh-nbsd-tdep.o solib-svr4.o"
+	gdb_target_obs="sh-tdep.o sh64-tdep.o sh-nbsd-tdep.o"
 	;;
 sh64-*-elf*)
 	# Target: Renesas/Super-H 64 bit with simulator
@@ -558,32 +584,30 @@ sparc64-*-linux*)
 sparc*-*-freebsd* | sparc*-*-kfreebsd*-gnu)
 	# Target: FreeBSD/sparc64
 	gdb_target_obs="sparc-tdep.o sparc64-tdep.o sparc64-fbsd-tdep.o \
-			fbsd-tdep.o solib-svr4.o \
 			ravenscar-thread.o sparc-ravenscar-thread.o"
 	;;
 sparc-*-netbsd* | sparc-*-knetbsd*-gnu)
 	# Target: NetBSD/sparc
-	gdb_target_obs="sparc-tdep.o sparc-nbsd-tdep.o nbsd-tdep.o \
-			solib-svr4.o \
+	gdb_target_obs="sparc-tdep.o sparc-nbsd-tdep.o \
 			ravenscar-thread.o sparc-ravenscar-thread.o"
 	;;
 sparc64-*-netbsd* | sparc64-*-knetbsd*-gnu)
 	# Target: NetBSD/sparc64
 	gdb_target_obs="sparc64-tdep.o sparc64-nbsd-tdep.o sparc-tdep.o \
-			sparc-nbsd-tdep.o nbsd-tdep.o solib-svr4.o \
+			sparc-nbsd-tdep.o \
 			ravenscar-thread.o sparc-ravenscar-thread.o"
 	;;
 sparc-*-openbsd*)
 	# Target: OpenBSD/sparc
 	gdb_target_obs="sparc-tdep.o sparc-nbsd-tdep.o sparc-obsd-tdep.o \
-			nbsd-tdep.o obsd-tdep.o bsd-uthread.o solib-svr4.o \
+			nbsd-tdep.o bsd-uthread.o \
 			ravenscar-thread.o sparc-ravenscar-thread.o"
 	;;
 sparc64-*-openbsd*)
 	# Target: OpenBSD/sparc64
 	gdb_target_obs="sparc64-tdep.o sparc64-nbsd-tdep.o sparc64-obsd-tdep.o \
 			sparc-tdep.o sparc-nbsd-tdep.o sparc-obsd-tdep.o \
-			nbsd-tdep.o obsd-tdep.o bsd-uthread.o solib-svr4.o \
+			nbsd-tdep.o bsd-uthread.o \
 			ravenscar-thread.o sparc-ravenscar-thread.o"
 	;;
 sparc-*-solaris2* | sparcv9-*-solaris2* | sparc64-*-solaris2*)
@@ -660,67 +684,63 @@ vax-*-*)
 
 x86_64-*-darwin*)
 	# Target: Darwin/x86-64
-	gdb_target_obs="amd64-tdep.o arch/amd64.o i386-tdep.o i386.o i387-tdep.o \
+	gdb_target_obs="${i386_tobjs} \
 			i386-darwin-tdep.o amd64-darwin-tdep.o \
                         solib-darwin.o"
 	;;
 
 x86_64-*-dicos*)
 	# Target: DICOS/x86-64
-	gdb_target_obs="amd64-tdep.o arch/amd64.o i386-tdep.o i386.o i387-tdep.o \
+	gdb_target_obs="${i386_tobjs} \
 			dicos-tdep.o i386-dicos-tdep.o amd64-dicos-tdep.o"
 	;;
 x86_64-*-elf*)
-	gdb_target_obs="amd64-tdep.o arch/amd64.o i386-tdep.o i386.o i387-tdep.o"
+	gdb_target_obs="${i386_tobjs}"
 	;;
 x86_64-*-linux*)
 	# Target: GNU/Linux x86-64
-	gdb_target_obs="amd64-tdep.o amd64-linux-tdep.o arch/amd64.o i386-tdep.o \
-			i387-tdep.o i386.o i386-linux-tdep.o glibc-tdep.o \
+	gdb_target_obs="amd64-linux-tdep.o ${i386_tobjs}  \
+			i386-linux-tdep.o glibc-tdep.o \
 			solib-svr4.o symfile-mem.o linux-tdep.o linux-record.o"
 	build_gdbserver=yes
 	;;
 x86_64-*-freebsd* | x86_64-*-kfreebsd*-gnu)
 	# Target: FreeBSD/amd64
-	gdb_target_obs="amd64-tdep.o arch/amd64.o amd64-fbsd-tdep.o i386-tdep.o \
-			i386.o i387-tdep.o i386-bsd-tdep.o i386-fbsd-tdep.o \
-			fbsd-tdep.o solib-svr4.o"
+	gdb_target_obs="amd64-fbsd-tdep.o ${i386_tobjs} \
+			i386-bsd-tdep.o i386-fbsd-tdep.o"
 	;;
 x86_64-*-mingw* | x86_64-*-cygwin*)
         # Target: MingW/amd64
-	gdb_target_obs="amd64-tdep.o arch/amd64.o amd64-windows-tdep.o \
-                        i386-tdep.o i386.o i386-cygwin-tdep.o i387-tdep.o \
+	gdb_target_obs="amd64-windows-tdep.o \
+                        ${i386_tobjs} i386-cygwin-tdep.o \
                         windows-tdep.o"
 	build_gdbserver=yes
         ;;
 x86_64-*-netbsd* | x86_64-*-knetbsd*-gnu)
 	# Target: NetBSD/amd64
-	gdb_target_obs="amd64-tdep.o arch/amd64.o amd64-nbsd-tdep.o i386-tdep.o \
-			i386.o i387-tdep.o nbsd-tdep.o solib-svr4.o"
+	gdb_target_obs="amd64-nbsd-tdep.o ${i386_tobjs}"
 	;;
 x86_64-*-openbsd*)
 	# Target: OpenBSD/amd64
-	gdb_target_obs="amd64-tdep.o arch/amd64.o amd64-obsd-tdep.o i386-tdep.o \
-			i387-tdep.o i386-bsd-tdep.o i386-obsd-tdep.o \
-			i386.o obsd-tdep.o bsd-uthread.o solib-svr4.o"
+	gdb_target_obs="amd64-obsd-tdep.o ${i386_tobjs} \
+			i386-bsd-tdep.o i386-obsd-tdep.o \
+			bsd-uthread.o"
 	;;
 x86_64-*-rtems*)
-	gdb_target_obs="amd64-tdep.o arch/amd64.o i386-tdep.o i386.o i387-tdep.o \
-			i386-bsd-tdep.o"
+	gdb_target_obs="${amd64_tobjs} ${i386_tobjs} i386-bsd-tdep.o"
 	;;
 xtensa*-*-linux*)	gdb_target=linux
 	# Target: GNU/Linux Xtensa
-	gdb_target_obs="xtensa-tdep.o xtensa-config.o xtensa-linux-tdep.o \
-			solib-svr4.o symfile-mem.o linux-tdep.o"
+	gdb_target_obs="xtensa-linux-tdep.o symfile-mem.o linux-tdep.o"
 	build_gdbserver=yes
 	;;
-xtensa*)
-	# Target: Tensilica Xtensa processors
-	gdb_target_obs="xtensa-tdep.o xtensa-config.o solib-svr4.o"
-	;;
 
 esac
 
+# Put them together.
+
+gdb_target_obs="${cpu_obs} ${os_obs} ${gdb_target_obs}"
+
 # map target onto default OS ABI
 
 case "${targ}" in

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [RFC] Replicate src dir in build dir
  2017-09-19 14:42 [RFC] Replicate src dir in build dir Yao Qi
  2017-09-19 20:44 ` Simon Marchi
  2017-09-20 11:26 ` Pedro Alves
@ 2017-10-08  3:24 ` Tom Tromey
  2017-10-08 21:04   ` Yao Qi
  2017-10-11  1:25   ` Yao Qi
  2 siblings, 2 replies; 20+ messages in thread
From: Tom Tromey @ 2017-10-08  3:24 UTC (permalink / raw)
  To: Yao Qi; +Cc: gdb-patches

>>>>> "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

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [RFC] Replicate src dir in build dir
  2017-10-08  3:24 ` Tom Tromey
@ 2017-10-08 21:04   ` Yao Qi
  2017-10-11  1:25   ` Yao Qi
  1 sibling, 0 replies; 20+ messages in thread
From: Yao Qi @ 2017-10-08 21:04 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On Sun, Oct 8, 2017 at 4:24 AM, Tom Tromey <tom@tromey.com> wrote:
>>>>>> "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.
>

Hi Tom,
Thanks for pointing them out.  I will look at them after
I am back to office (13th Oct).

> 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

-- 
Yao (齐尧)

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [RFC] Replicate src dir in build dir
  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
  1 sibling, 1 reply; 20+ messages in thread
From: Yao Qi @ 2017-10-11  1:25 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

[I happen to have some time today, so look into this
problem a little bit]

On Sun, Oct 8, 2017 at 4:24 AM, Tom Tromey <tom@tromey.com> wrote:
> 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

Right, I should add $(basename ) back, like the patch
below.

> 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.)

If I understand you correctly, depcomp has already
taken care of it.  See my reply to Simon's review.
https://sourceware.org/ml/gdb-patches/2017-09/msg00489.html

-- 
Yao (齐尧)

diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index da4095d..90ddc02 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -2952,8 +2952,8 @@ 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 $(@D)/$(DEPDIR)/$(@F).Tpo
-override POSTCOMPILE = @mv $(@D)/$(DEPDIR)/$(@F).Tpo \
+ -MF $(@D)/$(DEPDIR)/$(basename $(@F)).Tpo
+override POSTCOMPILE = @mv $(@D)/$(DEPDIR)/$(basename $(@F)).Tpo \
  $(@D)/$(DEPDIR)/$(@F).Po
 else
 override COMPILE.pre = source='$<' object='$@' libtool=no \

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [RFC] Replicate src dir in build dir
  2017-10-11  1:25   ` Yao Qi
@ 2017-10-11  3:26     ` Tom Tromey
  0 siblings, 0 replies; 20+ messages in thread
From: Tom Tromey @ 2017-10-11  3:26 UTC (permalink / raw)
  To: Yao Qi; +Cc: Tom Tromey, gdb-patches

>>>>> "Yao" == Yao Qi <qiyaoltc@gmail.com> writes:

Yao> Right, I should add $(basename ) back, like the patch
Yao> below.

Yeah.  Actually I wanted this to work so I sent a patch recently, which
is in now.

Yao> If I understand you correctly, depcomp has already
Yao> taken care of it.  See my reply to Simon's review.
Yao> https://sourceware.org/ml/gdb-patches/2017-09/msg00489.html

Yep, that's right; though it turned out that this code didn't work for
other reasons (nothing to do with your change); I fixed that as well.

Tom

^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2017-10-11  3:26 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-19 14:42 [RFC] Replicate src dir in build dir 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
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).