public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] gdbserver: Suffix generated C files with -generated
@ 2017-03-30  3:14 Simon Marchi
  2017-03-30  3:31 ` Simon Marchi
  0 siblings, 1 reply; 11+ messages in thread
From: Simon Marchi @ 2017-03-30  3:14 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

I noticed that there were some missing files in gdbserver's gitignore
(some generated register format .c files).  Of course the easy fix would
be to add those files to .gitignore, but I think we can do a better job,
so that we don't have to worry about adding generated files to
.gitignore or the clean Makefile target.

I suggest naming all generated source files -generated.c.  This way, we
can use a single rule in .gitignore and do a "rm -f *-generated.c" to
clean them up.

gdb/gdbserver/ChangeLog:

	* .gitignore: Remove generated files, replace with wildcard.
	* Makefile.in (OBS): Change version.o to version-generated.o.
	(GDBREPLAY_OBS): Likewise.
	(clean): Replace removal of generated files with wildcard.
	(version.c): Replace with...
	(version-generated.c): ...this.
	(xml-builtin.c): Replace with...
	(xml-builtin-generated.c): ...this.
	(%-ipa.o: %-generated.c, %.o: %-generated.c): New rules.
	(%.c: *regformats*): Replace with...
	(%-generated.c: *regformats*): ...this.
	* configure.ac: Update xml-builtin.o to xml-builtin-generated.o.
	* configure: Re-generate.
---
 gdb/gdbserver/.gitignore   | 18 +-----------
 gdb/gdbserver/Makefile.in  | 72 ++++++++++++++--------------------------------
 gdb/gdbserver/configure    |  8 +++---
 gdb/gdbserver/configure.ac |  2 +-
 4 files changed, 28 insertions(+), 72 deletions(-)

diff --git a/gdb/gdbserver/.gitignore b/gdb/gdbserver/.gitignore
index 66ce8439e5..fef0d01b14 100644
--- a/gdb/gdbserver/.gitignore
+++ b/gdb/gdbserver/.gitignore
@@ -7,20 +7,4 @@ libinproctrace.so
 build-gnulib-gdbserver
 build-libiberty-gdbserver
 
-amd64-avx-linux.c
-amd64-avx-mpx-linux.c
-amd64-avx512-linux.c
-amd64-linux.c
-amd64-mpx-linux.c
-i386-avx-linux.c
-i386-avx-mpx-linux.c
-i386-avx512-linux.c
-i386-linux.c
-i386-mmx-linux.c
-i386-mpx-linux.c
-reg-*.c
-version.c
-x32-avx-linux.c
-x32-avx512-linux.c
-x32-linux.c
-xml-builtin.c
+*-generated.c
diff --git a/gdb/gdbserver/Makefile.in b/gdb/gdbserver/Makefile.in
index 9935012eb8..b70370d979 100644
--- a/gdb/gdbserver/Makefile.in
+++ b/gdb/gdbserver/Makefile.in
@@ -264,14 +264,14 @@ OBS = \
 	tracepoint.o \
 	utils.o \
 	vec.o \
-	version.o \
+	version-generated.o \
 	waitstatus.o \
 	xml-utils.o \
 	$(DEPFILES) \
 	$(LIBOBJS) \
 	$(XML_BUILTIN)
 
-GDBREPLAY_OBS = gdbreplay.o version.o
+GDBREPLAY_OBS = gdbreplay.o version-generated.o
 GDBSERVER_LIBS = @GDBSERVER_LIBS@
 XM_CLIBS = @LIBS@
 CDEPS = $(srcdir)/proc-service.list
@@ -413,47 +413,10 @@ tags: TAGS
 
 clean:
 	rm -f *.o ${ADD_FILES} *~
-	rm -f version.c
 	rm -f gdbserver$(EXEEXT) gdbreplay$(EXEEXT) core make.log
 	rm -f $(IPA_LIB)
-	rm -f aarch64.c
-	rm -f reg-arm.c reg-bfin.c i386.c reg-ia64.c reg-m32r.c reg-m68k.c
-	rm -f reg-sh.c reg-sparc.c reg-spu.c amd64.c i386-linux.c
-	rm -f reg-cris.c reg-crisv32.c amd64-linux.c reg-xtensa.c
-	rm -f reg-tilegx.c reg-tilegx32.c
-	rm -f arm-with-iwmmxt.c
-	rm -f arm-with-vfpv2.c arm-with-vfpv3.c arm-with-neon.c
-	rm -f mips-linux.c mips-dsp-linux.c
-	rm -f mips64-linux.c mips64-dsp-linux.c
-	rm -f nios2-linux.c
-	rm -f powerpc-32.c powerpc-32l.c powerpc-64l.c powerpc-e500l.c
-	rm -f powerpc-altivec32l.c powerpc-cell32l.c powerpc-vsx32l.c
-	rm -f powerpc-altivec64l.c powerpc-cell64l.c powerpc-vsx64l.c
-	rm -f powerpc-isa205-32l.c powerpc-isa205-64l.c
-	rm -f powerpc-isa205-altivec32l.c powerpc-isa205-vsx32l.c powerpc-isa205-altivec64l.c
-	rm -f powerpc-isa205-vsx64l.c
-	rm -f s390-linux32.c s390-linux64.c s390x-linux64.c
-	rm -f s390-linux32v1.c s390-linux32v2.c s390-linux64v1.c
-	rm -f s390-linux64v2.c s390x-linux64v1.c s390x-linux64v2.c
-	rm -f s390-te-linux64.c s390x-te-linux64.c
-	rm -f s390-vx-linux64.c s390x-vx-linux64.c
-	rm -f s390-tevx-linux64.c s390x-tevx-linux64.c
-	rm -f tic6x-c64xp-linux.c tic6x-c64x-linux.c tic6x-c62x-linux.c
-	rm -f xml-builtin.c stamp-xml
-	rm -f i386-avx.c i386-avx-linux.c
-	rm -f i386-mpx.c i386-mpx-linux.c
-	rm -f i386-avx-mpx.c i386-avx-mpx-linux.c
-	rm -f i386-avx-avx512.c i386-avx-avx512-linux.c
-	rm -f i386-avx-mpx-avx512-pku.c i386-avx-mpx-avx512-pku-linux.c
-	rm -f amd64-avx.c amd64-avx-linux.c
-	rm -f amd64-mpx.c amd64-mpx-linux.c
-	rm -f amd64-avx-mpx.c amd64-avx-mpx-linux.c
-	rm -f amd64-avx-avx512.c amd64-avx-avx512-linux.c
-	rm -f amd64-avx-mpx-avx512-pku.c amd64-avx-mpx-avx512-pku-linux.c
-	rm -f i386-mmx.c i386-mmx-linux.c
-	rm -f x32.c x32-linux.c
-	rm -f x32-avx.c x32-avx-linux.c
-	rm -f x32-avx-avx512.c x32-avx-avx512-linux.c
+	rm -f *-generated.c
+	rm -f stamp-xml
 	@$(MAKE) $(FLAGS_TO_PASS) DO=$@ "DODIRS=$(SUBDIRS)" subdir_do
 
 maintainer-clean realclean distclean: clean
@@ -504,15 +467,15 @@ am--refresh:
 
 force:
 
-version.c: Makefile $(srcdir)/../version.in $(srcdir)/../../bfd/version.h $(srcdir)/../common/create-version.sh
+version-generated.c: Makefile $(srcdir)/../version.in $(srcdir)/../../bfd/version.h $(srcdir)/../common/create-version.sh
 	$(SHELL) $(srcdir)/../common/create-version.sh $(srcdir)/.. \
-	    $(host_alias) $(target_alias) version.c
+	    $(host_alias) $(target_alias) $@
 
-xml-builtin.c: stamp-xml; @true
+xml-builtin-generated.c: stamp-xml; @true
 stamp-xml: $(XML_DIR)/feature_to_c.sh Makefile $(XML_FILES)
 	rm -f xml-builtin.tmp
 	$(SHELL) $(XML_DIR)/feature_to_c.sh xml-builtin.tmp $(XML_FILES)
-	$(SHELL) $(srcdir)/../../move-if-change xml-builtin.tmp xml-builtin.c
+	$(SHELL) $(srcdir)/../../move-if-change xml-builtin.tmp xml-builtin-generated.c
 	echo stamp > stamp-xml
 
 .PRECIOUS: xml-builtin.c
@@ -552,6 +515,10 @@ ax.o: ax.c
 
 # Rules for objects that go in the in-process agent.
 
+%-ipa.o: %-generated.c
+	$(IPAGENT_COMPILE) $<
+	$(POSTCOMPILE)
+
 %-ipa.o: %.c
 	$(IPAGENT_COMPILE) $<
 	$(POSTCOMPILE)
@@ -573,6 +540,10 @@ ax.o: ax.c
 
 # Rules for objects that go in the gdbserver binary.
 
+%.o: %-generated.c
+	$(COMPILE) $<
+	$(POSTCOMPILE)
+
 %.o: %.c
 	$(COMPILE) $<
 	$(POSTCOMPILE)
@@ -593,18 +564,19 @@ ax.o: ax.c
 	$(COMPILE) $<
 	$(POSTCOMPILE)
 
-# Rules for register format descriptions.
+# Rules for register format descriptions.  Suffix destination files with
+# -generated to identify and clean them easily.
 
-%.c: ../regformats/%.dat | $(regdat_sh)
+%-generated.c: ../regformats/%.dat | $(regdat_sh)
 	$(SHELL) $(regdat_sh) $< $@
 
-%.c: ../regformats/arm/%.dat | $(regdat_sh)
+%-generated.c: ../regformats/arm/%.dat | $(regdat_sh)
 	$(SHELL) $(regdat_sh) $< $@
 
-%.c: ../regformats/i386/%.dat | $(regdat_sh)
+%-generated.c: ../regformats/i386/%.dat | $(regdat_sh)
 	$(SHELL) $(regdat_sh) $< $@
 
-%.c: ../regformats/rs6000/%.dat | $(regdat_sh)
+%-generated.c: ../regformats/rs6000/%.dat | $(regdat_sh)
 	$(SHELL) $(regdat_sh) $< $@
 
 #
diff --git a/gdb/gdbserver/configure b/gdb/gdbserver/configure
index 6ae486539f..44a44f4712 100755
--- a/gdb/gdbserver/configure
+++ b/gdb/gdbserver/configure
@@ -7498,9 +7498,9 @@ _ACEOF
 fi
 
 
-# See if <sys/user.h> supports the %fs_base and %gs_base amd64 segment
-# registers.  Older amd64 Linux's don't have the fs_base and gs_base
-# members of `struct user_regs_struct'.
+# See if <sys/user.h> supports the %fs_base and %gs_bas amd64 segment registers.
+# Older amd64 Linux's don't have the fs_base and gs_base members of
+# `struct user_regs_struct'.
 ac_fn_c_check_member "$LINENO" "struct user_regs_struct" "fs_base" "ac_cv_member_struct_user_regs_struct_fs_base" "#include <sys/user.h>
 "
 if test "x$ac_cv_member_struct_user_regs_struct_fs_base" = x""yes; then :
