]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUILD: Makefile: the compiler-specific flags should all be in SPEC_CFLAGS
authorWilly Tarreau <w@1wt.eu>
Tue, 10 Mar 2020 08:37:08 +0000 (09:37 +0100)
committerWilly Tarreau <w@1wt.eu>
Tue, 10 Mar 2020 08:42:30 +0000 (09:42 +0100)
We used to have -Wall -Wextra -Werror in COPTS which are flags fed by
the various USE_* options, and all other warnings in SPEC_CFLAGS. This
makes it impossible to remove these -W* entries (typically -Wextra).

Let's move these 3 flags into SPEC_CFLAGS where they should have been.
Now it's possible to override SPEC_CFLAGS to match any compiler's
specificities, or to clear all warnings at once, or to replace them
all with "-w" to silence warnings.

Makefile

index 2019274413ef77eb60ff07ec5f7020f76648b90a..c04e699d736b70f9556fc3e3c17e57d4f6a0777e 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -177,7 +177,7 @@ REG_TEST_SCRIPT=./scripts/run-regtests.sh
 # We rely on signed integer wraparound on overflow, however clang think it
 # can do whatever it wants since it's an undefined behavior, so use -fwrapv
 # to be sure we get the intended behavior.
-SPEC_CFLAGS := -Wdeclaration-after-statement
+SPEC_CFLAGS := -Wall -Wextra -Wdeclaration-after-statement
 SPEC_CFLAGS += $(call cc-opt-alt,-fwrapv,$(call cc-opt,-fno-strict-overflow))
 SPEC_CFLAGS += $(call cc-nowarn,address-of-packed-member)
 SPEC_CFLAGS += $(call cc-nowarn,unused-label)
@@ -197,6 +197,10 @@ SPEC_CFLAGS += $(call cc-opt,-Wshift-overflow=2)
 SPEC_CFLAGS += $(call cc-opt,-Wduplicated-cond)
 SPEC_CFLAGS += $(call cc-opt,-Wnull-dereference)
 
+ifneq ($(ERR),)
+SPEC_CFLAGS += -Werror
+endif
+
 #### Memory usage tuning
 # If small memory footprint is required, you can reduce the buffer size. There
 # are 2 buffers per concurrent session, so 16 kB buffers will eat 32 MB memory
@@ -701,11 +705,7 @@ EBTREE_DIR := ebtree
 
 #### Global compile options
 VERBOSE_CFLAGS = $(CFLAGS) $(TARGET_CFLAGS) $(SMALL_OPTS) $(DEFINE)
-COPTS  = -Iinclude -I$(EBTREE_DIR) -Wall -Wextra
-
-ifneq ($(ERR),)
-COPTS += -Werror
-endif
+COPTS  = -Iinclude -I$(EBTREE_DIR)
 
 COPTS += $(CFLAGS) $(TARGET_CFLAGS) $(SMALL_OPTS) $(DEFINE) $(SILENT_DEFINE)
 COPTS += $(DEBUG) $(OPTIONS_CFLAGS) $(ADDINC)