* [PATCH v2 0/6] kbuild: enable CONFIG_WERROR for more build steps
@ 2025-08-14 10:14 Thomas Weißschuh
2025-08-14 10:14 ` [PATCH v2 1/6] kbuild: align W=e with CONFIG_WERROR Thomas Weißschuh
` (6 more replies)
0 siblings, 7 replies; 18+ messages in thread
From: Thomas Weißschuh @ 2025-08-14 10:14 UTC (permalink / raw)
To: Nathan Chancellor, Nicolas Schier, Miguel Ojeda, Alex Gaynor,
Boqun Feng, Gary Guo, Björn Roy Baron, Benno Lossin,
Andreas Hindborg, Alice Ryhl, Trevor Gross, Danilo Krummrich
Cc: linux-kbuild, linux-kernel, rust-for-linux, Thomas Weißschuh
CONFIG_WERROR is useful for all build steps, not only compilation of C and
Rust sources linked into the kernel.
Also enable it for assembler and linker invocations and userprogs.
In addition unify the implementations of CONFIG_WERROR and W=e.
This partially implements features of Miguel's Rust -Werror series [0].
The changes to $(common_rust_flags) are not incorporated as it also modifies
Rust hostprog flags.
[0] https://lore.kernel.org/rust-for-linux/20240519211235.589325-2-ojeda@kernel.org
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
---
Changes in v2:
- Unify CONFIG_WERROR with W=e
- Unconditionally enable -Werror for C and Rust hostprogs
- Link to v1: https://lore.kernel.org/r/20250812-kbuild-werror-v1-0-36c9ff653700@linutronix.de
---
Miguel Ojeda (1):
kbuild: rust: move `-Dwarnings` handling to `Makefile.extrawarn`
Thomas Weißschuh (5):
kbuild: align W=e with CONFIG_WERROR
kbuild: unify W=e and CONFIG_WERROR
kbuild: respect CONFIG_WERROR for linker and assembler
kbuild: respect CONFIG_WERROR for userprogs
kbuild: enable -Werror for hostprogs
Makefile | 3 ---
scripts/Makefile.extrawarn | 18 +++++++++++++-----
2 files changed, 13 insertions(+), 8 deletions(-)
---
base-commit: e8ee794a1f7705edd64b9eb9837e7baa4421c084
change-id: 20250801-kbuild-werror-081f72fee1de
Best regards,
--
Thomas Weißschuh <thomas.weissschuh@linutronix.de>
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH v2 1/6] kbuild: align W=e with CONFIG_WERROR
2025-08-14 10:14 [PATCH v2 0/6] kbuild: enable CONFIG_WERROR for more build steps Thomas Weißschuh
@ 2025-08-14 10:14 ` Thomas Weißschuh
2025-08-14 10:14 ` [PATCH v2 2/6] kbuild: unify W=e and CONFIG_WERROR Thomas Weißschuh
` (5 subsequent siblings)
6 siblings, 0 replies; 18+ messages in thread
From: Thomas Weißschuh @ 2025-08-14 10:14 UTC (permalink / raw)
To: Nathan Chancellor, Nicolas Schier, Miguel Ojeda, Alex Gaynor,
Boqun Feng, Gary Guo, Björn Roy Baron, Benno Lossin,
Andreas Hindborg, Alice Ryhl, Trevor Gross, Danilo Krummrich
Cc: linux-kbuild, linux-kernel, rust-for-linux, Thomas Weißschuh
CONFIG_WERROR sets KBUILD_CPPFLAGS while W=e would only set KBUILD_CFLAGS.
As a preparation to unify the two mechanism, align their effects.
While at it, add some alignment whitespace to prepare for later additions
to the list of changed variables.
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
---
| 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn
index dca175fffcabeb2d942814f0a096a7efbf8bc819..4b4e8e136ce6b45f43dc7658eda78ae2b37bd792 100644
--- a/scripts/Makefile.extrawarn
+++ b/scripts/Makefile.extrawarn
@@ -218,6 +218,6 @@ endif
#
ifneq ($(findstring e, $(KBUILD_EXTRA_WARN)),)
-KBUILD_CFLAGS += -Werror
+KBUILD_CPPFLAGS += -Werror
endif
--
2.50.1
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH v2 2/6] kbuild: unify W=e and CONFIG_WERROR
2025-08-14 10:14 [PATCH v2 0/6] kbuild: enable CONFIG_WERROR for more build steps Thomas Weißschuh
2025-08-14 10:14 ` [PATCH v2 1/6] kbuild: align W=e with CONFIG_WERROR Thomas Weißschuh
@ 2025-08-14 10:14 ` Thomas Weißschuh
2025-08-14 10:14 ` [PATCH v2 3/6] kbuild: rust: move `-Dwarnings` handling to `Makefile.extrawarn` Thomas Weißschuh
` (4 subsequent siblings)
6 siblings, 0 replies; 18+ messages in thread
From: Thomas Weißschuh @ 2025-08-14 10:14 UTC (permalink / raw)
To: Nathan Chancellor, Nicolas Schier, Miguel Ojeda, Alex Gaynor,
Boqun Feng, Gary Guo, Björn Roy Baron, Benno Lossin,
Andreas Hindborg, Alice Ryhl, Trevor Gross, Danilo Krummrich
Cc: linux-kbuild, linux-kernel, rust-for-linux, Thomas Weißschuh
The two mechanisms have the same effect, unify their implementation.
Also avoid spurious rebuilds when switching between the two.
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
---
| 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
--git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn
index 4b4e8e136ce6b45f43dc7658eda78ae2b37bd792..1ffc7beca43bc9e373064194dc8975182815a872 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
@@ -214,9 +212,9 @@ KBUILD_CFLAGS += -Wno-unused-parameter
endif
#
-# W=e - error out on warnings
+# W=e and CONFIG_WERROR - error out on warnings
#
-ifneq ($(findstring e, $(KBUILD_EXTRA_WARN)),)
+ifneq ($(findstring e, $(KBUILD_EXTRA_WARN))$(CONFIG_WERROR),)
KBUILD_CPPFLAGS += -Werror
--
2.50.1
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH v2 3/6] kbuild: rust: move `-Dwarnings` handling to `Makefile.extrawarn`
2025-08-14 10:14 [PATCH v2 0/6] kbuild: enable CONFIG_WERROR for more build steps Thomas Weißschuh
2025-08-14 10:14 ` [PATCH v2 1/6] kbuild: align W=e with CONFIG_WERROR Thomas Weißschuh
2025-08-14 10:14 ` [PATCH v2 2/6] kbuild: unify W=e and CONFIG_WERROR Thomas Weißschuh
@ 2025-08-14 10:14 ` Thomas Weißschuh
2025-08-14 10:14 ` [PATCH v2 4/6] kbuild: respect CONFIG_WERROR for linker and assembler Thomas Weißschuh
` (3 subsequent siblings)
6 siblings, 0 replies; 18+ messages in thread
From: Thomas Weißschuh @ 2025-08-14 10:14 UTC (permalink / raw)
To: Nathan Chancellor, Nicolas Schier, Miguel Ojeda, Alex Gaynor,
Boqun Feng, Gary Guo, Björn Roy Baron, Benno Lossin,
Andreas Hindborg, Alice Ryhl, Trevor Gross, Danilo Krummrich
Cc: linux-kbuild, linux-kernel, rust-for-linux, Thomas Weißschuh
From: Miguel Ojeda <ojeda@kernel.org>
Following commit e88ca24319e4 ("kbuild: consolidate warning flags
in scripts/Makefile.extrawarn"), move `-Dwarnings` handling into
`Makefile.extrawarn` like C's `-Werror`.
No functional change intended.
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
---
Makefile | 3 ---
| 1 +
2 files changed, 1 insertion(+), 3 deletions(-)
diff --git a/Makefile b/Makefile
index 6bfe776bf3c5ff0cf187dc6719dd5817cd4af2ca..6630a66659c6d1ca7e72448b04d16c3fdd1fbe24 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
--git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn
index 1ffc7beca43bc9e373064194dc8975182815a872..b04b3062e0e49c3ae7471973251017e8738cd244 100644
--- a/scripts/Makefile.extrawarn
+++ b/scripts/Makefile.extrawarn
@@ -217,5 +217,6 @@ endif
ifneq ($(findstring e, $(KBUILD_EXTRA_WARN))$(CONFIG_WERROR),)
KBUILD_CPPFLAGS += -Werror
+KBUILD_RUSTFLAGS += -Dwarnings
endif
--
2.50.1
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH v2 4/6] kbuild: respect CONFIG_WERROR for linker and assembler
2025-08-14 10:14 [PATCH v2 0/6] kbuild: enable CONFIG_WERROR for more build steps Thomas Weißschuh
` (2 preceding siblings ...)
2025-08-14 10:14 ` [PATCH v2 3/6] kbuild: rust: move `-Dwarnings` handling to `Makefile.extrawarn` Thomas Weißschuh
@ 2025-08-14 10:14 ` Thomas Weißschuh
2025-08-14 10:14 ` [PATCH v2 5/6] kbuild: respect CONFIG_WERROR for userprogs Thomas Weißschuh
` (2 subsequent siblings)
6 siblings, 0 replies; 18+ messages in thread
From: Thomas Weißschuh @ 2025-08-14 10:14 UTC (permalink / raw)
To: Nathan Chancellor, Nicolas Schier, Miguel Ojeda, Alex Gaynor,
Boqun Feng, Gary Guo, Björn Roy Baron, Benno Lossin,
Andreas Hindborg, Alice Ryhl, Trevor Gross, Danilo Krummrich
Cc: linux-kbuild, linux-kernel, rust-for-linux, Thomas Weißschuh
The linker and assembler do not share the compiler flags.
Make sure they also fail on warnings with CONFIG_WERROR and W=e.
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
---
| 2 ++
1 file changed, 2 insertions(+)
--git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn
index b04b3062e0e49c3ae7471973251017e8738cd244..6efb9e5eeeed0696a061a17e029a92caba50826f 100644
--- a/scripts/Makefile.extrawarn
+++ b/scripts/Makefile.extrawarn
@@ -217,6 +217,8 @@ endif
ifneq ($(findstring e, $(KBUILD_EXTRA_WARN))$(CONFIG_WERROR),)
KBUILD_CPPFLAGS += -Werror
+KBUILD_AFLAGS += -Wa,--fatal-warnings
+KBUILD_LDFLAGS += --fatal-warnings
KBUILD_RUSTFLAGS += -Dwarnings
endif
--
2.50.1
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH v2 5/6] kbuild: respect CONFIG_WERROR for userprogs
2025-08-14 10:14 [PATCH v2 0/6] kbuild: enable CONFIG_WERROR for more build steps Thomas Weißschuh
` (3 preceding siblings ...)
2025-08-14 10:14 ` [PATCH v2 4/6] kbuild: respect CONFIG_WERROR for linker and assembler Thomas Weißschuh
@ 2025-08-14 10:14 ` Thomas Weißschuh
2025-08-14 10:14 ` [PATCH v2 6/6] kbuild: enable -Werror for hostprogs Thomas Weißschuh
2025-08-14 19:11 ` [PATCH v2 0/6] kbuild: enable CONFIG_WERROR for more build steps Nathan Chancellor
6 siblings, 0 replies; 18+ messages in thread
From: Thomas Weißschuh @ 2025-08-14 10:14 UTC (permalink / raw)
To: Nathan Chancellor, Nicolas Schier, Miguel Ojeda, Alex Gaynor,
Boqun Feng, Gary Guo, Björn Roy Baron, Benno Lossin,
Andreas Hindborg, Alice Ryhl, Trevor Gross, Danilo Krummrich
Cc: linux-kbuild, linux-kernel, rust-for-linux, Thomas Weißschuh
The userprogs compiler and linker do not share the regular compiler flags.
Make sure they also fail on warnings with CONFIG_WERROR and W=e.
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
---
| 2 ++
1 file changed, 2 insertions(+)
--git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn
index 6efb9e5eeeed0696a061a17e029a92caba50826f..96ff3f5582d651f0016c8ccd49d46022cc6fe070 100644
--- a/scripts/Makefile.extrawarn
+++ b/scripts/Makefile.extrawarn
@@ -219,6 +219,8 @@ ifneq ($(findstring e, $(KBUILD_EXTRA_WARN))$(CONFIG_WERROR),)
KBUILD_CPPFLAGS += -Werror
KBUILD_AFLAGS += -Wa,--fatal-warnings
KBUILD_LDFLAGS += --fatal-warnings
+KBUILD_USERCFLAGS += -Werror
+KBUILD_USERLDFLAGS += -Wl,--fatal-warnings
KBUILD_RUSTFLAGS += -Dwarnings
endif
--
2.50.1
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH v2 6/6] kbuild: enable -Werror for hostprogs
2025-08-14 10:14 [PATCH v2 0/6] kbuild: enable CONFIG_WERROR for more build steps Thomas Weißschuh
` (4 preceding siblings ...)
2025-08-14 10:14 ` [PATCH v2 5/6] kbuild: respect CONFIG_WERROR for userprogs Thomas Weißschuh
@ 2025-08-14 10:14 ` Thomas Weißschuh
2025-08-14 12:10 ` Nicolas Schier
` (2 more replies)
2025-08-14 19:11 ` [PATCH v2 0/6] kbuild: enable CONFIG_WERROR for more build steps Nathan Chancellor
6 siblings, 3 replies; 18+ messages in thread
From: Thomas Weißschuh @ 2025-08-14 10:14 UTC (permalink / raw)
To: Nathan Chancellor, Nicolas Schier, Miguel Ojeda, Alex Gaynor,
Boqun Feng, Gary Guo, Björn Roy Baron, Benno Lossin,
Andreas Hindborg, Alice Ryhl, Trevor Gross, Danilo Krummrich
Cc: linux-kbuild, linux-kernel, rust-for-linux, Thomas Weißschuh
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/
---
| 5 +++++
1 file changed, 5 insertions(+)
--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
^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [PATCH v2 6/6] kbuild: enable -Werror for hostprogs
2025-08-14 10:14 ` [PATCH v2 6/6] kbuild: enable -Werror for hostprogs Thomas Weißschuh
@ 2025-08-14 12:10 ` Nicolas Schier
2025-08-14 18:30 ` Nathan Chancellor
2025-08-17 16:31 ` Miguel Ojeda
2025-10-05 1:10 ` Askar Safin
2 siblings, 1 reply; 18+ messages in thread
From: Nicolas Schier @ 2025-08-14 12:10 UTC (permalink / raw)
To: Thomas Weißschuh
Cc: Nathan Chancellor, Miguel Ojeda, Alex Gaynor, Boqun Feng,
Gary Guo, Björn Roy Baron, Benno Lossin, Andreas Hindborg,
Alice Ryhl, Trevor Gross, Danilo Krummrich, linux-kbuild,
linux-kernel, rust-for-linux
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
>
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v2 6/6] kbuild: enable -Werror for hostprogs
2025-08-14 12:10 ` Nicolas Schier
@ 2025-08-14 18:30 ` Nathan Chancellor
0 siblings, 0 replies; 18+ messages in thread
From: Nathan Chancellor @ 2025-08-14 18:30 UTC (permalink / raw)
To: Nicolas Schier
Cc: Thomas Weißschuh, Miguel Ojeda, Alex Gaynor, Boqun Feng,
Gary Guo, Björn Roy Baron, Benno Lossin, Andreas Hindborg,
Alice Ryhl, Trevor Gross, Danilo Krummrich, linux-kbuild,
linux-kernel, rust-for-linux
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
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v2 0/6] kbuild: enable CONFIG_WERROR for more build steps
2025-08-14 10:14 [PATCH v2 0/6] kbuild: enable CONFIG_WERROR for more build steps Thomas Weißschuh
` (5 preceding siblings ...)
2025-08-14 10:14 ` [PATCH v2 6/6] kbuild: enable -Werror for hostprogs Thomas Weißschuh
@ 2025-08-14 19:11 ` Nathan Chancellor
6 siblings, 0 replies; 18+ messages in thread
From: Nathan Chancellor @ 2025-08-14 19:11 UTC (permalink / raw)
To: Nicolas Schier, Miguel Ojeda, Alex Gaynor, Boqun Feng, Gary Guo,
Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
Trevor Gross, Danilo Krummrich, Thomas Weißschuh
Cc: linux-kbuild, linux-kernel, rust-for-linux
On Thu, 14 Aug 2025 12:14:40 +0200, Thomas Weißschuh wrote:
> CONFIG_WERROR is useful for all build steps, not only compilation of C and
> Rust sources linked into the kernel.
>
> Also enable it for assembler and linker invocations and userprogs.
>
> In addition unify the implementations of CONFIG_WERROR and W=e.
>
> [...]
Applied, thanks!
[1/6] kbuild: align W=e with CONFIG_WERROR
https://git.kernel.org/kbuild/c/f852ce052a8b7
[2/6] kbuild: unify W=e and CONFIG_WERROR
https://git.kernel.org/kbuild/c/e7a10929c574c
[3/6] kbuild: rust: move `-Dwarnings` handling to `Makefile.extrawarn`
https://git.kernel.org/kbuild/c/592b571f20c5b
[4/6] kbuild: respect CONFIG_WERROR for linker and assembler
https://git.kernel.org/kbuild/c/ec4a3992bc0b5
[5/6] kbuild: respect CONFIG_WERROR for userprogs
https://git.kernel.org/kbuild/c/3f0ff4cc6ffb4
[6/6] kbuild: enable -Werror for hostprogs
https://git.kernel.org/kbuild/c/a646e96080cd5
Best regards,
--
Nathan Chancellor <nathan@kernel.org>
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v2 6/6] kbuild: enable -Werror for hostprogs
2025-08-14 10:14 ` [PATCH v2 6/6] kbuild: enable -Werror for hostprogs Thomas Weißschuh
2025-08-14 12:10 ` Nicolas Schier
@ 2025-08-17 16:31 ` Miguel Ojeda
2025-08-18 17:45 ` Nathan Chancellor
2025-10-05 1:10 ` Askar Safin
2 siblings, 1 reply; 18+ messages in thread
From: Miguel Ojeda @ 2025-08-17 16:31 UTC (permalink / raw)
To: Thomas Weißschuh
Cc: Nathan Chancellor, Nicolas Schier, Miguel Ojeda, Alex Gaynor,
Boqun Feng, Gary Guo, Björn Roy Baron, Benno Lossin,
Andreas Hindborg, Alice Ryhl, Trevor Gross, Danilo Krummrich,
linux-kbuild, linux-kernel, rust-for-linux
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
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v2 6/6] kbuild: enable -Werror for hostprogs
2025-08-17 16:31 ` Miguel Ojeda
@ 2025-08-18 17:45 ` Nathan Chancellor
0 siblings, 0 replies; 18+ messages in thread
From: Nathan Chancellor @ 2025-08-18 17:45 UTC (permalink / raw)
To: Miguel Ojeda
Cc: Thomas Weißschuh, Nicolas Schier, Miguel Ojeda, Alex Gaynor,
Boqun Feng, Gary Guo, Björn Roy Baron, Benno Lossin,
Andreas Hindborg, Alice Ryhl, Trevor Gross, Danilo Krummrich,
linux-kbuild, linux-kernel, rust-for-linux
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
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v2 6/6] kbuild: enable -Werror for hostprogs
2025-08-14 10:14 ` [PATCH v2 6/6] kbuild: enable -Werror for hostprogs Thomas Weißschuh
2025-08-14 12:10 ` Nicolas Schier
2025-08-17 16:31 ` Miguel Ojeda
@ 2025-10-05 1:10 ` Askar Safin
2025-10-05 1:31 ` Sam James
2025-10-05 20:53 ` Nathan Chancellor
2 siblings, 2 replies; 18+ messages in thread
From: Askar Safin @ 2025-10-05 1:10 UTC (permalink / raw)
To: thomas.weissschuh
Cc: a.hindborg, alex.gaynor, aliceryhl, bjorn3_gh, boqun.feng, dakr,
gary, linux-kbuild, linux-kernel, lossin, nathan, nicolas.schier,
ojeda, rust-for-linux, tmgross
"Thomas Weißschuh" <thomas.weissschuh@linutronix.de>:
> Enable -Werror unconditionally
Please, drop this patch.
Never enable -Werror unconditionally for any part of build.
I often bisect Linux. And to do this, I often need to build very old
Linux commits (with modern compiler). Unconditional -Werror will make
this impossible.
For example, recently I found this regression:
https://lore.kernel.org/regressions/197f290e30b.eaadc7bc7913.7315623184036672946@zohomail.com/T/#u
The regression caused by commits happened in 2019.
So to bisect it, I had to build 2019 trees using modern compiler.
--
Askar Safin
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v2 6/6] kbuild: enable -Werror for hostprogs
2025-10-05 1:10 ` Askar Safin
@ 2025-10-05 1:31 ` Sam James
2025-10-05 20:53 ` Nathan Chancellor
1 sibling, 0 replies; 18+ messages in thread
From: Sam James @ 2025-10-05 1:31 UTC (permalink / raw)
To: safinaskar
Cc: a.hindborg, alex.gaynor, aliceryhl, bjorn3_gh, boqun.feng, dakr,
gary, linux-kbuild, linux-kernel, lossin, nathan, nicolas.schier,
ojeda, rust-for-linux, thomas.weissschuh, tmgross
I tried to make this argument recently for libbpf but was unsuccessful:
https://lore.kernel.org/bpf/7e6c41e47c6a8ab73945e6aac319e0dd53337e1b.1751712192.git.sam@gentoo.org/
I agree, though.
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v2 6/6] kbuild: enable -Werror for hostprogs
2025-10-05 1:10 ` Askar Safin
2025-10-05 1:31 ` Sam James
@ 2025-10-05 20:53 ` Nathan Chancellor
2025-10-06 10:20 ` Thomas Weißschuh
2025-10-06 11:27 ` Miguel Ojeda
1 sibling, 2 replies; 18+ messages in thread
From: Nathan Chancellor @ 2025-10-05 20:53 UTC (permalink / raw)
To: Askar Safin, Thomas Weißschuh, Nicolas Schier
Cc: a.hindborg, alex.gaynor, aliceryhl, bjorn3_gh, boqun.feng, dakr,
gary, linux-kbuild, linux-kernel, lossin, ojeda, rust-for-linux,
tmgross, sam
Hi Askar,
On Sun, Oct 05, 2025 at 04:10:47AM +0300, Askar Safin wrote:
> "Thomas Weißschuh" <thomas.weissschuh@linutronix.de>:
> > Enable -Werror unconditionally
>
> Please, drop this patch.
This is already merged into Linus's tree so it cannot be dropped, it
would need to be reverted. However...
> Never enable -Werror unconditionally for any part of build.
>
> I often bisect Linux. And to do this, I often need to build very old
> Linux commits (with modern compiler). Unconditional -Werror will make
> this impossible.
>
> For example, recently I found this regression:
>
> https://lore.kernel.org/regressions/197f290e30b.eaadc7bc7913.7315623184036672946@zohomail.com/T/#u
>
> The regression caused by commits happened in 2019.
>
> So to bisect it, I had to build 2019 trees using modern compiler.
I do my fair share of bisecting old Linux trees with a modern compiler,
so I do understand that pain. While it is easy enough to avoid this
behavior with HOSTCFLAGS=-Wno-error or HOSTCFLAGS=-w and there are other
places that the kernel enables -Werror unconditionally, I do not want
this to be a major pain point for random people doing bisected,
especially when the host tools are fairly battle tested so warnings may
not be a big deal.
In looking further into this, I noticed that in its current state,
-Werror is not getting applied to scripts/basic/fixup or
scripts/kconfig/*.o files (seems $(include-y) happens to late?), which
was one of the reasons to avoid making it depend on CONFIG_WERROR or
W=e. If that's the case, we could probably make it opt in like the rest
of the warnings for the kernel, which should be a fair compromise
between wanting to make potential issues more obvious while not
impacting people who build old sources with new compilers.
Thomas and Nicolas, thoughts?
Cheers,
Nathan
diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn
index 1434cb6208cb..1a29598cf7cb 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 can not use on
+# CONFIG_ symbols), -Werror should be opted into, so only apply -Werror to
+# hostprogs built after the initial Kconfig bootstrap.
KBUILD_HOSTCFLAGS += -Werror
KBUILD_HOSTLDFLAGS += -Wl,--fatal-warnings
KBUILD_HOSTRUSTFLAGS += -Dwarnings
+
+endif
^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [PATCH v2 6/6] kbuild: enable -Werror for hostprogs
2025-10-05 20:53 ` Nathan Chancellor
@ 2025-10-06 10:20 ` Thomas Weißschuh
2025-10-06 11:27 ` Miguel Ojeda
1 sibling, 0 replies; 18+ messages in thread
From: Thomas Weißschuh @ 2025-10-06 10:20 UTC (permalink / raw)
To: Nathan Chancellor
Cc: Askar Safin, Nicolas Schier, a.hindborg, alex.gaynor, aliceryhl,
bjorn3_gh, boqun.feng, dakr, gary, linux-kbuild, linux-kernel,
lossin, ojeda, rust-for-linux, tmgross, sam
On Sun, Oct 05, 2025 at 01:53:35PM -0700, Nathan Chancellor wrote:
(...)
> In looking further into this, I noticed that in its current state,
> -Werror is not getting applied to scripts/basic/fixup or
> scripts/kconfig/*.o files (seems $(include-y) happens to late?), which
> was one of the reasons to avoid making it depend on CONFIG_WERROR or
> W=e. If that's the case, we could probably make it opt in like the rest
> of the warnings for the kernel, which should be a fair compromise
> between wanting to make potential issues more obvious while not
> impacting people who build old sources with new compilers.
>
> Thomas and Nicolas, thoughts?
Yeah, fixdep and script/kconfig seem to be specifically handled in the
'ifdef config-build' block in Makefile. And this happens explicitly
before 'include .../auto.conf'. So your diff below looks like the
correct solution. Thanks for taking a look!
Thomas
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v2 6/6] kbuild: enable -Werror for hostprogs
2025-10-05 20:53 ` Nathan Chancellor
2025-10-06 10:20 ` Thomas Weißschuh
@ 2025-10-06 11:27 ` Miguel Ojeda
2025-10-06 21:48 ` Nathan Chancellor
1 sibling, 1 reply; 18+ messages in thread
From: Miguel Ojeda @ 2025-10-06 11:27 UTC (permalink / raw)
To: Nathan Chancellor
Cc: Askar Safin, Thomas Weißschuh, Nicolas Schier, a.hindborg,
alex.gaynor, aliceryhl, bjorn3_gh, boqun.feng, dakr, gary,
linux-kbuild, linux-kernel, lossin, ojeda, rust-for-linux,
tmgross, sam
On Sun, Oct 5, 2025 at 10:53 PM Nathan Chancellor <nathan@kernel.org> wrote:
>
> Thomas and Nicolas, thoughts?
I think it would be good to eventually split the hostprog flags into 2
sets: the ones that are used for bootstrapping, and the ones that go
after that.
That way, we can get the best of both worlds, if I understand correctly.
Cheers,
Miguel
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v2 6/6] kbuild: enable -Werror for hostprogs
2025-10-06 11:27 ` Miguel Ojeda
@ 2025-10-06 21:48 ` Nathan Chancellor
0 siblings, 0 replies; 18+ messages in thread
From: Nathan Chancellor @ 2025-10-06 21:48 UTC (permalink / raw)
To: Miguel Ojeda
Cc: Askar Safin, Thomas Weißschuh, Nicolas Schier, a.hindborg,
alex.gaynor, aliceryhl, bjorn3_gh, boqun.feng, dakr, gary,
linux-kbuild, linux-kernel, lossin, ojeda, rust-for-linux,
tmgross, sam
On Mon, Oct 06, 2025 at 01:27:33PM +0200, Miguel Ojeda wrote:
> On Sun, Oct 5, 2025 at 10:53 PM Nathan Chancellor <nathan@kernel.org> wrote:
> >
> > Thomas and Nicolas, thoughts?
>
> I think it would be good to eventually split the hostprog flags into 2
> sets: the ones that are used for bootstrapping, and the ones that go
> after that.
>
> That way, we can get the best of both worlds, if I understand correctly.
Does that buy us much? We would not want -Werror applied to
scripts/basic or scripts/kconfig without consent from the user. W=e
could provide that at that stage of the build (with an adjustment of
where scripts/Makefile.extrawarn was included) but CONFIG_WERROR would
not be.
Given how frequently fixdep and kconfig are built, I am fairly confident
that new warnings wtihin them would be reported quickly, even without
-Werror, so I do not see it as too much of a loss. All other host
programs should be covered by that diff.
It may still be worth doing for other reasons but I would have to see
what such a change would actually look like in practice before
committing to it.
Cheers,
Nathan
^ permalink raw reply [flat|nested] 18+ messages in thread
end of thread, other threads:[~2025-10-06 21:48 UTC | newest]
Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-14 10:14 [PATCH v2 0/6] kbuild: enable CONFIG_WERROR for more build steps Thomas Weißschuh
2025-08-14 10:14 ` [PATCH v2 1/6] kbuild: align W=e with CONFIG_WERROR Thomas Weißschuh
2025-08-14 10:14 ` [PATCH v2 2/6] kbuild: unify W=e and CONFIG_WERROR Thomas Weißschuh
2025-08-14 10:14 ` [PATCH v2 3/6] kbuild: rust: move `-Dwarnings` handling to `Makefile.extrawarn` Thomas Weißschuh
2025-08-14 10:14 ` [PATCH v2 4/6] kbuild: respect CONFIG_WERROR for linker and assembler Thomas Weißschuh
2025-08-14 10:14 ` [PATCH v2 5/6] kbuild: respect CONFIG_WERROR for userprogs Thomas Weißschuh
2025-08-14 10:14 ` [PATCH v2 6/6] kbuild: enable -Werror for hostprogs Thomas Weißschuh
2025-08-14 12:10 ` Nicolas Schier
2025-08-14 18:30 ` Nathan Chancellor
2025-08-17 16:31 ` Miguel Ojeda
2025-08-18 17:45 ` Nathan Chancellor
2025-10-05 1:10 ` Askar Safin
2025-10-05 1:31 ` Sam James
2025-10-05 20:53 ` Nathan Chancellor
2025-10-06 10:20 ` Thomas Weißschuh
2025-10-06 11:27 ` Miguel Ojeda
2025-10-06 21:48 ` Nathan Chancellor
2025-08-14 19:11 ` [PATCH v2 0/6] kbuild: enable CONFIG_WERROR for more build steps 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).