mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2024-12-25 14:12:13 +00:00
BUILD: makefile: split WARN_CFLAGS from SPEC_CFLAGS
It's currently not possible to only set some -Wno... without breaking the -W... and conversely. Let's split both sets apart so that it's now possible to set -W... alone in WARN_CFLAGS to enable only some warnings, and pass the -Wno... in SPEC_CFLAGS without losing the enabled ones.
This commit is contained in:
parent
af5755675d
commit
056c718853
8
INSTALL
8
INSTALL
@ -670,6 +670,14 @@ variable, FAILFAST enables -Wfatal-errors when set to non-empty except 0, and
|
||||
makes the compiler stop at the first error instead of scrolling pages. It's
|
||||
essentially a matter of taste.
|
||||
|
||||
Packagers who want to achieve the cleanest warning-free builds may be
|
||||
interested in knowing that all enabled warnings are normally placed into
|
||||
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).
|
||||
|
||||
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
|
||||
improvements and a barely perceptible performance cost. Unless instructed to do
|
||||
|
22
Makefile
22
Makefile
@ -83,6 +83,7 @@
|
||||
# DEBUG may be used to set some internal debugging options.
|
||||
# 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
|
||||
# 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
|
||||
@ -203,13 +204,15 @@ REG_TEST_SCRIPT=./scripts/run-regtests.sh
|
||||
# It is preferable not to change this option in order to avoid breakage.
|
||||
STD_CFLAGS := $(call cc-opt-alt,-fwrapv,-fno-strict-overflow)
|
||||
|
||||
#### Compiler-specific flags to enable/disable certain classes of warnings.
|
||||
WARN_CFLAGS := -Wtype-limits -Wshift-negative-value -Wshift-overflow=2 \
|
||||
-Wduplicated-cond -Wnull-dereference
|
||||
SPEC_CFLAGS := -Wall -Wextra -Wundef -Wdeclaration-after-statement
|
||||
SPEC_CFLAGS += $(call cc-all-fast,$(WARN_CFLAGS))
|
||||
#### Compiler-specific flags to enable certain classes of warnings.
|
||||
# Some are hard-coded, others are enabled only if supported.
|
||||
WARN_CFLAGS := -Wall -Wextra -Wundef -Wdeclaration-after-statement \
|
||||
$(call cc-all-fast, \
|
||||
-Wtype-limits -Wshift-negative-value -Wshift-overflow=2 \
|
||||
-Wduplicated-cond -Wnull-dereference)
|
||||
|
||||
SPEC_CFLAGS += $(cc-wnouwo)
|
||||
#### 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)
|
||||
@ -486,7 +489,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) $(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) $(SPEC_CFLAGS) $(ERROR_CFLAGS) $(CFLAGS) -dM -E -xc - </dev/null 2>/dev/null | grep -c 'LOCK_FREE.*1'),0)
|
||||
USE_LIBATOMIC = implicit
|
||||
endif
|
||||
endif
|
||||
@ -855,10 +858,10 @@ endif
|
||||
$(collect_opts_flags)
|
||||
|
||||
#### Global compile options
|
||||
VERBOSE_CFLAGS = $(OPT_CFLAGS) $(ARCH_FLAGS) $(CPU_CFLAGS) $(DEBUG_CFLAGS) $(STD_CFLAGS) $(SPEC_CFLAGS) $(TARGET_CFLAGS) $(CFLAGS) $(DEFINE)
|
||||
VERBOSE_CFLAGS = $(OPT_CFLAGS) $(ARCH_FLAGS) $(CPU_CFLAGS) $(DEBUG_CFLAGS) $(STD_CFLAGS) $(WARN_CFLAGS) $(SPEC_CFLAGS) $(TARGET_CFLAGS) $(CFLAGS) $(DEFINE)
|
||||
COPTS = -Iinclude
|
||||
|
||||
COPTS += $(OPT_CFLAGS) $(ARCH_FLAGS) $(CPU_CFLAGS) $(DEBUG_CFLAGS) $(STD_CFLAGS) $(SPEC_CFLAGS) $(ERROR_CFLAGS) $(TARGET_CFLAGS) $(DEFINE) $(SILENT_DEFINE)
|
||||
COPTS += $(OPT_CFLAGS) $(ARCH_FLAGS) $(CPU_CFLAGS) $(DEBUG_CFLAGS) $(STD_CFLAGS) $(WARN_CFLAGS) $(SPEC_CFLAGS) $(ERROR_CFLAGS) $(TARGET_CFLAGS) $(DEFINE) $(SILENT_DEFINE)
|
||||
COPTS += $(DEBUG) $(OPTIONS_CFLAGS) $(CFLAGS) $(ADDINC)
|
||||
|
||||
ifneq ($(VERSION)$(SUBVERS)$(EXTRAVERSION),)
|
||||
@ -1168,6 +1171,7 @@ opts:
|
||||
@echo -n 'CPU_CFLAGS="$(strip $(CPU_CFLAGS))" '
|
||||
@echo -n 'DEBUG_CFLAGS="$(strip $(DEBUG_CFLAGS))" '
|
||||
@echo -n 'STD_CFLAGS="$(strip $(STD_CFLAGS))" '
|
||||
@echo -n 'WARN_CFLAGS="$(strip $(WARN_CFLAGS))" '
|
||||
@echo -n 'ERROR_CFLAGS="$(strip $(ERROR_CFLAGS))" '
|
||||
@echo -n 'CFLAGS="$(strip $(CFLAGS))" '
|
||||
@#echo "$(strip $(BUILD_OPTIONS))"
|
||||
|
Loading…
Reference in New Issue
Block a user