[PATCH RFC next 16/18] scripts/Makefile.extrawarn: Respect CONFIG_WERROR / W=e for hostprogs
Quentin Schulz
foss+uboot at 0leil.net
Mon May 4 15:20:43 CEST 2026
From: Quentin Schulz <quentin.schulz at cherry.de>
[ Upstream commit 7ded7d37e5f5b36b4acd74380156cf07b6640c5b ]
Original commit log:
Commit 27758d8c2583 ("kbuild: enable -Werror for hostprogs")
unconditionally enabled -Werror for the compiler, assembler, and linker
when building the host programs, as the build footprint of the host
programs is small (thus risk of build failures from warnings are low)
and that stage of the build may not have Kconfig values (thus
CONFIG_WERROR could not be used as a precondition).
While turning warnings into errors unconditionally happens in a few
places within the kernel, it can be disruptive to people who may be
building with newer compilers, such as while doing a bisect. While it is
possible to avoid this behavior by passing HOSTCFLAGS=-w or
HOSTCFLAGS=-Wno-error, it may not be the most intuitive for regular
users not intimately familiar with Kbuild.
Avoid being disruptive to the entire build by depending on the explicit
opt-in of CONFIG_WERROR or W=e to enable -Werror and the like while
building the host programs. While this means there is a small portion of
the build that does not have -Werror enabled (namely scripts/kconfig/*
and scripts/basic/fixdep), it is better than not having it altogether.
Signed-off-by: Quentin Schulz <quentin.schulz at cherry.de>
---
scripts/Makefile.extrawarn | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn
index 8988308cc36..9fdc38a40af 100644
--- a/scripts/Makefile.extrawarn
+++ b/scripts/Makefile.extrawarn
@@ -108,9 +108,11 @@ KBUILD_AFLAGS += -Wa,--fatal-warnings
KBUILD_LDFLAGS += --fatal-warnings
KBUILD_RUSTFLAGS += -Dwarnings
-endif
-
-# Hostprog flags are used during build bootstrapping and can not rely on CONFIG_ symbols.
+# While hostprog flags are used during build bootstrapping (thus should not
+# depend on CONFIG_ symbols), -Werror is disruptive and should be opted into.
+# Only apply -Werror to hostprogs built after the initial Kconfig stage.
KBUILD_HOSTCFLAGS += -Werror
KBUILD_HOSTLDFLAGS += -Wl,--fatal-warnings
KBUILD_HOSTRUSTFLAGS += -Dwarnings
+
+endif
--
2.54.0
More information about the U-Boot
mailing list