Skip to contentSkip to conversation

Makefile: add --no-builtin-rules flag

PATCH Superseded Arnout Vandecappelle (Essensium/Mind) 2 participants 4 messages Mar 11, 2016 – Mar 13, 2016 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 Makefile: add --no-builtin-rules flag

When calling 'make', it takes several seconds before anything happens. This is because all the makefiles that have to be parsed and variables and rules that have to be evaluated.

One of the rules to be evaluated are the implicit rules that make adds to check out the *.mk files from RCS etc. This obviously makes no sense. Therefore, disable the built-in rules.

To avoid breaking package that depend on them, make sure we filter this out when calling sub-makes. MFLAGS has to be overridden too, otherwise the sub-make will just use that instead of MAKEFLAGS when MAKEFLAGS is empty.

Time for 'make help > /dev/null' on my machine (with hot cache):
before after

real    0m4.167s   0m3.375s
user    0m3.596s   0m2.928s
sys     0m0.256s   0m0.180s

and for 'make graph-depends' on a large config:
before after

real    0m58.417s  0m53.625s
user    0m48.284s  0m43.680s
sys     0m4.076s   0m3.536s

A roughly 10% improvement.

---
v2: override MFLAGS as well.

---
 Makefile            | 2 ++
 package/Makefile.in | 2 ++
 2 files changed, 4 insertions(+)
Makefile +2 -0
index f2822a2..bbb2017 100644
@@ -29,6 +29,8 @@ UMASK = 0022
 ifneq ($(shell umask),$(UMASK))
 .PHONY: _all $(MAKECMDGOALS)
 
+%.mk:
+
 $(MAKECMDGOALS): _all
 	@:
 
package/Makefile.in +2 -0
index fbf5485..730810e 100644
@@ -1,3 +1,4 @@
+MAKEFLAGS += --no-builtin-rules
 ifndef MAKE
 MAKE := make
 endif
@@ -5,6 +6,7 @@ ifndef HOSTMAKE
 HOSTMAKE = $(MAKE)
 endif
 HOSTMAKE := $(shell which $(HOSTMAKE) || type -p $(HOSTMAKE) || echo make)
+HOSTMAKE += MAKEFLAGS="$(filter-out --no-builtin-rules,$(MAKEFLAGS))" MFLAGS=
 
 # If BR2_JLEVEL is 0, scale the maximum concurrency with the number of
 # CPUs. An additional job is used in order to keep processors busy
Signature · 1 line
2.7.0
#1 lore raw

PATCH v2 1/1 Makefile: add --no-builtin-rules flag

Arnout, All,

On 2016-03-12 00:47 +0100, Arnout Vandecappelle (Essensium/Mind) spake thusly:

Quoted 58 lines

When calling 'make', it takes several seconds before anything happens. This is because all the makefiles that have to be parsed and variables and rules that have to be evaluated.

One of the rules to be evaluated are the implicit rules that make adds to check out the *.mk files from RCS etc. This obviously makes no sense. Therefore, disable the built-in rules.

To avoid breaking package that depend on them, make sure we filter this out when calling sub-makes. MFLAGS has to be overridden too, otherwise the sub-make will just use that instead of MAKEFLAGS when MAKEFLAGS is empty.

Time for 'make help > /dev/null' on my machine (with hot cache):
before after

real    0m4.167s   0m3.375s
user    0m3.596s   0m2.928s
sys     0m0.256s   0m0.180s

and for 'make graph-depends' on a large config:
before after

real    0m58.417s  0m53.625s
user    0m48.284s  0m43.680s
sys     0m4.076s   0m3.536s

A roughly 10% improvement.

---
v2: override MFLAGS as well.

---
 Makefile            | 2 ++
 package/Makefile.in | 2 ++
 2 files changed, 4 insertions(+)
Makefile +2 -0
index f2822a2..bbb2017 100644
@@ -29,6 +29,8 @@ UMASK = 0022
 ifneq ($(shell umask),$(UMASK))
 .PHONY: _all $(MAKECMDGOALS)
 
+%.mk:
+
 $(MAKECMDGOALS): _all
 	@:
 
package/Makefile.in +1 -0
index fbf5485..730810e 100644
@@ -1,3 +1,4 @@
+MAKEFLAGS += --no-builtin-rules
 ifndef MAKE
 MAKE := make
 endif

package/Makefile.in ifndef HOSTMAKE · line 9

Quoted 4 lines
package/Makefile.in +1 -0
@@ -5,6 +6,7 @@ ifndef HOSTMAKE
 HOSTMAKE = $(MAKE)
 endif
 HOSTMAKE := $(shell which $(HOSTMAKE) || type -p $(HOSTMAKE) || echo make)
+HOSTMAKE += MAKEFLAGS="$(filter-out --no-builtin-rules,$(MAKEFLAGS))" MFLAGS=