@@ -8252,7 +8252,7 @@ $as_echo "#define USE_LIBTHREAD_DB_DIRECTLY 1" >>confdefs.h
 fi
 
 if test "$srv_xmlfiles" != ""; then
-  srv_xmlbuiltin="xml-builtin.o"
+  srv_xmlbuiltin="xml-builtin-generated.o"
 
 $as_echo "#define USE_XML 1" >>confdefs.h
 
diff --git a/gdb/gdbserver/configure.ac b/gdb/gdbserver/configure.ac
index 4ea7913c98..23ea8d5d45 100644
--- a/gdb/gdbserver/configure.ac
+++ b/gdb/gdbserver/configure.ac
@@ -383,7 +383,7 @@ if test "$srv_libs" != "" -a "$srv_libs" != "-ldl"; then
 fi
 
 if test "$srv_xmlfiles" != ""; then
-  srv_xmlbuiltin="xml-builtin.o"
+  srv_xmlbuiltin="xml-builtin-generated.o"
   AC_DEFINE(USE_XML, 1, [Define if an XML target description is available.])
 
   tmp_xmlfiles=$srv_xmlfiles
-- 
2.12.1

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

* Re: [PATCH] gdbserver: Suffix generated C files with -generated
  2017-03-30  3:14 [PATCH] gdbserver: Suffix generated C files with -generated Simon Marchi
