* [PATCH v1 1/1] compiler_types: Warn about unused static inline functions on second
@ 2025-11-06 10:50 Andy Shevchenko
2025-11-06 15:16 ` Nathan Chancellor
2025-11-07 18:29 ` Nathan Chancellor
0 siblings, 2 replies; 7+ messages in thread
From: Andy Shevchenko @ 2025-11-06 10:50 UTC (permalink / raw)
To: linux-kernel, llvm
Cc: Nathan Chancellor, Nick Desaulniers, Bill Wendling, Justin Stitt,
Linus Torvalds, Dan Williams, Jonathan Cameron, Peter Zijlstra,
Andy Shevchenko
From: Peter Zijlstra <peterz@infradead.org>
Per Nathan, clang catches unused "static inline" functions in C files since
commit 6863f5643dd7 ("kbuild: allow Clang to find unused static inline
functions for W=1 build").
Linus said:
> So I entirely ignore W=1 issues, because I think so many of the extra
> warnings are bogus.
>
> But if this one in particular is causing more problems than most -
> some teams do seem to use W=1 as part of their test builds - it's fine
> to send me a patch that just moves bad warnings to W=2.
>
> And if anybody uses W=2 for their test builds, that's THEIR problem..
Here is the change to bump the warning from W=1 to W=2.
Fixes: 6863f5643dd7 ("kbuild: allow Clang to find unused static inline functions for W=1 build")
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
include/linux/compiler_types.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h
index 59288a2c1ad2..575a03643fa1 100644
--- a/include/linux/compiler_types.h
+++ b/include/linux/compiler_types.h
@@ -253,7 +253,7 @@ struct ftrace_likely_data {
* for W=1 build. This will allow clang to find unused functions. Remove the
* __inline_maybe_unused entirely after fixing most of -Wunused-function warnings.
*/
-#ifdef KBUILD_EXTRA_WARN1
+#ifdef KBUILD_EXTRA_WARN2
#define __inline_maybe_unused
#else
#define __inline_maybe_unused __maybe_unused
--
2.50.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v1 1/1] compiler_types: Warn about unused static inline functions on second
2025-11-06 10:50 [PATCH v1 1/1] compiler_types: Warn about unused static inline functions on second Andy Shevchenko
@ 2025-11-06 15:16 ` Nathan Chancellor
2025-11-06 16:01 ` Andy Shevchenko
2025-11-06 19:13 ` Linus Torvalds
2025-11-07 18:29 ` Nathan Chancellor
1 sibling, 2 replies; 7+ messages in thread
From: Nathan Chancellor @ 2025-11-06 15:16 UTC (permalink / raw)
To: Andy Shevchenko
Cc: linux-kernel, llvm, Nick Desaulniers, Bill Wendling, Justin Stitt,
Linus Torvalds, Dan Williams, Jonathan Cameron, Peter Zijlstra
On Thu, Nov 06, 2025 at 11:50:00AM +0100, Andy Shevchenko wrote:
> From: Peter Zijlstra <peterz@infradead.org>
>
> Per Nathan, clang catches unused "static inline" functions in C files since
> commit 6863f5643dd7 ("kbuild: allow Clang to find unused static inline
> functions for W=1 build").
>
> Linus said:
>
> > So I entirely ignore W=1 issues, because I think so many of the extra
> > warnings are bogus.
> >
> > But if this one in particular is causing more problems than most -
> > some teams do seem to use W=1 as part of their test builds - it's fine
> > to send me a patch that just moves bad warnings to W=2.
> >
> > And if anybody uses W=2 for their test builds, that's THEIR problem..
>
> Here is the change to bump the warning from W=1 to W=2.
>
> Fixes: 6863f5643dd7 ("kbuild: allow Clang to find unused static inline functions for W=1 build")
> Signed-off-by: Peter Zijlstra <peterz@infradead.org>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
I can take this as a fix via kbuild or Linus can apply it directly
but...
> ---
> include/linux/compiler_types.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h
> index 59288a2c1ad2..575a03643fa1 100644
> --- a/include/linux/compiler_types.h
> +++ b/include/linux/compiler_types.h
> @@ -253,7 +253,7 @@ struct ftrace_likely_data {
> * for W=1 build. This will allow clang to find unused functions. Remove the
> * __inline_maybe_unused entirely after fixing most of -Wunused-function warnings.
> */
The comment should be updated to W=2 instead of W=1 and we should
probably drop the sentence about removing __inline_maybe_unused entirely
since people such as Peter will never want this behavior by default. I
do not mind doing it myself if I take it.
> -#ifdef KBUILD_EXTRA_WARN1
> +#ifdef KBUILD_EXTRA_WARN2
> #define __inline_maybe_unused
> #else
> #define __inline_maybe_unused __maybe_unused
> --
> 2.50.1
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v1 1/1] compiler_types: Warn about unused static inline functions on second
2025-11-06 15:16 ` Nathan Chancellor
@ 2025-11-06 16:01 ` Andy Shevchenko
2025-11-06 17:06 ` Nathan Chancellor
2025-11-06 19:13 ` Linus Torvalds
1 sibling, 1 reply; 7+ messages in thread
From: Andy Shevchenko @ 2025-11-06 16:01 UTC (permalink / raw)
To: Nathan Chancellor
Cc: linux-kernel, llvm, Nick Desaulniers, Bill Wendling, Justin Stitt,
Linus Torvalds, Dan Williams, Jonathan Cameron, Peter Zijlstra
On Thu, Nov 06, 2025 at 08:16:49AM -0700, Nathan Chancellor wrote:
> On Thu, Nov 06, 2025 at 11:50:00AM +0100, Andy Shevchenko wrote:
...
> > * for W=1 build. This will allow clang to find unused functions. Remove the
> > * __inline_maybe_unused entirely after fixing most of -Wunused-function warnings.
> The comment should be updated to W=2 instead of W=1
Granted.
> and we should
> probably drop the sentence about removing __inline_maybe_unused entirely
> since people such as Peter will never want this behavior by default. I
> do not mind doing it myself if I take it.
But future is uncertain, it might be that GCC also gains this and it won't
confuse anyway as it might become a truth (no more such warnings in the code)
at some point.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v1 1/1] compiler_types: Warn about unused static inline functions on second
2025-11-06 16:01 ` Andy Shevchenko
@ 2025-11-06 17:06 ` Nathan Chancellor
2025-11-07 7:45 ` Andy Shevchenko
0 siblings, 1 reply; 7+ messages in thread
From: Nathan Chancellor @ 2025-11-06 17:06 UTC (permalink / raw)
To: Andy Shevchenko
Cc: linux-kernel, llvm, Nick Desaulniers, Bill Wendling, Justin Stitt,
Linus Torvalds, Dan Williams, Jonathan Cameron, Peter Zijlstra
On Thu, Nov 06, 2025 at 06:01:03PM +0200, Andy Shevchenko wrote:
> On Thu, Nov 06, 2025 at 08:16:49AM -0700, Nathan Chancellor wrote:
> > and we should
> > probably drop the sentence about removing __inline_maybe_unused entirely
> > since people such as Peter will never want this behavior by default. I
> > do not mind doing it myself if I take it.
>
> But future is uncertain, it might be that GCC also gains this and it won't
> confuse anyway as it might become a truth (no more such warnings in the code)
> at some point.
The reality of the situation is that moving this warning to W=2 is
basically the same as just turning it off entirely since building with
W=2 is not a common endeavor for the majority of folks actually writing
kernel code, so the number of warnings will just continue to grow. At
that point, there is very little reason to believe that we would be able
to go from W=2 to enabled by default at some point in the future since
people already do not like it enabled at W=1 where it is not as
impactful as enabled by default. As a result, I feel like the comment
genuinely serves no purpose. If GCC were to change its behavior to
match clang, I feel like kernel folks would still want the current GCC
behavior.
Cheers,
Nathan
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v1 1/1] compiler_types: Warn about unused static inline functions on second
2025-11-06 15:16 ` Nathan Chancellor
2025-11-06 16:01 ` Andy Shevchenko
@ 2025-11-06 19:13 ` Linus Torvalds
1 sibling, 0 replies; 7+ messages in thread
From: Linus Torvalds @ 2025-11-06 19:13 UTC (permalink / raw)
To: Nathan Chancellor
Cc: Andy Shevchenko, linux-kernel, llvm, Nick Desaulniers,
Bill Wendling, Justin Stitt, Dan Williams, Jonathan Cameron,
Peter Zijlstra
On Thu, 6 Nov 2025 at 07:16, Nathan Chancellor <nathan@kernel.org> wrote:
>
> I can take this as a fix via kbuild or Linus can apply it directly
Yes, please just take it through the regular Kbuild tree (with
whatever modifications this thread then results in).
Thanks,
Linus
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v1 1/1] compiler_types: Warn about unused static inline functions on second
2025-11-06 17:06 ` Nathan Chancellor
@ 2025-11-07 7:45 ` Andy Shevchenko
0 siblings, 0 replies; 7+ messages in thread
From: Andy Shevchenko @ 2025-11-07 7:45 UTC (permalink / raw)
To: Nathan Chancellor
Cc: linux-kernel, llvm, Nick Desaulniers, Bill Wendling, Justin Stitt,
Linus Torvalds, Dan Williams, Jonathan Cameron, Peter Zijlstra
On Thu, Nov 06, 2025 at 10:06:16AM -0700, Nathan Chancellor wrote:
> On Thu, Nov 06, 2025 at 06:01:03PM +0200, Andy Shevchenko wrote:
> > On Thu, Nov 06, 2025 at 08:16:49AM -0700, Nathan Chancellor wrote:
> > > and we should
> > > probably drop the sentence about removing __inline_maybe_unused entirely
> > > since people such as Peter will never want this behavior by default. I
> > > do not mind doing it myself if I take it.
> >
> > But future is uncertain, it might be that GCC also gains this and it won't
> > confuse anyway as it might become a truth (no more such warnings in the code)
> > at some point.
>
> The reality of the situation is that moving this warning to W=2 is
> basically the same as just turning it off entirely since building with
> W=2 is not a common endeavor for the majority of folks actually writing
> kernel code, so the number of warnings will just continue to grow. At
> that point, there is very little reason to believe that we would be able
> to go from W=2 to enabled by default at some point in the future since
> people already do not like it enabled at W=1 where it is not as
> impactful as enabled by default. As a result, I feel like the comment
> genuinely serves no purpose. If GCC were to change its behavior to
> match clang, I feel like kernel folks would still want the current GCC
> behavior.
Okay, I won't object. But so far the patch taken as is, please fold the changes
you mention in it (will require rebase, but personally I don't care, all
depends on your workflow, followup is also fine to me).
And thanks for taking care of this!
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v1 1/1] compiler_types: Warn about unused static inline functions on second
2025-11-06 10:50 [PATCH v1 1/1] compiler_types: Warn about unused static inline functions on second Andy Shevchenko
2025-11-06 15:16 ` Nathan Chancellor
@ 2025-11-07 18:29 ` Nathan Chancellor
1 sibling, 0 replies; 7+ messages in thread
From: Nathan Chancellor @ 2025-11-07 18:29 UTC (permalink / raw)
To: linux-kernel, llvm, Andy Shevchenko
Cc: Nathan Chancellor, Nick Desaulniers, Bill Wendling, Justin Stitt,
Linus Torvalds, Dan Williams, Jonathan Cameron, Peter Zijlstra
On Thu, 06 Nov 2025 11:50:00 +0100, Andy Shevchenko wrote:
> Per Nathan, clang catches unused "static inline" functions in C files since
> commit 6863f5643dd7 ("kbuild: allow Clang to find unused static inline
> functions for W=1 build").
>
> Linus said:
>
> > So I entirely ignore W=1 issues, because I think so many of the extra
> > warnings are bogus.
> >
> > But if this one in particular is causing more problems than most -
> > some teams do seem to use W=1 as part of their test builds - it's fine
> > to send me a patch that just moves bad warnings to W=2.
> >
> > And if anybody uses W=2 for their test builds, that's THEIR problem..
>
> [...]
Applied, thanks!
[1/1] compiler_types: Warn about unused static inline functions on second
https://git.kernel.org/kbuild/c/9818af18db4bf
Best regards,
--
Nathan Chancellor <nathan@kernel.org>
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2025-11-07 18:29 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-06 10:50 [PATCH v1 1/1] compiler_types: Warn about unused static inline functions on second Andy Shevchenko
2025-11-06 15:16 ` Nathan Chancellor
2025-11-06 16:01 ` Andy Shevchenko
2025-11-06 17:06 ` Nathan Chancellor
2025-11-07 7:45 ` Andy Shevchenko
2025-11-06 19:13 ` Linus Torvalds
2025-11-07 18:29 ` Nathan Chancellor
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox