commit 5df1480da4c4e58830d108f4f0f3347598c55ab3 Author: Willy Tarreau Date: Wed Oct 3 09:52:51 2018 +0200 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. (cherry picked from commit f11ca5e7a43c772637018ec2ad981a9fd7d3816f) [wt: only backported for context and consistency with next patch] Signed-off-by: Willy Tarreau diff --git a/Makefile b/Makefile index d3615060..1a971f92 100644 --- a/Makefile +++ b/Makefile @@ -96,13 +96,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 =