@ 2017-03-30  3:31 ` Simon Marchi
  2017-03-31 12:24   ` Pedro Alves
  0 siblings, 1 reply; 11+ messages in thread
From: Simon Marchi @ 2017-03-30  3:31 UTC (permalink / raw)
  To: gdb-patches

On 2017-03-29 23:14, Simon Marchi wrote:
> diff --git a/gdb/gdbserver/configure b/gdb/gdbserver/configure
> index 6ae486539f..44a44f4712 100755
> --- a/gdb/gdbserver/configure
> +++ b/gdb/gdbserver/configure
> @@ -7498,9 +7498,9 @@ _ACEOF
>  fi
> 
> 
> -# See if <sys/user.h> supports the %fs_base and %gs_base amd64 segment
> -# registers.  Older amd64 Linux's don't have the fs_base and gs_base
> -# members of `struct user_regs_struct'.
> +# See if <sys/user.h> supports the %fs_base and %gs_bas amd64 segment
> registers.
> +# Older amd64 Linux's don't have the fs_base and gs_base members of
> +# `struct user_regs_struct'.
>  ac_fn_c_check_member "$LINENO" "struct user_regs_struct" "fs_base"
> "ac_cv_member_struct_user_regs_struct_fs_base" "#include <sys/user.h>
>  "
>  if test "x$ac_cv_member_struct_user_regs_struct_fs_base" = x""yes; 
> then :
> @@ -8252,7 +8252,7 @@ $as_echo "#define USE_LIBTHREAD_DB_DIRECTLY 1"
> >>confdefs.h
>  fi
> 
>  if test "$srv_xmlfiles" != ""; then
> -  srv_xmlbuiltin="xml-builtin.o"
> +  srv_xmlbuiltin="xml-builtin-generated.o"

Hmm actually we don't need to rename this, the other .o files are not 
named -generated.  You can forget changes to configure/configure.ac (I 
removed them locally).

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

* Re: [PATCH] gdbserver: Suffix generated C files with -generated
  2017-03-30  3:31 ` Simon Marchi
@ 2017-03-31 12:24   ` Pedro Alves
  2017-03-31 13:35     ` Simon Marchi
  2017-03-31 14:56     ` [PATCH v2] " Simon Marchi
  0 siblings, 2 replies; 11+ messages in thread
