BUILD: makefile: stop opening sub-shells for each and every command

We're spending ~8% of the total build time calling a shell to display
"CC" using the "echo" command! We don't really need this, as make also
knows a "$(info ...)" command to print a message. However there's a catch,
this command trims leading spaces, so we need to use an invisible space
using "$ ". Furthermore, in GNU make 3.80 and older, $(info) doesn't show
anything, so we only do that for 3.81 and above, older versions continue
to use echo.

This measurably speeds up build time especially at -O0 that developers
use most of the time for quick checks.
This commit is contained in:
Willy Tarreau 2021-11-19 10:23:36 +01:00
parent e15ab93244
commit 9e3093c48a
1 changed files with 8 additions and 0 deletions

View File

@ -813,10 +813,18 @@ cmd_CC = $(CC)
cmd_LD = $(LD)
cmd_AR = $(AR)
else
ifeq (3.81,$(firstword $(sort $(MAKE_VERSION) 3.81)))
# 3.81 or above
cmd_CC = $(info $ CC $@) $(Q)$(CC)
cmd_LD = $(info $ LD $@) $(Q)$(LD)
cmd_AR = $(info $ AR $@) $(Q)$(AR)
else
# 3.80 or older
cmd_CC = $(Q)echo " CC $@";$(CC)
cmd_LD = $(Q)echo " LD $@";$(LD)
cmd_AR = $(Q)echo " AR $@";$(AR)
endif
endif
ifeq ($(TARGET),)
all: