UPSTREAM: Enable '-Werror' by default for all kernel builds
... but make it a config option so that broken environments can disable it when required. We really should always have a clean build, and will disable specific over-eager warnings as required, if we can't fix them. But while I fairly religiously enforce that in my own tree, it doesn't get enforced by various build robots that don't necessarily report warnings. So this just makes '-Werror' a default compiler flag, but allows people to disable it for their configuration if they have some particular issues. Occasionally, new compiler versions end up enabling new warnings, and it can take a while before we have them fixed (or the warnings disabled if that is what it takes), so the config option allows for that situation. Hopefully this will mean that I get fewer pull requests that have new warnings that were not noticed by various automation we have in place. Knock wood. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> (cherry picked from commit 3fe617ccafd6f5bb33c2391d6f4eeb41c1fd0151) Signed-off-by: Alistair Delva <adelva@google.com> Change-Id: If981f26ebe668be7c727661fede10215c4ee5bc5
This commit is contained in:
committed by
Treehugger Robot
parent
447ba7ae75
commit
824c55581d
3
Makefile
3
Makefile
@@ -793,6 +793,9 @@ stackp-flags-$(CONFIG_STACKPROTECTOR_STRONG) := -fstack-protector-strong
|
||||
|
||||
KBUILD_CFLAGS += $(stackp-flags-y)
|
||||
|
||||
KBUILD_CFLAGS-$(CONFIG_WERROR) += -Werror
|
||||
KBUILD_CFLAGS += $(KBUILD_CFLAGS-y)
|
||||
|
||||
ifdef CONFIG_CC_IS_CLANG
|
||||
KBUILD_CPPFLAGS += -Qunused-arguments
|
||||
KBUILD_CFLAGS += -Wno-format-invalid-specifier
|
||||
|
||||
14
init/Kconfig
14
init/Kconfig
@@ -131,6 +131,20 @@ config COMPILE_TEST
|
||||
here. If you are a user/distributor, say N here to exclude useless
|
||||
drivers to be distributed.
|
||||
|
||||
config WERROR
|
||||
bool "Compile the kernel with warnings as errors"
|
||||
default y
|
||||
help
|
||||
A kernel build should not cause any compiler warnings, and this
|
||||
enables the '-Werror' flag to enforce that rule by default.
|
||||
|
||||
However, if you have a new (or very old) compiler with odd and
|
||||
unusual warnings, or you have some architecture with problems,
|
||||
you may need to disable this config option in order to
|
||||
successfully build the kernel.
|
||||
|
||||
If in doubt, say Y.
|
||||
|
||||
config UAPI_HEADER_TEST
|
||||
bool "Compile test UAPI headers"
|
||||
depends on HEADERS_INSTALL && CC_CAN_LINK
|
||||
|
||||
Reference in New Issue
Block a user