From: Willy Tarreau Date: Wed, 3 Oct 2018 07:52:51 +0000 (+0200) Subject: BUILD: Makefile: speed up compiler options detection X-Git-Tag: v1.9-dev4~90 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f11ca5e7a43c772637018ec2ad981a9fd7d3816f;p=thirdparty%2Fhaproxy.git BUILD: Makefile: speed up compiler options detection Commits b78016649 and d3a7f4035 brought the ability to detect the build options and warnings that the compiler supports. However, they're detected using "$(CC) -c", which is 50% slower than "$(CC) -E" for the same result, just because it starts the assembler at the end. Given that we're starting to check for a number of warnings, this detection alone starts to become visible, taking a bit more than 300 ms on the build time. Let's switch to -E instead to shrink this incompressible time by roughly 100 ms. --- diff --git a/Makefile b/Makefile index c4c1f6e799..4eac3f95fd 100644 --- a/Makefile +++ b/Makefile @@ -102,13 +102,13 @@ # Usage: CFLAGS += $(call cc-opt,option). Eg: $(call cc-opt,-fwrapv) # Note: ensure the referencing variable is assigned using ":=" and not "=" to # call it only once. -cc-opt = $(shell set -e; if $(CC) $(1) -c -xc - -o /dev/null &0 2>&0; then echo "$(1)"; fi;) +cc-opt = $(shell set -e; if $(CC) $(1) -E -xc - -o /dev/null &0 2>&0; then echo "$(1)"; fi;) # Disable a warning when supported by the compiler. Don't put spaces around the # warning! And don't use cc-opt which doesn't always report an error until # another one is also returned. # Usage: CFLAGS += $(call cc-nowarn,warning). Eg: $(call cc-opt,format-truncation) -cc-nowarn = $(shell set -e; if $(CC) -W$(1) -c -xc - -o /dev/null &0 2>&0; then echo "-Wno-$(1)"; fi;) +cc-nowarn = $(shell set -e; if $(CC) -W$(1) -E -xc - -o /dev/null &0 2>&0; then echo "-Wno-$(1)"; fi;) #### Installation options. DESTDIR =