public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] gdb: replace suffix rules with pattern rules
@ 2014-01-12 21:56 Patrick Palka
  2014-01-13 19:45 ` Tom Tromey
  0 siblings, 1 reply; 4+ messages in thread
From: Patrick Palka @ 2014-01-12 21:56 UTC (permalink / raw)
  To: gdb-patches; +Cc: Patrick Palka

Suffix rules (e.g. .c.o:) are error-prone and may not interact well with
GNU make's -r/--no-builtin-rules flag.  Replace them with
otherwise-equivalent pattern rules (e.g. %.o: %.c).

Since we no longer rely on suffix rules, we can also remove references
to the magic .SUFFIXES target.

As a result of this change, one can now successfully build gdb/ with
make's -r flag which improves build time by a bit.
---
 gdb/ChangeLog             |  5 +++++
 gdb/Makefile.in           | 12 +++++-------
 gdb/gdbserver/Makefile.in |  2 +-
 3 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index d5006ea..e2ab527 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2014-01-12  Patrick Palka  <patrick@parcs.ath.cx>
+
+	* Makefile.in: Remove references to .SUFFIXES target.  Replace
+	suffix rules with corresponding pattern rules.
+
 2014-01-10  Patrick Palka  <patrick@parcs.ath.cx>
 
 	* regformats/regdat.sh: Always rewrite the register file.
diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index 824b26b..3627e0e 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -992,7 +992,7 @@ DISTSTUFF = $(YYFILES)
 generated_files = config.h observer.h observer.inc ada-lex.c jit-reader.h \
 	$(GNULIB_H) $(NAT_GENERATED_FILES) gcore
 
-.c.o:
+%.o: %.c
 	$(COMPILE) $<
 	$(POSTCOMPILE)
 
@@ -1621,7 +1621,6 @@ ada-exp.o: ada-exp.c
 # Rules for generating translated message descriptions.  Disabled by
 # autoconf if the tools are not available.
 
-.SUFFIXES: .po .gmo .pox .pot
 .PHONY: all-po install-po uninstall-po clean-po update-po $(PACKAGE).pot
 
 all-po: $(CATALOGS)
@@ -1632,14 +1631,14 @@ update-po: $(CATALOGS:.gmo=.pox)
 
 # N.B. We do not attempt to copy these into $(srcdir).  The snapshot
 # script does that.
-.po.gmo:
+%.gmo: %.po
 	-test -d po || mkdir po
 	$(GMSGFMT) --statistics -o $@ $<
 
 # The new .po has to be gone over by hand, so we deposit it into
 # build/po with a different extension.  If build/po/$(PACKAGE).pot
 # exists, use it (it was just created), else use the one in srcdir.
-.po.pox:
+%.pox: %.po
 	-test -d po || mkdir po
 	$(MSGMERGE) $< `if test -f po/$(PACKAGE).pot; \
 			then echo po/$(PACKAGE).pot; \
@@ -1700,8 +1699,7 @@ po/$(PACKAGE).pot: force
 # Strictly speaking c-exp.c should therefore depend on
 # Makefile.in, but that was a pretty big annoyance.
 
-.SUFFIXES: .y .l
-.y.c:
+%.c: %.y
 	rm -f $@ $@.tmp
 	$(SHELL) $(YLWRAP) $< y.tab.c $@ -- $(YACC) $(YFLAGS) && mv $@ $@.tmp \
 		|| (rm -f $@; false)
@@ -1717,7 +1715,7 @@ po/$(PACKAGE).pot: force
 	     -e "s/^\(#line.*\)`basename $<`/\1`echo $<|sed 's/\//\\\\\//g'`/" \
 	  < $@.tmp > $@
 	rm -f $@.tmp
-.l.c:
+%.c: %.l
 	if [ "$(FLEX)" ] && $(FLEX) --version >/dev/null 2>&1; then \
 	    $(FLEX) -o$@ $< && \
 	    rm -f $@.new && \
diff --git a/gdb/gdbserver/Makefile.in b/gdb/gdbserver/Makefile.in
index b58184d..0f62ca4 100644
--- a/gdb/gdbserver/Makefile.in
+++ b/gdb/gdbserver/Makefile.in
@@ -234,7 +234,7 @@ FLAGS_TO_PASS = \
 # All generated files which can be included by another file.
 generated_files = config.h $(GNULIB_H)
 
-.c.o:
+%.o: %.c
 	$(COMPILE) $<
 	$(POSTCOMPILE)
 
-- 
1.8.5.2

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

