Skip to content

Commit efa80b0

Browse files
committed
kbuild: move -Werror from KBUILD_CFLAGS to KBUILD_CPPFLAGS
CONFIG_WERROR turns warnings into errors, which happens only for *.c files because -Werror is added to KBUILD_CFLAGS. Adding it to KBUILD_CPPFLAGS makes more sense because preprocessors understand the -Werror option. For example, you can put a #warning directive in any preprocessed code. warning: #warning "this is a warning message" [-Wcpp] If -Werror is added, it is promoted to an error. error: #warning "this is a warning message" [-Werror=cpp] This commit moves -Werror to KBUILD_CPPFLAGS so it works in the same way for *.c, *.S, *.lds.S or whatever needs preprocessing. Signed-off-by: Masahiro Yamada <[email protected]> Reviewed-by: Nick Desaulniers <[email protected]> Reviewed-by: Nathan Chancellor <[email protected]>
1 parent 4bf7358 commit efa80b0

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -866,7 +866,8 @@ stackp-flags-$(CONFIG_STACKPROTECTOR_STRONG) := -fstack-protector-strong
866866

867867
KBUILD_CFLAGS += $(stackp-flags-y)
868868

869-
KBUILD_CFLAGS-$(CONFIG_WERROR) += -Werror
869+
KBUILD_CPPFLAGS-$(CONFIG_WERROR) += -Werror
870+
KBUILD_CPPFLAGS += $(KBUILD_CPPFLAGS-y)
870871
KBUILD_CFLAGS-$(CONFIG_CC_NO_ARRAY_BOUNDS) += -Wno-array-bounds
871872

872873
KBUILD_RUSTFLAGS-$(CONFIG_WERROR) += -Dwarnings

0 commit comments

Comments
 (0)