* [PATCH] scripts/Makefile.extrawarn: Respect CONFIG_WERROR / W=e for hostprogs
@ 2025-10-06 21:39 Nathan Chancellor
2025-10-07 6:27 ` Thomas Weißschuh
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Nathan Chancellor @ 2025-10-06 21:39 UTC (permalink / raw)
To: Nathan Chancellor, Nicolas Schier, Thomas Weißschuh
Cc: Askar Safin, Sam James, Miguel Ojeda, linux-kbuild, linux-kernel
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.
Fixes: 27758d8c2583 ("kbuild: enable -Werror for hostprogs")
Link: https://lore.kernel.org/20251005011100.1035272-1-safinaskar@gmail.com/
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
| 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
--git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn
index 1434cb6208cb..6af392f9cd02 100644
--- a/scripts/Makefile.extrawarn
+++ b/scripts/Makefile.extrawarn
@@ -223,9 +223,11 @@ KBUILD_USERCFLAGS += -Werror
KBUILD_USERLDFLAGS += -Wl,--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
---
base-commit: 2ea77fca84f07849aa995271271340d262d0c2e9
change-id: 20251006-kbuild-hostprogs-werror-fix-be6a3e123dfc
Best regards,
--
Nathan Chancellor <nathan@kernel.org>
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] scripts/Makefile.extrawarn: Respect CONFIG_WERROR / W=e for hostprogs
2025-10-06 21:39 [PATCH] scripts/Makefile.extrawarn: Respect CONFIG_WERROR / W=e for hostprogs Nathan Chancellor
@ 2025-10-07 6:27 ` Thomas Weißschuh
2025-10-07 16:00 ` Miguel Ojeda
2025-10-07 16:55 ` Nathan Chancellor
2 siblings, 0 replies; 5+ messages in thread
From: Thomas Weißschuh @ 2025-10-07 6:27 UTC (permalink / raw)
To: Nathan Chancellor
Cc: Nicolas Schier, Askar Safin, Sam James, Miguel Ojeda,
linux-kbuild, linux-kernel
On Mon, Oct 06, 2025 at 02:39:56PM -0700, Nathan Chancellor wrote:
> 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.
>
> Fixes: 27758d8c2583 ("kbuild: enable -Werror for hostprogs")
> Link: https://lore.kernel.org/20251005011100.1035272-1-safinaskar@gmail.com/
Reported-by: Askar Safin <safinaskar@gmail.com>
Closes: https://lore.kernel.org/20251005011100.1035272-1-safinaskar@gmail.com/
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Reviewed-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Thanks and sorry for the trouble!
> ---
> scripts/Makefile.extrawarn | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn
> index 1434cb6208cb..6af392f9cd02 100644
> --- a/scripts/Makefile.extrawarn
> +++ b/scripts/Makefile.extrawarn
> @@ -223,9 +223,11 @@ KBUILD_USERCFLAGS += -Werror
> KBUILD_USERLDFLAGS += -Wl,--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
>
> ---
> base-commit: 2ea77fca84f07849aa995271271340d262d0c2e9
> change-id: 20251006-kbuild-hostprogs-werror-fix-be6a3e123dfc
>
> Best regards,
> --
> Nathan Chancellor <nathan@kernel.org>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] scripts/Makefile.extrawarn: Respect CONFIG_WERROR / W=e for hostprogs
2025-10-06 21:39 [PATCH] scripts/Makefile.extrawarn: Respect CONFIG_WERROR / W=e for hostprogs Nathan Chancellor
2025-10-07 6:27 ` Thomas Weißschuh
@ 2025-10-07 16:00 ` Miguel Ojeda
2025-10-07 16:07 ` Miguel Ojeda
2025-10-07 16:55 ` Nathan Chancellor
2 siblings, 1 reply; 5+ messages in thread
From: Miguel Ojeda @ 2025-10-07 16:00 UTC (permalink / raw)
To: Nathan Chancellor
Cc: Nicolas Schier, Thomas Weißschuh, Askar Safin, Sam James,
Miguel Ojeda, linux-kbuild, linux-kernel
On Mon, Oct 6, 2025 at 11:40 PM Nathan Chancellor <nathan@kernel.org> wrote:
>
> 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.
>
> Fixes: 27758d8c2583 ("kbuild: enable -Werror for hostprogs")
> Link: https://lore.kernel.org/20251005011100.1035272-1-safinaskar@gmail.com/
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Acked-by: Miguel Ojeda <ojeda@kernel.org>
Cheers,
Miguel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] scripts/Makefile.extrawarn: Respect CONFIG_WERROR / W=e for hostprogs
2025-10-07 16:00 ` Miguel Ojeda
@ 2025-10-07 16:07 ` Miguel Ojeda
0 siblings, 0 replies; 5+ messages in thread
From: Miguel Ojeda @ 2025-10-07 16:07 UTC (permalink / raw)
To: Nathan Chancellor
Cc: Nicolas Schier, Thomas Weißschuh, Askar Safin, Sam James,
Miguel Ojeda, linux-kbuild, linux-kernel
On Tue, Oct 7, 2025 at 6:00 PM Miguel Ojeda
<miguel.ojeda.sandonis@gmail.com> wrote:
>
> Acked-by: Miguel Ojeda <ojeda@kernel.org>
I also tested that for Rust hostprogs it now respects `WERROR` and
`W=e` as expected:
Tested-by: Miguel Ojeda <ojeda@kernel.org> # Rust
Thanks!
Cheers,
Miguel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] scripts/Makefile.extrawarn: Respect CONFIG_WERROR / W=e for hostprogs
2025-10-06 21:39 [PATCH] scripts/Makefile.extrawarn: Respect CONFIG_WERROR / W=e for hostprogs Nathan Chancellor
2025-10-07 6:27 ` Thomas Weißschuh
2025-10-07 16:00 ` Miguel Ojeda
@ 2025-10-07 16:55 ` Nathan Chancellor
2 siblings, 0 replies; 5+ messages in thread
From: Nathan Chancellor @ 2025-10-07 16:55 UTC (permalink / raw)
To: Nicolas Schier, Thomas Weißschuh, Nathan Chancellor
Cc: Askar Safin, Sam James, Miguel Ojeda, linux-kbuild, linux-kernel
On Mon, 06 Oct 2025 14:39:56 -0700, Nathan Chancellor wrote:
> 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).
>
> [...]
Applied, thanks!
[1/1] scripts/Makefile.extrawarn: Respect CONFIG_WERROR / W=e for hostprogs
https://git.kernel.org/kbuild/c/7ded7d37e5f5b
Best regards,
--
Nathan Chancellor <nathan@kernel.org>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-10-07 16:55 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-06 21:39 [PATCH] scripts/Makefile.extrawarn: Respect CONFIG_WERROR / W=e for hostprogs Nathan Chancellor
2025-10-07 6:27 ` Thomas Weißschuh
2025-10-07 16:00 ` Miguel Ojeda
2025-10-07 16:07 ` Miguel Ojeda
2025-10-07 16:55 ` Nathan Chancellor
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).