]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUILD: makefile: rename SPEC_CFLAGS to NOWARN_CFLAGS
authorWilly Tarreau <w@1wt.eu>
Thu, 11 Apr 2024 13:46:54 +0000 (15:46 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 11 Apr 2024 15:33:28 +0000 (17:33 +0200)
Now that the variable only serves to disable warnings, let's give it a
more suitable name and document its (rare) usage for package maintainers.

INSTALL
Makefile

diff --git a/INSTALL b/INSTALL
index ee358bda49395b6253afc9a5cf9904c2794449bd..03eaabc99b1e7d719b79a1639aa3659682a8de82 100644 (file)
--- a/INSTALL
+++ b/INSTALL
@@ -676,7 +676,14 @@ the WARN_CFLAGS variable. The variable contains a list of pre-established
 warnings and a list of some that are dynamically detected on the compiler.
 If the build environment or toolchain doesn't even support some of the basic
 ones, it is then possible to just redefine them by passing the main ones in
-WARN_CFLAGS (e.g. at the very least -W -Wall).
+WARN_CFLAGS (e.g. at the very least -W -Wall). Similarly, it may sometimes
+be desirable not to disable certain warnings when porting to new platforms
+or during code audits, or simply because the toolchain doesn't support some
+of the most basic -Wno options. In this case, the list of automatic -Wno
+variables is specified by variable NOWARN_CFLAGS, which is passed after
+WARN_CFLAGS (i.e. it can undo some of the WARN_CFLAGS settings). Be careful
+with it, as clearing this list can yield many warnings depending on the
+compiler and options.
 
 The DEBUG variable is used to extend the CFLAGS and is preset to a list of
 build-time options that are known for providing significant reliability
index 418807f17fdba1adfe71c0d0498712acd5f145ce..10b83036a5d59b41ec669a5768c5aa86f4577667 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -84,6 +84,7 @@
 #   ERR may be set to non-empty to pass -Werror to the compiler
 #   FAILFAST may be set to non-empty to pass -Wfatal-errors to the compiler
 #   WARN_CFLAGS overrides the default set of enabled warning options
+#   NOWARN_CFLAGS overrides the default set of disabled warning options
 #   ADDINC may be used to complete the include path in the form -Ipath.
 #   ADDLIB may be used to complete the library list in the form -Lpath -llib.
 #   DEFINE may be used to specify any additional define, which will be reported
@@ -212,16 +213,16 @@ WARN_CFLAGS := -Wall -Wextra -Wundef -Wdeclaration-after-statement            \
                  -Wduplicated-cond -Wnull-dereference)
 
 #### Compiler-specific flags to enable certain classes of warnings.
-SPEC_CFLAGS := $(cc-wnouwo)
-SPEC_CFLAGS += $(call cc-nowarn,address-of-packed-member)
-SPEC_CFLAGS += $(call cc-nowarn,unused-label)
-SPEC_CFLAGS += $(call cc-nowarn,sign-compare)
-SPEC_CFLAGS += $(call cc-nowarn,unused-parameter)
-SPEC_CFLAGS += $(call cc-nowarn,clobbered)
-SPEC_CFLAGS += $(call cc-nowarn,missing-field-initializers)
-SPEC_CFLAGS += $(call cc-nowarn,cast-function-type)
-SPEC_CFLAGS += $(call cc-nowarn,string-plus-int)
-SPEC_CFLAGS += $(call cc-nowarn,atomic-alignment)
+NOWARN_CFLAGS := $(cc-wnouwo)
+NOWARN_CFLAGS += $(call cc-nowarn,address-of-packed-member)
+NOWARN_CFLAGS += $(call cc-nowarn,unused-label)
+NOWARN_CFLAGS += $(call cc-nowarn,sign-compare)
+NOWARN_CFLAGS += $(call cc-nowarn,unused-parameter)
+NOWARN_CFLAGS += $(call cc-nowarn,clobbered)
+NOWARN_CFLAGS += $(call cc-nowarn,missing-field-initializers)
+NOWARN_CFLAGS += $(call cc-nowarn,cast-function-type)
+NOWARN_CFLAGS += $(call cc-nowarn,string-plus-int)
+NOWARN_CFLAGS += $(call cc-nowarn,atomic-alignment)
 
 #### CFLAGS defining error handling
 # ERROR_CFLAGS are just accumulators for these variables, they're not meant