From: Pedro Alves @ 2017-03-31 12:24 UTC (permalink / raw)
  To: Simon Marchi, gdb-patches

Hi Simon,

On 03/30/2017 04:31 AM, Simon Marchi wrote:

>> @@ -8252,7 +8252,7 @@ $as_echo "#define USE_LIBTHREAD_DB_DIRECTLY 1"
>> >>confdefs.h
>>  fi
>>
>>  if test "$srv_xmlfiles" != ""; then
>> -  srv_xmlbuiltin="xml-builtin.o"
>> +  srv_xmlbuiltin="xml-builtin-generated.o"
> 
> Hmm actually we don't need to rename this, the other .o files are not
> named -generated.  You can forget changes to configure/configure.ac (I
> removed them locally).

I'm confused on what the result will be.  The patch had this in Makefile.in,
for example:

-	version.o \
+	version-generated.o \

Can you post the updated patch?

Thanks,
Pedro Alves

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

* Re: [PATCH] gdbserver: Suffix generated C files with -generated
  2017-03-31 12:24   ` Pedro Alves
@ 2017-03-31 13:35     ` Simon Marchi
  2017-03-31 14:56     ` [PATCH v2] " Simon Marchi
  1 sibling, 0 replies; 11+ messages in thread
From: Simon Marchi @ 2017-03-31 13:35 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches

On 2017-03-31 08:23, Pedro Alves wrote:
> Hi Simon,
> 
> On 03/30/2017 04:31 AM, Simon Marchi wrote:
> 
>>> @@ -8252,7 +8252,7 @@ $as_echo "#define USE_LIBTHREAD_DB_DIRECTLY 1"
>>> >>confdefs.h
>>>  fi
>>> 
>>>  if test "$srv_xmlfiles" != ""; then
>>> -  srv_xmlbuiltin="xml-builtin.o"
>>> +  srv_xmlbuiltin="xml-builtin-generated.o"
>> 
>> Hmm actually we don't need to rename this, the other .o files are not
>> named -generated.  You can forget changes to configure/configure.ac (I
>> removed them locally).
> 
> I'm confused on what the result will be.  The patch had this in 
> Makefile.in,
> for example:
> 
> -	version.o \
> +	version-generated.o \
> 
> Can you post the updated patch?

Ah, yes, same mistake with that one.  It probably shouldn't change as 
well (although it would still work).

To explain the mistake, I first started changing the pattern to have:

   foo-generated.c -> foo-generated.o

But then realized I would have to change everything in configure.srv, 
and that would be ugly.  So I decided to add the "%.o: %-generated.c" 
and "%-ipa.o: %-generated.c" rules instead, which allows keeping the 
change to a minimum.  I however forgot to change version-generated.o 
back to version.o and xml-builtin-generated.o to xml-builtin.o.  It 
still works, because they get picked up by the "%.o: %.c" rule.

I'll post the updated patch.

Simon

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

* [PATCH v2] gdbserver: Suffix generated C files with -generated
  2017-03-31 12:24   ` Pedro Alves
  2017-03-31 13:35     ` Simon Marchi
@ 2017-03-31 14:56     ` Simon Marchi
  2017-03-31 15:13       ` Pedro Alves
  1 sibling, 1 reply; 11+ messages in thread
From: Simon Marchi @ 2017-03-31 14:56 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

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

I noticed that there were some missing files in gdbserver's gitignore
(some generated register format .c files).  Of course the easy fix would
be to add those files to .gitignore, but I think we can do a better job,
so that we don't have to worry about adding generated files to
.gitignore or the clean Makefile target.

I suggest naming all generated source files -generated.c.  This way, we
can use a single rule in .gitignore and do a "rm -f *-generated.c" to
clean them up.

New in v2:

  - Don't rename version.o and xml-builtin.o

gdb/gdbserver/ChangeLog:

	* .gitignore: Remove generated files, replace with wildcard.
	* (clean): Replace removal of generated files with wildcard.
	(version.c): Replace with...
	(version-generated.c): ...this.
	(xml-builtin.c): Replace with...
	(xml-builtin-generated.c): ...this.
	(%-ipa.o: %-generated.c, %.o: %-generated.c): New rules.
	(%.c: *regformats*): Replace with...
	(%-generated.c: *regformats*): ...this.
---
 gdb/gdbserver/.gitignore  | 18 +------------
 gdb/gdbserver/Makefile.in | 68 ++++++++++++++---------------------------------
 2 files changed, 21 insertions(+), 65 deletions(-)

diff --git a/gdb/gdbserver/.gitignore b/gdb/gdbserver/.gitignore
index 66ce8439e5..fef0d01b14 100644
--- a/gdb/gdbserver/.gitignore
+++ b/gdb/gdbserver/.gitignore
@@ -7,20 +7,4 @@ libinproctrace.so
 build-gnulib-gdbserver
 build-libiberty-gdbserver
 
-amd64-avx-linux.c
-amd64-avx-mpx-linux.c
-amd64-avx512-linux.c
-amd64-linux.c
-amd64-mpx-linux.c
-i386-avx-linux.c
-i386-avx-mpx-linux.c
-i386-avx512-linux.c
-i386-linux.c
-i386-mmx-linux.c
-i386-mpx-linux.c
-reg-*.c
-version.c
-x32-avx-linux.c
-x32-avx512-linux.c
-x32-linux.c
-xml-builtin.c
+*-generated.c
diff --git a/gdb/gdbserver/Makefile.in b/gdb/gdbserver/Makefile.in
index 9935012eb8..6af7c402f8 100644
--- a/gdb/gdbserver/Makefile.in
+++ b/gdb/gdbserver/Makefile.in
@@ -413,47 +413,10 @@ tags: TAGS
 
 clean:
 	rm -f *.o ${ADD_FILES} *~
-	rm -f version.c
 	rm -f gdbserver$(EXEEXT) gdbreplay$(EXEEXT) core make.log
 	rm -f $(IPA_LIB)
-	rm -f aarch64.c
-	rm -f reg-arm.c reg-bfin.c i386.c reg-ia64.c reg-m32r.c reg-m68k.c
-	rm -f reg-sh.c reg-sparc.c reg-spu.c amd64.c i386-linux.c
-	rm -f reg-cris.c reg-crisv32.c amd64-linux.c reg-xtensa.c
-	rm -f reg-tilegx.c reg-tilegx32.c
-	rm -f arm-with-iwmmxt.c
-	rm -f arm-with-vfpv2.c arm-with-vfpv3.c arm-with-neon.c
-	rm -f mips-linux.c mips-dsp-linux.c
-	rm -f mips64-linux.c mips64-dsp-linux.c
-	rm -f nios2-linux.c
-	rm -f powerpc-32.c powerpc-32l.c powerpc-64l.c powerpc-e500l.c
-	rm -f powerpc-altivec32l.c powerpc-cell32l.c powerpc-vsx32l.c
-	rm -f powerpc-altivec64l.c powerpc-cell64l.c powerpc-vsx64l.c
-	rm -f powerpc-isa205-32l.c powerpc-isa205-64l.c
-	rm -f powerpc-isa205-altivec32l.c powerpc-isa205-vsx32l.c powerpc-isa205-altivec64l.c
-	rm -f powerpc-isa205-vsx64l.c
-	rm -f s390-linux32.c s390-linux64.c s390x-linux64.c
-	rm -f s390-linux32v1.c s390-linux32v2.c s390-linux64v1.c
-	rm -f s390-linux64v2.c s390x-linux64v1.c s390x-linux64v2.c
-	rm -f s390-te-linux64.c s390x-te-linux64.c
-	rm -f s390-vx-linux64.c s390x-vx-linux64.c
-	rm -f s390-tevx-linux64.c s390x-tevx-linux64.c
-	rm -f tic6x-c64xp-linux.c tic6x-c64x-linux.c tic6x-c62x-linux.c
-	rm -f xml-builtin.c stamp-xml
-	rm -f i386-avx.c i386-avx-linux.c
-	rm -f i386-mpx.c i386-mpx-linux.c
-	rm -f i386-avx-mpx.c i386-avx-mpx-linux.c
-	rm -f i386-avx-avx512.c i386-avx-avx512-linux.c
-	rm -f i386-avx-mpx-avx512-pku.c i386-avx-mpx-avx512-pku-linux.c
-	rm -f amd64-avx.c amd64-avx-linux.c
-	rm -f amd64-mpx.c amd64-mpx-linux.c
-	rm -f amd64-avx-mpx.c amd64-avx-mpx-linux.c
-	rm -f amd64-avx-avx512.c amd64-avx-avx512-linux.c
-	rm -f amd64-avx-mpx-avx512-pku.c amd64-avx-mpx-avx512-pku-linux.c
-	rm -f i386-mmx.c i386-mmx-linux.c
-	rm -f x32.c x32-linux.c
-	rm -f x32-avx.c x32-avx-linux.c
-	rm -f x32-avx-avx512.c x32-avx-avx512-linux.c
+	rm -f *-generated.c
+	rm -f stamp-xml
 	@$(MAKE) $(FLAGS_TO_PASS) DO=$@ "DODIRS=$(SUBDIRS)" subdir_do
 
 maintainer-clean realclean distclean: clean
@@ -504,15 +467,15 @@ am--refresh:
 
 force:
 
-version.c: Makefile $(srcdir)/../version.in $(srcdir)/../../bfd/version.h $(srcdir)/../common/create-version.sh
+version-generated.c: Makefile $(srcdir)/../version.in $(srcdir)/../../bfd/version.h $(srcdir)/../common/create-version.sh
 	$(SHELL) $(srcdir)/../common/create-version.sh $(srcdir)/.. \
-	    $(host_alias) $(target_alias) version.c
+	    $(host_alias) $(target_alias) $@
 
-xml-builtin.c: stamp-xml; @true
+xml-builtin-generated.c: stamp-xml; @true
 stamp-xml: $(XML_DIR)/feature_to_c.sh Makefile $(XML_FILES)
 	rm -f xml-builtin.tmp
 	$(SHELL) $(XML_DIR)/feature_to_c.sh xml-builtin.tmp $(XML_FILES)
-	$(SHELL) $(srcdir)/../../move-if-change xml-builtin.tmp xml-builtin.c
+	$(SHELL) $(srcdir)/../../move-if-change xml-builtin.tmp xml-builtin-generated.c
 	echo stamp > stamp-xml
 
 .PRECIOUS: xml-builtin.c
@@ -552,6 +515,10 @@ ax.o: ax.c
 
 # Rules for objects that go in the in-process agent.
 
+%-ipa.o: %-generated.c
+	$(IPAGENT_COMPILE) $<
+	$(POSTCOMPILE)
+
 %-ipa.o: %.c
 	$(IPAGENT_COMPILE) $<
 	$(POSTCOMPILE)
@@ -573,6 +540,10 @@ ax.o: ax.c
 
 # Rules for objects that go in the gdbserver binary.
 
+%.o: %-generated.c
+	$(COMPILE) $<
+	$(POSTCOMPILE)
+
 %.o: %.c
 	$(COMPILE) $<
 	$(POSTCOMPILE)
@@ -593,18 +564,19 @@ ax.o: ax.c
 	$(COMPILE) $<
 	$(POSTCOMPILE)
 
-# Rules for register format descriptions.
+# Rules for register format descriptions.  Suffix destination files with
+# -generated to identify and clean them easily.
 
-%.c: ../regformats/%.dat | $(regdat_sh)
+%-generated.c: ../regformats/%.dat | $(regdat_sh)
 	$(SHELL) $(regdat_sh) $< $@
 
-%.c: ../regformats/arm/%.dat | $(regdat_sh)
+%-generated.c: ../regformats/arm/%.dat | $(regdat_sh)
 	$(SHELL) $(regdat_sh) $< $@
 
-%.c: ../regformats/i386/%.dat | $(regdat_sh)
+%-generated.c: ../regformats/i386/%.dat | $(regdat_sh)
 	$(SHELL) $(regdat_sh) $< $@
 
-%.c: ../regformats/rs6000/%.dat | $(regdat_sh)
+%-generated.c: ../regformats/rs6000/%.dat | $(regdat_sh)
 	$(SHELL) $(regdat_sh) $< $@
 
 #
-- 
2.11.0

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

* Re: [PATCH v2] gdbserver: Suffix generated C files with -generated
  2017-03-31 14:56     ` [PATCH v2] " Simon Marchi