Is the extra added complexity worth the improvement?

Regards,
Yann E. MORIN.

Quoted 9 lines
package/Makefile.in +0 -0
 # If BR2_JLEVEL is 0, scale the maximum concurrency with the number of
 # CPUs. An additional job is used in order to keep processors busy
Signature · 6 lines
2.7.0

_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#2 lore raw

PATCH v2 1/1 Makefile: add --no-builtin-rules flag

In reply to Arnout Vandecappelle (Essensium/Mind)

Arnout, All,

On 2016-03-12 00:47 +0100, Arnout Vandecappelle (Essensium/Mind) spake thusly:

Quoted 4 lines

When calling 'make', it takes several seconds before anything happens. This is because all the makefiles that have to be parsed and variables and rules that have to be evaluated.

Quoted 8 lines

One of the rules to be evaluated are the implicit rules that make adds to check out the *.mk files from RCS etc. This obviously makes no sense. Therefore, disable the built-in rules.

To avoid breaking package that depend on them, make sure we filter this out when calling sub-makes. MFLAGS has to be overridden too, otherwise the sub-make will just use that instead of MAKEFLAGS when MAKEFLAGS is empty.

Sorry, it breaks at least host-ncurses:

/usr/bin/make MAKEFLAGS="--no-print-directory" MFLAGS= -j1 -C /home/ymorin/dev/buildroot/O/build/host-ncurses-5.9 sources cd include && /usr/bin/make ---no-print-directory DESTDIR="" sources
/usr/bin/make: unrecognized option '---no-print-directory'
Usage: make [options] [target] ...
[--SNIP--]

Regards,
Yann E. MORIN.

Quoted 59 lines

Time for 'make help > /dev/null' on my machine (with hot cache):
before after

real    0m4.167s   0m3.375s
user    0m3.596s   0m2.928s
sys     0m0.256s   0m0.180s

and for 'make graph-depends' on a large config:
before after

real    0m58.417s  0m53.625s
user    0m48.284s  0m43.680s
sys     0m4.076s   0m3.536s

A roughly 10% improvement.

---
v2: override MFLAGS as well.

---
 Makefile            | 2 ++
 package/Makefile.in | 2 ++
 2 files changed, 4 insertions(+)
Makefile +2 -0
index f2822a2..bbb2017 100644
@@ -29,6 +29,8 @@ UMASK = 0022
 ifneq ($(shell umask),$(UMASK))
 .PHONY: _all $(MAKECMDGOALS)
 
+%.mk:
+
 $(MAKECMDGOALS): _all
 	@:
 
package/Makefile.in +2 -0
index fbf5485..730810e 100644
@@ -1,3 +1,4 @@
+MAKEFLAGS += --no-builtin-rules
 ifndef MAKE
 MAKE := make
 endif
@@ -5,6 +6,7 @@ ifndef HOSTMAKE
 HOSTMAKE = $(MAKE)
 endif
 HOSTMAKE := $(shell which $(HOSTMAKE) || type -p $(HOSTMAKE) || echo make)
+HOSTMAKE += MAKEFLAGS="$(filter-out --no-builtin-rules,$(MAKEFLAGS))" MFLAGS=
 
 # If BR2_JLEVEL is 0, scale the maximum concurrency with the number of
 # CPUs. An additional job is used in order to keep processors busy
Signature · 6 lines
2.7.0

_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#3 lore raw

PATCH v2 1/1 Makefile: add --no-builtin-rules flag

Quoted 15 lines · Yann E. MORIN

Arnout, All,

On 2016-03-12 00:47 +0100, Arnout Vandecappelle (Essensium/Mind) spake thusly:

Quoted 4 lines
Quoted 4 lines

When calling 'make', it takes several seconds before anything happens. This is because all the makefiles that have to be parsed and variables and rules that have to be evaluated.

Quoted 8 lines
Quoted 8 lines

One of the rules to be evaluated are the implicit rules that make adds to check out the *.mk files from RCS etc. This obviously makes no sense. Therefore, disable the built-in rules.

To avoid breaking package that depend on them, make sure we filter this out when calling sub-makes. MFLAGS has to be overridden too, otherwise the sub-make will just use that instead of MAKEFLAGS when MAKEFLAGS is empty.

Quoted 7 lines

Sorry, it breaks at least host-ncurses:

/usr/bin/make MAKEFLAGS="--no-print-directory" MFLAGS= -j1 -C /home/ymorin/dev/buildroot/O/build/host-ncurses-5.9 sources cd include && /usr/bin/make ---no-print-directory DESTDIR="" sources
/usr/bin/make: unrecognized option '---no-print-directory'
Usage: make [options] [target] ...
[--SNIP--]

Gah, bug in make 3.81 :-(

That will probably require even more hackery to work around... Let's drop this
patch.

Regards,
Arnout

Signature · 6 lines
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF