public inbox for linux-kbuild@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 1/2] kbuild: move -Werror from KBUILD_CFLAGS to KBUILD_CPPFLAGS
@ 2022-10-12 18:01 Masahiro Yamada
  2022-10-12 18:01 ` [PATCH v3 2/2] kbuild: move -Wundef " Masahiro Yamada
  2022-10-14 16:03 ` [PATCH v3 1/2] kbuild: move -Werror " Nathan Chancellor
  0 siblings, 2 replies; 5+ messages in thread
From: Masahiro Yamada @ 2022-10-12 18:01 UTC (permalink / raw)
  To: linux-kbuild; +Cc: linux-kernel, linux-arch, Masahiro Yamada, Nick Desaulniers

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 <masahiroy@kernel.org>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
---

(no changes since v1)

 Makefile | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index 85a63a1d29b3..790760d26ea0 100644
--- a/Makefile
+++ b/Makefile
@@ -859,7 +859,8 @@ stackp-flags-$(CONFIG_STACKPROTECTOR_STRONG)      := -fstack-protector-strong
 
 KBUILD_CFLAGS += $(stackp-flags-y)
 
-KBUILD_CFLAGS-$(CONFIG_WERROR) += -Werror
+KBUILD_CPPFLAGS-$(CONFIG_WERROR) += -Werror
+KBUILD_CPPFLAGS += $(KBUILD_CPPFLAGS-y)
 KBUILD_CFLAGS-$(CONFIG_CC_NO_ARRAY_BOUNDS) += -Wno-array-bounds
 
 KBUILD_RUSTFLAGS-$(CONFIG_WERROR) += -Dwarnings
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-10-14 20:22 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-12 18:01 [PATCH v3 1/2] kbuild: move -Werror from KBUILD_CFLAGS to KBUILD_CPPFLAGS Masahiro Yamada
2022-10-12 18:01 ` [PATCH v3 2/2] kbuild: move -Wundef " Masahiro Yamada
2022-10-14 16:03 ` [PATCH v3 1/2] kbuild: move -Werror " Nathan Chancellor
2022-10-14 20:19   ` Nick Desaulniers
2022-10-14 20:21   ` Masahiro Yamada

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox