Add -Werror build option
Subsystems (2)
PATCH 1/1 Add -Werror build option
Add a config option "ERROR_ON_WARNING" that adds the "-Werror" flag to gcc, which turns warnings into errors.
This option enables developers to set a stricter level of code checking for kernel code: all code must be warning-free.
Signed-off-by Simon Que <[email protected]>
Signed-off-by Mandeep Singh Baines <[email protected]>
--- Makefile | 4 ++++ lib/Kconfig.debug | 9 +++++++++ 2 files changed, 13 insertions(+), 0 deletions(-)
Makefile +4 -0
@@ -620,6 +620,10 @@ endif NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include) CHECKFLAGS += $(NOSTDINC_FLAGS) +ifdef CONFIG_ERROR_ON_WARNING +KBUILD_CFLAGS += -Werror +endif + # warn about C99 declaration after statement KBUILD_CFLAGS += $(call cc-option,-Wdeclaration-after-statement,)
lib/Kconfig.debug +9 -0
@@ -1305,3 +1305,12 @@ source "lib/Kconfig.kmemcheck" config TEST_KSTRTOX tristate "Test kstrto*() family of functions at runtime" + +config ERROR_ON_WARNING + bool "Treat compiler warnings as errors" + help + If you say Y here, the Makefile will pass the "-Werror" option to the + compiler. This will cause the compiler to fail on any warning, as if + it were an error. + + If unsure, say N.
Signature · 1 line
1.7.8.6
Quoted 5 lines · Simon Que
Add a config option "
ERROR_ON_WARNING" that adds the "-Werror" flag to gcc, which turns warnings into errors.This option enables developers to set a stricter level of code checking for kernel code: all code must be warning-free.
And we want this because...?
Signature · 5 lines
Regards/Gruss,
Boris.
Sent from a fat crate under my desk. Formatting is fine.
--