@ 2017-03-31 15:13       ` Pedro Alves
  2017-03-31 15:40         ` Simon Marchi
  0 siblings, 1 reply; 11+ messages in thread
From: Pedro Alves @ 2017-03-31 15:13 UTC (permalink / raw)
  To: Simon Marchi, gdb-patches; +Cc: Simon Marchi

On 03/31/2017 03:55 PM, Simon Marchi wrote:
> From: Simon Marchi <simon.marchi@polymtl.ca>
> 
> I noticed that there were some missing files in gdbserver's gitignore
> (some generated register format .c files).  Of course the easy fix would
> be to add those files to .gitignore, but I think we can do a better job,
> so that we don't have to worry about adding generated files to
> .gitignore or the clean Makefile target.
> 
> I suggest naming all generated source files -generated.c.  This way, we
> can use a single rule in .gitignore and do a "rm -f *-generated.c" to
> clean them up.
> 
> New in v2:
> 
>   - Don't rename version.o and xml-builtin.o
> 
> gdb/gdbserver/ChangeLog:
> 
> 	* .gitignore: Remove generated files, replace with wildcard.
> 	* (clean): Replace removal of generated files with wildcard.
> 	(version.c): Replace with...
> 	(version-generated.c): ...this.
> 	(xml-builtin.c): Replace with...
> 	(xml-builtin-generated.c): ...this.
> 	(%-ipa.o: %-generated.c, %.o: %-generated.c): New rules.
> 	(%.c: *regformats*): Replace with...
> 	(%-generated.c: *regformats*): ...this.