@@ -489,7 +490,7 @@ $(set_target_defaults)
 # linking with it by default as it's not always available nor deployed
 # (especially on archs which do not need it).
 ifneq ($(USE_THREAD:0=),)
-  ifneq ($(shell $(CC) $(OPT_CFLAGS) $(ARCH_FLAGS) $(CPU_CFLAGS) $(DEBUG_CFLAGS) $(STD_CFLAGS) $(WARN_CFLAGS) $(SPEC_CFLAGS) $(ERROR_CFLAGS) $(CFLAGS) -dM -E -xc - </dev/null 2>/dev/null | grep -c 'LOCK_FREE.*1'),0)
+  ifneq ($(shell $(CC) $(OPT_CFLAGS) $(ARCH_FLAGS) $(CPU_CFLAGS) $(DEBUG_CFLAGS) $(STD_CFLAGS) $(WARN_CFLAGS) $(NOWARN_CFLAGS) $(ERROR_CFLAGS) $(CFLAGS) -dM -E -xc - </dev/null 2>/dev/null | grep -c 'LOCK_FREE.*1'),0)
     USE_LIBATOMIC   = implicit
   endif
 endif
@@ -858,10 +859,10 @@ endif
 $(collect_opts_flags)
 
 #### Global compile options
-VERBOSE_CFLAGS = $(OPT_CFLAGS) $(ARCH_FLAGS) $(CPU_CFLAGS) $(DEBUG_CFLAGS) $(STD_CFLAGS) $(WARN_CFLAGS) $(SPEC_CFLAGS) $(TARGET_CFLAGS) $(CFLAGS) $(DEFINE)
+VERBOSE_CFLAGS = $(OPT_CFLAGS) $(ARCH_FLAGS) $(CPU_CFLAGS) $(DEBUG_CFLAGS) $(STD_CFLAGS) $(WARN_CFLAGS) $(NOWARN_CFLAGS) $(TARGET_CFLAGS) $(CFLAGS) $(DEFINE)
 COPTS  = -Iinclude
 
-COPTS += $(OPT_CFLAGS) $(ARCH_FLAGS) $(CPU_CFLAGS) $(DEBUG_CFLAGS) $(STD_CFLAGS) $(WARN_CFLAGS) $(SPEC_CFLAGS) $(ERROR_CFLAGS) $(TARGET_CFLAGS) $(DEFINE) $(SILENT_DEFINE)
+COPTS += $(OPT_CFLAGS) $(ARCH_FLAGS) $(CPU_CFLAGS) $(DEBUG_CFLAGS) $(STD_CFLAGS) $(WARN_CFLAGS) $(NOWARN_CFLAGS) $(ERROR_CFLAGS) $(TARGET_CFLAGS) $(DEFINE) $(SILENT_DEFINE)
 COPTS += $(DEBUG) $(OPTIONS_CFLAGS) $(CFLAGS) $(ADDINC)
 
 ifneq ($(VERSION)$(SUBVERS)$(EXTRAVERSION),)
@@ -1172,6 +1173,7 @@ opts:
        @echo -n 'DEBUG_CFLAGS="$(strip $(DEBUG_CFLAGS))" '
        @echo -n 'STD_CFLAGS="$(strip $(STD_CFLAGS))" '
        @echo -n 'WARN_CFLAGS="$(strip $(WARN_CFLAGS))" '
+       @echo -n 'NOWARN_CFLAGS="$(strip $(NOWARN_CFLAGS))" '
        @echo -n 'ERROR_CFLAGS="$(strip $(ERROR_CFLAGS))" '
        @echo -n 'CFLAGS="$(strip $(CFLAGS))" '
        @#echo "$(strip $(BUILD_OPTIONS))"