makefiles/cflags.inc.mk: change optional CFLAGS to 'OPTIONAL_CFLAGS'
Update the optional flags to use 'OPTIONAL_CFLAGS' instead of evaluating everytime. They are now blacklisted by architecture/toolchain according to the current docker reference image.
This commit is contained in:
parent
043534daf9
commit
909552e3c0
@ -11,37 +11,19 @@ endif
|
|||||||
# 0x0 might be a sane memory location for embedded systems, so the test must not be removed.
|
# 0x0 might be a sane memory location for embedded systems, so the test must not be removed.
|
||||||
# Right now clang does not use the *delete-null-pointer* optimization, and does not understand the parameter.
|
# Right now clang does not use the *delete-null-pointer* optimization, and does not understand the parameter.
|
||||||
# Related issues: #628, #664.
|
# Related issues: #628, #664.
|
||||||
ifeq ($(shell $(CC) -fno-delete-null-pointer-checks -E - 2>/dev/null >/dev/null </dev/null ; echo $$?),0)
|
OPTIONAL_CFLAGS += -fno-delete-null-pointer-checks
|
||||||
ifeq ($(shell LANG=C $(CC) -fno-delete-null-pointer-checks -E - 2>&1 1>/dev/null </dev/null | grep warning: | grep -- -fno-delete-null-pointer-checks),)
|
|
||||||
CFLAGS += -fno-delete-null-pointer-checks
|
|
||||||
|
|
||||||
ifneq ($(shell $(CXX) -fno-delete-null-pointer-checks -E - 2>/dev/null >/dev/null </dev/null ; echo $$?),0)
|
|
||||||
CXXUWFLAGS += -fno-delete-null-pointer-checks
|
|
||||||
else
|
|
||||||
ifneq ($(shell LANG=C $(CXX) -fno-delete-null-pointer-checks -E - 2>&1 1>/dev/null </dev/null | grep warning: | grep -- -fno-delete-null-pointer-checks),)
|
|
||||||
CXXUWFLAGS += -fno-delete-null-pointer-checks
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Template for testing a compiler flag and adding it to CFLAGS (errors usually
|
|
||||||
# happens when using older toolchains which do not support the given flags)
|
|
||||||
define cflags_test_and_add
|
|
||||||
ifeq ($(shell $(CC) -Werror $(1) -E - 2>/dev/null >/dev/null </dev/null ; echo $$?),0)
|
|
||||||
CFLAGS += $(1)
|
|
||||||
endif
|
|
||||||
endef
|
|
||||||
# Use colored compiler output if the compiler supports this and if this is not
|
# Use colored compiler output if the compiler supports this and if this is not
|
||||||
# disabled by the user
|
# disabled by the user
|
||||||
ifeq ($(CC_NOCOLOR),0)
|
ifeq ($(CC_NOCOLOR),0)
|
||||||
$(eval $(call cflags_test_and_add,-fdiagnostics-color))
|
OPTIONAL_CFLAGS += -fdiagnostics-color
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Fast-out on old style function definitions.
|
# Fast-out on old style function definitions.
|
||||||
# They cause unreadable error compiler errors on missing semicolons.
|
# They cause unreadable error compiler errors on missing semicolons.
|
||||||
# Worse yet they hide errors by accepting wildcard argument types.
|
# Worse yet they hide errors by accepting wildcard argument types.
|
||||||
$(foreach flag,-Wstrict-prototypes -Wold-style-definition,$(eval $(call cflags_test_and_add,$(flag))))
|
OPTIONAL_CFLAGS += -Wstrict-prototypes
|
||||||
|
OPTIONAL_CFLAGS += -Wold-style-definition
|
||||||
|
|
||||||
# Unwanted flags for c++
|
# Unwanted flags for c++
|
||||||
CXXUWFLAGS += -std=%
|
CXXUWFLAGS += -std=%
|
||||||
@ -59,7 +41,9 @@ CFLAGS += -fno-common
|
|||||||
# Enable all default warnings and all extra warnings
|
# Enable all default warnings and all extra warnings
|
||||||
CFLAGS += -Wall -Wextra
|
CFLAGS += -Wall -Wextra
|
||||||
# Enable additional checks for printf/scanf format strings
|
# Enable additional checks for printf/scanf format strings
|
||||||
$(foreach flag,-Wformat=2 -Wformat-overflow -Wformat-truncation,$(eval $(call cflags_test_and_add,$(flag))))
|
OPTIONAL_CFLAGS += -Wformat=2
|
||||||
|
OPTIONAL_CFLAGS += -Wformat-overflow
|
||||||
|
OPTIONAL_CFLAGS += -Wformat-truncation
|
||||||
|
|
||||||
# Warn if a user-supplied include directory does not exist.
|
# Warn if a user-supplied include directory does not exist.
|
||||||
CFLAGS += -Wmissing-include-dirs
|
CFLAGS += -Wmissing-include-dirs
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user