OK.

Thanks,
Pedro Alves

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

* Re: [PATCH v2] gdbserver: Suffix generated C files with -generated
  2017-03-31 15:13       ` Pedro Alves
@ 2017-03-31 15:40         ` Simon Marchi
  2017-03-31 18:46           ` Simon Marchi
  0 siblings, 1 reply; 11+ messages in thread
From: Simon Marchi @ 2017-03-31 15:40 UTC (permalink / raw)
  To: Pedro Alves; +Cc: Simon Marchi, gdb-patches

On 2017-03-31 11:12, Pedro Alves wrote:
> On 03/31/2017 03:55 PM, Simon Marchi wrote:
>> From: Simon Marchi <simon.marchi@polymtl.ca>
>> 
>> I noticed that there were some missing files in gdbserver's gitignore
>> (some generated register format .c files).  Of course the easy fix 
>> would
>> be to add those files to .gitignore, but I think we can do a better 
>> job,
>> so that we don't have to worry about adding generated files to
>> .gitignore or the clean Makefile target.
>> 
>> I suggest naming all generated source files -generated.c.  This way, 
>> we
>> can use a single rule in .gitignore and do a "rm -f *-generated.c" to
>> clean them up.
>> 
>> New in v2:
>> 
>>   - Don't rename version.o and xml-builtin.o
>> 
>> gdb/gdbserver/ChangeLog:
>> 
>> 	* .gitignore: Remove generated files, replace with wildcard.
>> 	* (clean): Replace removal of generated files with wildcard.
>> 	(version.c): Replace with...
>> 	(version-generated.c): ...this.
>> 	(xml-builtin.c): Replace with...
>> 	(xml-builtin-generated.c): ...this.
>> 	(%-ipa.o: %-generated.c, %.o: %-generated.c): New rules.
>> 	(%.c: *regformats*): Replace with...
>> 	(%-generated.c: *regformats*): ...this.
> 
> OK.

Thanks, pushed.

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

* Re: [PATCH v2] gdbserver: Suffix generated C files with -generated
  2017-03-31 15:40         ` Simon Marchi
