Skip to content

Commit

Permalink
kernel: Add CC_WERROR config to turn warnings into errors
Browse files Browse the repository at this point in the history
Add configuration option CONFIG_CC_WERROR to prevent warnings
from creeping in.

Bug: 67861121
Change-Id: I8cd2123d2c569ea6c6ab7f74ed6ca67976e9af3a
Signed-off-by: Chris Fries <[email protected]>
  • Loading branch information
ccfries authored and EdwinMoq committed Apr 1, 2022
1 parent 87a4553 commit 287337b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -737,6 +737,10 @@ else
KBUILD_CFLAGS += -O2
endif

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)
KBUILD_CFLAGS += $(call cc-option,-fno-allow-store-data-races)
Expand Down
10 changes: 10 additions & 0 deletions lib/Kconfig.debug
Original file line number Diff line number Diff line change
Expand Up @@ -2110,6 +2110,16 @@ config BUG_ON_DATA_CORRUPTION

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"
Expand Down

0 comments on commit 287337b

Please sign in to comment.