* Re: [PATCH] gdb: replace suffix rules with pattern rules
  2014-01-12 21:56 [PATCH] gdb: replace suffix rules with pattern rules Patrick Palka
@ 2014-01-13 19:45 ` Tom Tromey
  2014-01-14  1:18   ` Patrick Palka
  0 siblings, 1 reply; 4+ messages in thread
From: Tom Tromey @ 2014-01-13 19:45 UTC (permalink / raw)
  To: Patrick Palka; +Cc: gdb-patches

>>>>> "Patrick" == Patrick Palka <patrick@parcs.ath.cx> writes:

Patrick> Suffix rules (e.g. .c.o:) are error-prone and may not interact
Patrick> well with GNU make's -r/--no-builtin-rules flag.  Replace them
Patrick> with otherwise-equivalent pattern rules (e.g. %.o: %.c).

Despite appearances, gdb's use of GNU make features is constrained to
parallel check and, if GNU make is available, dependency tracking.  That
is, in theory you can do a "one-off" build of gdb using some other make.

I wouldn't mind requiring GNU make -- gcc has done it for years without
adverse effects -- but it isn't currently the case.

TBH I am not sure how you'd go about getting this sort of change
approved.

Patrick> As a result of this change, one can now successfully build gdb/ with
Patrick> make's -r flag which improves build time by a bit.

There's a zillion other directories to cope with in the tree.
Does make -r work in all of them except gdb?
If so, how?

Tom

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

* Re: [PATCH] gdb: replace suffix rules with pattern rules
  2014-01-13 19:45 ` Tom Tromey
@ 2014-01-14  1:18   ` Patrick Palka
  2014-01-14  2:55     ` Tom Tromey
  0 siblings, 1 reply; 4+ messages in thread
From: Patrick Palka @ 2014-01-14  1:18 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On Mon, Jan 13, 2014 at 2:45 PM, Tom Tromey <tromey@redhat.com> wrote:
>>>>>> "Patrick" == Patrick Palka <patrick@parcs.ath.cx> writes:
>
> Patrick> Suffix rules (e.g. .c.o:) are error-prone and may not interact
> Patrick> well with GNU make's -r/--no-builtin-rules flag.  Replace them
> Patrick> with otherwise-equivalent pattern rules (e.g. %.o: %.c).
>
> Despite appearances, gdb's use of GNU make features is constrained to
> parallel check and, if GNU make is available, dependency tracking.  That
> is, in theory you can do a "one-off" build of gdb using some other make.

I see.  That explains why e.g. static pattern rules are not used either.

> I wouldn't mind requiring GNU make -- gcc has done it for years without
> adverse effects -- but it isn't currently the case.
>
> TBH I am not sure how you'd go about getting this sort of change
> approved.
>
> Patrick> As a result of this change, one can now successfully build gdb/ with
> Patrick> make's -r flag which improves build time by a bit.
>
> There's a zillion other directories to cope with in the tree.
> Does make -r work in all of them except gdb?
> If so, how?

Not all.  The directories whose makefiles are generated by automake
work under make -r and so do the ones that don't use suffix rules at
all. The ones generated by
automake work because automake makes sure to explicitly populate the
.SUFFIXES target with the relevant file extensions.  The gdb/ makefile
doesn't work
under make -r essentially because it relies on a ".c.o:" suffix rule
but the file extensions .c and .o are not in .SUFFIXES.  (So, a
portable variant of the above patch would be to make sure to add .c
and .o into the .SUFFIXES target, leaving the suffix rules in place.)
Likewise for one or two other makefiles in the tree, suchas the one
under readline/.

I was not aware of the concern about portability.  I'll repost a
portable version of the patch once I submit my copyright assignment.

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

* Re: [PATCH] gdb: replace suffix rules with pattern rules
  2014-01-14  1:18   ` Patrick Palka
@ 2014-01-14  2:55     ` Tom Tromey
  0 siblings, 0 replies; 4+ messages in thread
From: Tom Tromey @ 2014-01-14  2:55 UTC (permalink / raw)
  To: Patrick Palka; +Cc: gdb-patches

>>>>> "Patrick" == Patrick Palka <patrick@parcs.ath.cx> writes:

Patrick> I was not aware of the concern about portability.  I'll repost a
Patrick> portable version of the patch once I submit my copyright assignment.

Sounds good.  I think that patch would be unobjectionable.

Tom

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

end of thread, other threads:[~2014-01-14  2:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-12 21:56 [PATCH] gdb: replace suffix rules with pattern rules Patrick Palka
2014-01-13 19:45 ` Tom Tromey
2014-01-14  1:18   ` Patrick Palka
2014-01-14  2:55     ` 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).