@ 2017-03-31 18:46           ` Simon Marchi
  2017-03-31 19:39             ` Simon Marchi
  0 siblings, 1 reply; 11+ messages in thread
From: Simon Marchi @ 2017-03-31 18:46 UTC (permalink / raw)
  To: Pedro Alves; +Cc: Simon Marchi, gdb-patches

On 2017-03-31 11:40, Simon Marchi wrote:
> On 2017-03-31 11:12, Pedro Alves wrote:
>> On 03/31/2017 03:55 PM, Simon Marchi wrote:
>>> From: Simon Marchi <simon.marchi@polymtl.ca>
>>> 
>>> I noticed that there were some missing files in gdbserver's gitignore
>>> (some generated register format .c files).  Of course the easy fix 
>>> would
>>> be to add those files to .gitignore, but I think we can do a better 
>>> job,
>>> so that we don't have to worry about adding generated files to
>>> .gitignore or the clean Makefile target.
>>> 
>>> I suggest naming all generated source files -generated.c.  This way, 
>>> we
>>> can use a single rule in .gitignore and do a "rm -f *-generated.c" to
>>> clean them up.
>>> 
>>> New in v2:
>>> 
>>>   - Don't rename version.o and xml-builtin.o
>>> 
>>> gdb/gdbserver/ChangeLog:
>>> 
>>> 	* .gitignore: Remove generated files, replace with wildcard.
>>> 	* (clean): Replace removal of generated files with wildcard.
>>> 	(version.c): Replace with...
>>> 	(version-generated.c): ...this.
>>> 	(xml-builtin.c): Replace with...
>>> 	(xml-builtin-generated.c): ...this.
>>> 	(%-ipa.o: %-generated.c, %.o: %-generated.c): New rules.
>>> 	(%.c: *regformats*): Replace with...
>>> 	(%-generated.c: *regformats*): ...this.
>> 
>> OK.
> 
> Thanks, pushed.

Note that when updating past this commit and rebuilding, or in general 
hopping back and forth between branches that have this commit and 
branches that don't and rebuilding, you may stumble on errors like:

   make: *** No rule to make target `version.c', needed by `version.o'.  
Stop.

It's the same issue some people had when environ.c was moved to 
common/environ.c, and it will happen every time we move a source file.  
The reason is the leftover dependency file in .deps, containing 
something like:

   version.o: version.c

These files are automatically generated by gcc and state all the files 
that went into creating version.o during the last build.  That rule 
states that version.c should exist when for version.o to be built, and 
that version.o should be rebuilt if version.c is more recent.  But 
version.c was moved and no longer exists, hence the error.

One thing I see we could do to mitigate the problem is clear the .deps 
directory when doing a "make clean".  After all, when doing a clean, all 
objects are deleted and are going to be rebuilt, so we don't care about 
the dependencies anymore.  So if somebody stumbles on that problem, 
there's a chance they'll try to clean and build again, which would fix 
the problem.

Do you have any better idea?

Simon

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

