[PATCH v2 6/6] kbuild: enable -Werror for hostprogs

Thomas Weißschuh posted 6 patches 1 month, 3 weeks ago
[PATCH v2 6/6] kbuild: enable -Werror for hostprogs
Posted by Thomas Weißschuh 1 month, 3 weeks ago
The hostprog compilers and linkers do not share the regular compiler flags,
so they are not affected by CONFIG_WERROR or W=e. As hostprogs are used
during the bootstrap of the build, they can't depend on kconfig options.

Enable -Werror unconditionally.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>

---
For testing in -next, as discussed in
https://lore.kernel.org/lkml/20250812-kbuild-werror-v1-2-36c9ff653700@linutronix.de/
---
 scripts/Makefile.extrawarn | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn
index 96ff3f5582d651f0016c8ccd49d46022cc6fe070..1434cb6208cb82f20aeb29cc8c059220d1a1f6d2 100644
--- a/scripts/Makefile.extrawarn
+++ b/scripts/Makefile.extrawarn
@@ -224,3 +224,8 @@ KBUILD_USERLDFLAGS	+= -Wl,--fatal-warnings
 KBUILD_RUSTFLAGS	+= -Dwarnings
 
 endif
+
+# Hostprog flags are used during build bootstrapping and can not rely on CONFIG_ symbols.
+KBUILD_HOSTCFLAGS	+= -Werror
+KBUILD_HOSTLDFLAGS	+= -Wl,--fatal-warnings
+KBUILD_HOSTRUSTFLAGS	+= -Dwarnings

-- 
2.50.1

Re: [PATCH v2 6/6] kbuild: enable -Werror for hostprogs
Posted by Miguel Ojeda 1 month, 2 weeks ago
On Thu, Aug 14, 2025 at 12:15 PM Thomas Weißschuh
<thomas.weissschuh@linutronix.de> wrote:
>
> The hostprog compilers and linkers do not share the regular compiler flags,
> so they are not affected by CONFIG_WERROR or W=e. As hostprogs are used
> during the bootstrap of the build, they can't depend on kconfig options.
>
> Enable -Werror unconditionally.
>
> Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
>
> ---
> For testing in -next, as discussed in
> https://lore.kernel.org/lkml/20250812-kbuild-werror-v1-2-36c9ff653700@linutronix.de/

The discussion was on patch 0, i.e. the next message in Lore's tree
view -- I would suggest adding it to the commit message for reference:

Link: https://lore.kernel.org/rust-for-linux/CANiq72k-PdSH2BNgbq=X+FhpyEErifSCKfO5ObXz6bu9_J8+fA@mail.gmail.com/

Anyway, since Nathan already applied it, and I see a couple patches on
top, no big deal if it cannot be added.

Thanks!

Cheers,
Miguel
Re: [PATCH v2 6/6] kbuild: enable -Werror for hostprogs
Posted by Nathan Chancellor 1 month, 2 weeks ago
On Sun, Aug 17, 2025 at 06:31:06PM +0200, Miguel Ojeda wrote:
> The discussion was on patch 0, i.e. the next message in Lore's tree
> view -- I would suggest adding it to the commit message for reference:
> 
> Link: https://lore.kernel.org/rust-for-linux/CANiq72k-PdSH2BNgbq=X+FhpyEErifSCKfO5ObXz6bu9_J8+fA@mail.gmail.com/
> 
> Anyway, since Nathan already applied it, and I see a couple patches on
> top, no big deal if it cannot be added.

I dropped the top patch due to a build failure:

https://lore.kernel.org/20250818140143.61b8c466@canb.auug.org.au/

So I was okay with just rebasing the top commit to amend this one,
especially when giving more context to the patch. Thanks for the
suggestion!

Cheers,
Nathan
Re: [PATCH v2 6/6] kbuild: enable -Werror for hostprogs
Posted by Nicolas Schier 1 month, 3 weeks ago
On Thu, Aug 14, 2025 at 12:14:46PM +0200, Thomas Weißschuh wrote:
> The hostprog compilers and linkers do not share the regular compiler flags,
> so they are not affected by CONFIG_WERROR or W=e. As hostprogs are used
> during the bootstrap of the build, they can't depend on kconfig options.
> 
> Enable -Werror unconditionally.
> 
> Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
> 
> ---
> For testing in -next, as discussed in
> https://lore.kernel.org/lkml/20250812-kbuild-werror-v1-2-36c9ff653700@linutronix.de/

yeah, I am not sure if this is a good change, but I am ok with testing
it in next, as Nathan suggested.

For the rest of the series:

Reviewed-by: Nicolas Schier <nsc@kernel.org>

Thanks.

> ---
>  scripts/Makefile.extrawarn | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn
> index 96ff3f5582d651f0016c8ccd49d46022cc6fe070..1434cb6208cb82f20aeb29cc8c059220d1a1f6d2 100644
> --- a/scripts/Makefile.extrawarn
> +++ b/scripts/Makefile.extrawarn
> @@ -224,3 +224,8 @@ KBUILD_USERLDFLAGS	+= -Wl,--fatal-warnings
>  KBUILD_RUSTFLAGS	+= -Dwarnings
>  
>  endif
> +
> +# Hostprog flags are used during build bootstrapping and can not rely on CONFIG_ symbols.
> +KBUILD_HOSTCFLAGS	+= -Werror
> +KBUILD_HOSTLDFLAGS	+= -Wl,--fatal-warnings
> +KBUILD_HOSTRUSTFLAGS	+= -Dwarnings
> 
> -- 
> 2.50.1
> 
Re: [PATCH v2 6/6] kbuild: enable -Werror for hostprogs
Posted by Nathan Chancellor 1 month, 2 weeks ago
On Thu, Aug 14, 2025 at 02:10:13PM +0200, Nicolas Schier wrote:
> On Thu, Aug 14, 2025 at 12:14:46PM +0200, Thomas Weißschuh wrote:
> > The hostprog compilers and linkers do not share the regular compiler flags,
> > so they are not affected by CONFIG_WERROR or W=e. As hostprogs are used
> > during the bootstrap of the build, they can't depend on kconfig options.
> > 
> > Enable -Werror unconditionally.
> > 
> > Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
> > 
> > ---
> > For testing in -next, as discussed in
> > https://lore.kernel.org/lkml/20250812-kbuild-werror-v1-2-36c9ff653700@linutronix.de/
> 
> yeah, I am not sure if this is a good change, but I am ok with testing
> it in next, as Nathan suggested.

Yeah, I will leave this as the top patch in kbuild-next for now so that
we can easily back out if it is disruptive.

> For the rest of the series:
> 
> Reviewed-by: Nicolas Schier <nsc@kernel.org>

I applied this tag to patches 1 through 5 and left it off of this one,
based on "for the rest of the series". Let me know if that was
unintentional.

Cheers,
Nathan