From 0d7a2ae4f5199ec37ead6914fa24d40ec0989a4d Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Tue, 16 Oct 2018 18:11:34 +0200 Subject: [PATCH] BUILD: Makefile: silence an option conflict warning with clang clang complains that -fno-strict-overflow is not used when -fwrapv is used, which breaks the build when -Werror is used. Let's introduce a cc-opt-alt function to emit the former only then the latter is not supported (since it implies the former). --- Makefile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 4eac3f95fd..424d98cb36 100644 --- a/Makefile +++ b/Makefile @@ -104,6 +104,9 @@ # call it only once. cc-opt = $(shell set -e; if $(CC) $(1) -E -xc - -o /dev/null &0 2>&0; then echo "$(1)"; fi;) +# same but emits $2 if $1 is not supported +cc-opt-alt = $(shell set -e; if $(CC) $(1) -E -xc - -o /dev/null &0 2>&0; then echo "$(1)"; else echo "$(2)"; 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. @@ -153,8 +156,7 @@ DEBUG_CFLAGS = -g # can do whatever it wants since it's an undefined behavior, so use -fwrapv # to be sure we get the intended behavior. SPEC_CFLAGS := -fno-strict-aliasing -Wdeclaration-after-statement -SPEC_CFLAGS += $(call cc-opt,-fwrapv) -SPEC_CFLAGS += $(call cc-opt,-fno-strict-overflow) +SPEC_CFLAGS += $(call cc-opt-alt,-fwrapv,$(call cc-opt,-fno-strict-overflow)) SPEC_CFLAGS += $(call cc-nowarn,format-truncation) SPEC_CFLAGS += $(call cc-nowarn,address-of-packed-member) SPEC_CFLAGS += $(call cc-nowarn,unused-label)