* Re: [PATCH v2] gdbserver: Suffix generated C files with -generated
  2017-03-31 18:46           ` Simon Marchi
@ 2017-03-31 19:39             ` Simon Marchi
  2017-04-04 10:44               ` Pedro Alves
  0 siblings, 1 reply; 11+ messages in thread
From: Simon Marchi @ 2017-03-31 19:39 UTC (permalink / raw)
  To: Pedro Alves; +Cc: Simon Marchi, gdb-patches

On 2017-03-31 14:46, Simon Marchi wrote:
> Note that when updating past this commit and rebuilding, or in general
> hopping back and forth between branches that have this commit and
> branches that don't and rebuilding, you may stumble on errors like:
> 
>   make: *** No rule to make target `version.c', needed by `version.o'.  
> Stop.
> 
> It's the same issue some people had when environ.c was moved to
> common/environ.c, and it will happen every time we move a source file.
>  The reason is the leftover dependency file in .deps, containing
> something like:
> 
>   version.o: version.c
> 
> These files are automatically generated by gcc and state all the files
> that went into creating version.o during the last build.  That rule
> states that version.c should exist when for version.o to be built, and
> that version.o should be rebuilt if version.c is more recent.  But
> version.c was moved and no longer exists, hence the error.
> 
> One thing I see we could do to mitigate the problem is clear the .deps
> directory when doing a "make clean".  After all, when doing a clean,
> all objects are deleted and are going to be rebuilt, so we don't care
> about the dependencies anymore.  So if somebody stumbles on that
> problem, there's a chance they'll try to clean and build again, which
> would fix the problem.
> 
> Do you have any better idea?
> 
> Simon

Huh, I've just noticed that gdb does this already:

   rm -f $(DEPDIR)/*

which translates to:

   rm -f .deps/*

So I guess it'd make sense to do it as well in gdbserver.

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

* Re: [PATCH v2] gdbserver: Suffix generated C files with -generated
  2017-03-31 19:39             ` Simon Marchi
@ 2017-04-04 10:44               ` Pedro Alves
  2017-04-04 14:52                 ` [PATCH pushed] gdbserver: Clear .deps on clean Simon Marchi
  0 siblings, 1 reply; 11+ messages in thread
From: Pedro Alves @ 2017-04-04 10:44 UTC (permalink / raw)
  To: Simon Marchi; +Cc: Simon Marchi, gdb-patches

On 03/31/2017 08:39 PM, Simon Marchi wrote:

>> Do you have any better idea?

Not off hand.

> Huh, I've just noticed that gdb does this already:
> 
>   rm -f $(DEPDIR)/*
> 
> which translates to:
> 
>   rm -f .deps/*
> 
> So I guess it'd make sense to do it as well in gdbserver.

Go for it.

Thanks,
Pedro Alves

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

* [PATCH pushed] gdbserver: Clear .deps on clean
  2017-04-04 10:44               ` Pedro Alves
@ 2017-04-04 14:52                 ` Simon Marchi
  0 siblings, 0 replies; 11+ messages in thread
From: Simon Marchi @ 2017-04-04 14:52 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

I have just pushed this:

In some situations, the dependency tracking files in .deps can refer to
source files that were removed or renamed, leading to errors like:

  make: *** No rule to make target `version.c', needed by `version.o'. Stop.

This patch makes the clean target clear the .deps directory, which gives
the user a chance to recover from the error wihtout knowing about the
internals of the build system.

It is already done for GDB.  See here for more details:

  https://sourceware.org/ml/gdb-patches/2009-03/msg00000.html

gdb/gdbserver/ChangeLog:

	* Makefile.in (clean): Clear .deps.
---
 gdb/gdbserver/ChangeLog   | 4 ++++
 gdb/gdbserver/Makefile.in | 1 +
 2 files changed, 5 insertions(+)

diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog
index 7ad841880e..39aea2fe0d 100644
--- a/gdb/gdbserver/ChangeLog
+++ b/gdb/gdbserver/ChangeLog
@@ -1,3 +1,7 @@
+2017-04-04  Simon Marchi  <simon.marchi@ericsson.com>
+
+	* Makefile.in (clean): Clear .deps.
+
 2017-03-31  Simon Marchi  <simon.marchi@polymtl.ca>
 
 	* .gitignore: Remove generated files, replace with wildcard.
diff --git a/gdb/gdbserver/Makefile.in b/gdb/gdbserver/Makefile.in
index 6af7c402f8..01dfdc0b89 100644
--- a/gdb/gdbserver/Makefile.in
+++ b/gdb/gdbserver/Makefile.in
@@ -417,6 +417,7 @@ clean:
 	rm -f $(IPA_LIB)
 	rm -f *-generated.c
 	rm -f stamp-xml
+	rm -f $(DEPDIR)/*.Po
 	@$(MAKE) $(FLAGS_TO_PASS) DO=$@ "DODIRS=$(SUBDIRS)" subdir_do
 
 maintainer-clean realclean distclean: clean
-- 
2.11.0

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

end of thread, other threads:[~2017-04-04 14:52 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-30  3:14 [PATCH] gdbserver: Suffix generated C files with -generated Simon Marchi
2017-03-30  3:31 ` Simon Marchi
2017-03-31 12:24   ` Pedro Alves
2017-03-31 13:35     ` Simon Marchi
2017-03-31 14:56     ` [PATCH v2] " Simon Marchi
2017-03-31 15:13       ` Pedro Alves
2017-03-31 15:40         ` Simon Marchi
2017-03-31 18:46           ` Simon Marchi
2017-03-31 19:39             ` Simon Marchi
2017-04-04 10:44               ` Pedro Alves
2017-04-04 14:52                 ` [PATCH pushed] gdbserver: Clear .deps on clean Simon Marchi

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