Makefiles: Disable suffix rules and implicit rules
Commit Message
Since we don't use suffix rules nor implicit rules in gdb, we can
disable them. The advantage is a slightly faster make [1].
Here are some numbers about the speedup. I ran this on my trusty old
Intel Q6600, so the time numbers are probably higher than what you'd get
on any recent hardware. I ran "make" in the gdb/ directory of an
already built repository (configured with --enable-targets=all). I
recorded the time of execution (average of 5). I then ran "make -d" and
recorded the number of printed lines, which gives a rough idea of the
number of operations done.
I compared the following configurations, to see the impact of both the
empty .SUFFIXES target and the empty pattern rules, as well as running
"make -r", which can be considered the "ideal" case.
A - baseline
B - baseline + .SUFFIXES
C - baseline + pattern rules
D - baseline + .SUFFIXES + pattern rules
E - baseline + make -r
config | time (s) | "make -d"
-----------------------------
A | 5.74 | 2396643
B | 1.19 | 298469
C | 2.81 | 1266573
D | 1.13 | 245489
E | 1.01 | 163914
We can see that the empty .SUFFIXES target has a bigger impact than the
empty pattern rules, but still it doesn't hurt to disable the implicit
pattern rules as well.
There are still some mentions of implicit rules I can't get rid of in
the "make -d" output. For example, it's trying to build .c files from
.w files:
Looking for an implicit rule for '/home/simark/src/binutils-gdb/gdb/infrun.c'.
Trying pattern rule with stem 'infrun'.
Trying implicit prerequisite '/home/simark/src/binutils-gdb/gdb/infrun.w'.
and trying to build Makefile.in from a bunch of extensions:
Looking for an implicit rule for 'Makefile.in'.
Trying pattern rule with stem 'Makefile.in'.
Trying implicit prerequisite 'Makefile.in.o'.
Trying pattern rule with stem 'Makefile.in'.
Trying implicit prerequisite 'Makefile.in.c'.
Trying pattern rule with stem 'Makefile.in'.
Trying implicit prerequisite 'Makefile.in.cc'.
... many more ...
If somebody knows how to disable them, we can do it, but at this point
the returns are minimal, so it is not that important.
I verified that both in-tree and out-of-tree builds work.
[1] Switching from explicit rules to pattern rules for files in
subdirectories actually made it slower, so this is kind of a way to
redeem myself. But it the end it's faster than it was previously,
so it was all worth it. :)
gdb/ChangeLog:
* disable-implicit-rules.mk: New file.
* Makefile.in: Include disable-implicit-rules.mk.
* data-directory/Makefile.in: Likewise.
* doc/Makefile.in: Likewise.
gdb/gdbserver/ChangeLog:
* Makefile.in: Include disable-implicit-rules.mk.
gdb/testsuite/ChangeLog:
* Makefile.in: Include disable-implicit-rules.mk.
---
gdb/Makefile.in | 3 +++
gdb/data-directory/Makefile.in | 3 +++
gdb/disable-implicit-rules.mk | 10 ++++++++++
gdb/doc/Makefile.in | 3 +++
gdb/gdbserver/Makefile.in | 3 +++
gdb/testsuite/Makefile.in | 3 +++
6 files changed, 25 insertions(+)
create mode 100644 gdb/disable-implicit-rules.mk
Comments
On 11/26/2016 04:04 AM, Simon Marchi wrote:
>
> gdb/ChangeLog:
>
> * disable-implicit-rules.mk: New file.
Please add a copyright header.
> * Makefile.in: Include disable-implicit-rules.mk.
> * data-directory/Makefile.in: Likewise.
> * doc/Makefile.in: Likewise.
doc/ has its own ChangeLog file.
What about gnulib/Makefile.in ?
Otherwise LGTM.
(I suspect that we could move more common things to
a shared fragment, like e.g., NOEXPORT and MAKEOVERRIDES,
though the later maybe we don't need anymore. )
Thanks,
Pedro Alves
On 2016-11-30 06:51, Pedro Alves wrote:
> On 11/26/2016 04:04 AM, Simon Marchi wrote:
>
>>
>> gdb/ChangeLog:
>>
>> * disable-implicit-rules.mk: New file.
>
> Please add a copyright header.
Done locally.
>> * Makefile.in: Include disable-implicit-rules.mk.
>> * data-directory/Makefile.in: Likewise.
>> * doc/Makefile.in: Likewise.
>
> doc/ has its own ChangeLog file.
Whoops. Fixed locally.
> What about gnulib/Makefile.in ?
I thought it was an imported file, but no. It doesn't do much so I
don't think it will change anything, but I'll add the include in it as
well, for completeness. Ok with you?
On 11/30/2016 08:29 PM, Simon Marchi wrote:
> On 2016-11-30 06:51, Pedro Alves wrote:
>> On 11/26/2016 04:04 AM, Simon Marchi wrote:
>>
>>>
>>> gdb/ChangeLog:
>>>
>>> * disable-implicit-rules.mk: New file.
>>
>> Please add a copyright header.
>
> Done locally.
>
>>> * Makefile.in: Include disable-implicit-rules.mk.
>>> * data-directory/Makefile.in: Likewise.
>>> * doc/Makefile.in: Likewise.
>>
>> doc/ has its own ChangeLog file.
>
> Whoops. Fixed locally.
>
>> What about gnulib/Makefile.in ?
>
> I thought it was an imported file, but no. It doesn't do much so I
> don't think it will change anything, but I'll add the include in it as
> well, for completeness. Ok with you?
Yes.
Thanks,
Pedro Alves
On 2016-11-30 15:45, Pedro Alves wrote:
> On 11/30/2016 08:29 PM, Simon Marchi wrote:
>> On 2016-11-30 06:51, Pedro Alves wrote:
>>> On 11/26/2016 04:04 AM, Simon Marchi wrote:
>>>
>>>>
>>>> gdb/ChangeLog:
>>>>
>>>> * disable-implicit-rules.mk: New file.
>>>
>>> Please add a copyright header.
>>
>> Done locally.
>>
>>>> * Makefile.in: Include disable-implicit-rules.mk.
>>>> * data-directory/Makefile.in: Likewise.
>>>> * doc/Makefile.in: Likewise.
>>>
>>> doc/ has its own ChangeLog file.
>>
>> Whoops. Fixed locally.
>>
>>> What about gnulib/Makefile.in ?
>>
>> I thought it was an imported file, but no. It doesn't do much so I
>> don't think it will change anything, but I'll add the include in it as
>> well, for completeness. Ok with you?
>
> Yes.
>
> Thanks,
> Pedro Alves
Thanks, pushed with those fixed.
@@ -2909,4 +2909,7 @@ endif
# Dependencies.
-include $(patsubst %.o, $(DEPDIR)/%.Po, $(all_object_files))
+# Disable implicit make rules.
+include $(srcdir)/disable-implicit-rules.mk
+
### end of the gdb Makefile.in.
@@ -412,3 +412,6 @@ MAKEOVERRIDES=
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
cd $(top_builddir) && $(MAKE) data-directory/Makefile
+
+# Disable implicit make rules.
+include $(srcdir)/../disable-implicit-rules.mk
new file mode 100644
@@ -0,0 +1,10 @@
+# An empty .SUFFIXES target clears the suffixes list, which will skip lookups
+# of many implicit rules, speeding up the execution of make.
+.SUFFIXES:
+
+# Disable some implicit pattern rules.
+%: %,v
+%: RCS/%,v
+%: RCS/%
+%: s.%
+%: SCCS/s.%
@@ -676,3 +676,6 @@ maintainer-clean realclean: distclean
install: install-info install-man
uninstall: uninstall-info uninstall-man
+
+# Disable implicit make rules.
+include $(srcdir)/../disable-implicit-rules.mk
@@ -1079,4 +1079,7 @@ endif
# Dependencies.
-include $(patsubst %.o, $(DEPDIR)/%.Po, $(all_object_files))
+# Disable implicit make rules.
+include $(srcdir)/../disable-implicit-rules.mk
+
# This is the end of "Makefile.in".
@@ -372,3 +372,6 @@ read1.so: lib/read1.c
# Build the read1 machinery.
.PHONY: read1
read1: read1.so expect-read1
+
+# Disable implicit make rules.
+include $(srcdir)/../disable-implicit-rules.mk