Skip to content

Commit 7ded7d3

Browse files
committed
scripts/Makefile.extrawarn: Respect CONFIG_WERROR / W=e for hostprogs
Commit 27758d8 ("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. Fixes: 27758d8 ("kbuild: enable -Werror for hostprogs") Acked-by: Miguel Ojeda <ojeda@kernel.org> Reported-by: Askar Safin <safinaskar@gmail.com> Closes: https://lore.kernel.org/20251005011100.1035272-1-safinaskar@gmail.com/ Reviewed-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de> Tested-by: Miguel Ojeda <ojeda@kernel.org> # Rust Link: https://patch.msgid.link/20251006-kbuild-hostprogs-werror-fix-v1-1-23cf1ffced5c@kernel.org Signed-off-by: Nathan Chancellor <nathan@kernel.org>
1 parent 66128f4 commit 7ded7d3

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

scripts/Makefile.extrawarn

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,9 +223,11 @@ KBUILD_USERCFLAGS += -Werror
223223
KBUILD_USERLDFLAGS += -Wl,--fatal-warnings
224224
KBUILD_RUSTFLAGS += -Dwarnings
225225

226-
endif
227-
228-
# Hostprog flags are used during build bootstrapping and can not rely on CONFIG_ symbols.
226+
# While hostprog flags are used during build bootstrapping (thus should not
227+
# depend on CONFIG_ symbols), -Werror is disruptive and should be opted into.
228+
# Only apply -Werror to hostprogs built after the initial Kconfig stage.
229229
KBUILD_HOSTCFLAGS += -Werror
230230
KBUILD_HOSTLDFLAGS += -Wl,--fatal-warnings
231231
KBUILD_HOSTRUSTFLAGS += -Dwarnings
232+
233+
endif

0 commit comments

Comments
 (0)