diff --git a/Makefile b/Makefile index aaf11b2253ba..be4cba61d442 100644 --- a/Makefile +++ b/Makefile @@ -398,7 +398,6 @@ KBUILD_CFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \ -fno-strict-aliasing -fno-common \ -Werror-implicit-function-declaration \ -Wno-format-security -Wno-builtin-macro-redefined \ - -Werror \ -std=gnu89 $(call cc-option,-fno-PIE) # re-define of __func__, __file__ to save rodata size @@ -731,6 +730,10 @@ endif KBUILD_CFLAGS += $(call cc-ifversion, -lt, 0409, \ $(call cc-disable-warning,maybe-uninitialized,)) +ifdef CONFIG_CC_WERROR +KBUILD_CFLAGS += -Werror +endif + # Tell gcc to never replace conditional load with a non-conditional one KBUILD_CFLAGS += $(call cc-option,--param=allow-store-data-races=0) diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index 89bf8889b773..263ae5f96301 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -1985,6 +1985,16 @@ config TEST_STATIC_KEYS If unsure, say N. +config CC_WERROR + bool "Treat all compile warnings as errors" + default n + help + Select this option to set compiler warnings as errors, + to prevent easily-fixable problems from creeping into + the codebase. + + If unsure, say N. + source "samples/Kconfig" source "lib/Kconfig.kgdb"