[PATCH 1/2] kbuild: move existing CONFIG_WERROR flags into dedicated Makefile

Thomas Weißschuh posted 2 patches 1 month, 3 weeks ago
There is a newer version of this series
[PATCH 1/2] kbuild: move existing CONFIG_WERROR flags into dedicated Makefile
Posted by Thomas Weißschuh 1 month, 3 weeks ago
CONFIG_WERROR is about to be enabled for more build steps.
To avoid spreading similar flags into multiple locations, create a
dedicated, shared file for them.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
---
 Makefile                   |  4 +---
 scripts/Makefile.extrawarn |  2 --
 scripts/Makefile.werror    | 11 +++++++++++
 3 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/Makefile b/Makefile
index 6bfe776bf3c5ff0cf187dc6719dd5817cd4af2ca..4ffa40e98b1517e1f2a7a155641fa9a3c784f625 100644
--- a/Makefile
+++ b/Makefile
@@ -901,9 +901,6 @@ stackp-flags-$(CONFIG_STACKPROTECTOR_STRONG)      := -fstack-protector-strong
 
 KBUILD_CFLAGS += $(stackp-flags-y)
 
-KBUILD_RUSTFLAGS-$(CONFIG_WERROR) += -Dwarnings
-KBUILD_RUSTFLAGS += $(KBUILD_RUSTFLAGS-y)
-
 ifdef CONFIG_FRAME_POINTER
 KBUILD_CFLAGS	+= -fno-omit-frame-pointer -fno-optimize-sibling-calls
 KBUILD_RUSTFLAGS += -Cforce-frame-pointers=y
@@ -1085,6 +1082,7 @@ endif
 
 # include additional Makefiles when needed
 include-y			:= scripts/Makefile.extrawarn
+include-$(CONFIG_WERROR)	+= scripts/Makefile.werror
 include-$(CONFIG_DEBUG_INFO)	+= scripts/Makefile.debug
 include-$(CONFIG_DEBUG_INFO_BTF)+= scripts/Makefile.btf
 include-$(CONFIG_KASAN)		+= scripts/Makefile.kasan
diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn
index dca175fffcabeb2d942814f0a096a7efbf8bc819..2d8201395002dace78b875a6d25d1fd33b1691fd 100644
--- a/scripts/Makefile.extrawarn
+++ b/scripts/Makefile.extrawarn
@@ -25,8 +25,6 @@ ifneq ($(CONFIG_FRAME_WARN),0)
 KBUILD_CFLAGS += -Wframe-larger-than=$(CONFIG_FRAME_WARN)
 endif
 
-KBUILD_CPPFLAGS-$(CONFIG_WERROR) += -Werror
-KBUILD_CPPFLAGS += $(KBUILD_CPPFLAGS-y)
 KBUILD_CFLAGS-$(CONFIG_CC_NO_ARRAY_BOUNDS) += -Wno-array-bounds
 
 ifdef CONFIG_CC_IS_CLANG
diff --git a/scripts/Makefile.werror b/scripts/Makefile.werror
new file mode 100644
index 0000000000000000000000000000000000000000..db14b5490ba83444be39a18109f103cabc5b95e9
--- /dev/null
+++ b/scripts/Makefile.werror
@@ -0,0 +1,11 @@
+# SPDX-License-Identifier: GPL-2.0
+# ==========================================================================
+# Warning flags enabled by CONFIG_WERROR
+#
+# Different parts of the build require different flags to transform warnings
+# into errors. These are handled by the entries below.
+# ==========================================================================
+
+KBUILD_CPPFLAGS		+= -Werror
+
+KBUILD_RUSTFLAGS	+= -Dwarnings

-- 
2.50.1