linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] Makefile.extrawarn: move -Wcast-align to W=3
@ 2020-10-26 22:03 Arnd Bergmann
  2020-10-26 22:03 ` [PATCH 2/2] Makefile.extrawarn: limit -Wnested-externs to clang Arnd Bergmann
  2020-10-27  1:42 ` [PATCH 1/2] Makefile.extrawarn: move -Wcast-align to W=3 Nathan Chancellor
  0 siblings, 2 replies; 8+ messages in thread
From: Arnd Bergmann @ 2020-10-26 22:03 UTC (permalink / raw)
  To: Masahiro Yamada, Michal Marek
  Cc: Arnd Bergmann, Nathan Chancellor, Nick Desaulniers, linux-kbuild,
	linux-kernel, clang-built-linux

From: Arnd Bergmann <arnd@arndb.de>

This warning behaves differently depending on the architecture
and compiler. Using x86 gcc, we get no output at all because
gcc knows the architecture can handle unaligned accesses.

Using x86 clang, or gcc on an architecture that needs to
manually deal with unaligned accesses, the build log is
completely flooded with these warnings, as they are commonly
invoked by inline functions of networking headers, e.g.

include/linux/skbuff.h:1426:26: warning: cast increases required alignment of target type [-Wcast-align]

The compiler is correct to point this out, as we are dealing
with undefined behavior that does cause problems in practice,
but there is also no good way to rewrite the code in commonly
included headers to a safer method.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 scripts/Makefile.extrawarn | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn
index 95e4cdb94fe9..6baee1200615 100644
--- a/scripts/Makefile.extrawarn
+++ b/scripts/Makefile.extrawarn
@@ -60,7 +60,6 @@ endif
 #
 ifneq ($(findstring 2, $(KBUILD_EXTRA_WARN)),)
 
-KBUILD_CFLAGS += -Wcast-align
 KBUILD_CFLAGS += -Wdisabled-optimization
 KBUILD_CFLAGS += -Wnested-externs
 KBUILD_CFLAGS += -Wshadow
@@ -80,6 +79,7 @@ endif
 ifneq ($(findstring 3, $(KBUILD_EXTRA_WARN)),)
 
 KBUILD_CFLAGS += -Wbad-function-cast
+KBUILD_CFLAGS += -Wcast-align
 KBUILD_CFLAGS += -Wcast-qual
 KBUILD_CFLAGS += -Wconversion
 KBUILD_CFLAGS += -Wpacked
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/2] Makefile.extrawarn: limit -Wnested-externs to clang
  2020-10-26 22:03 [PATCH 1/2] Makefile.extrawarn: move -Wcast-align to W=3 Arnd Bergmann
@ 2020-10-26 22:03 ` Arnd Bergmann
  2020-10-27  1:48   ` Nathan Chancellor
  2020-10-27  1:42 ` [PATCH 1/2] Makefile.extrawarn: move -Wcast-align to W=3 Nathan Chancellor
  1 sibling, 1 reply; 8+ messages in thread
From: Arnd Bergmann @ 2020-10-26 22:03 UTC (permalink / raw)
  To: Masahiro Yamada, Michal Marek
  Cc: Arnd Bergmann, Nathan Chancellor, Nick Desaulniers, linux-kbuild,
	linux-kernel, clang-built-linux

From: Arnd Bergmann <arnd@arndb.de>

The -Wnested-externs warning has become useless with gcc, since
this warns every time that BUILD_BUG_ON() or similar macros
are used.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 scripts/Makefile.extrawarn | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn
index 6baee1200615..9406f752e355 100644
--- a/scripts/Makefile.extrawarn
+++ b/scripts/Makefile.extrawarn
@@ -61,7 +61,10 @@ endif
 ifneq ($(findstring 2, $(KBUILD_EXTRA_WARN)),)
 
 KBUILD_CFLAGS += -Wdisabled-optimization
+ifdef CONFIG_CC_IS_CLANG
 KBUILD_CFLAGS += -Wnested-externs
+endif
+
 KBUILD_CFLAGS += -Wshadow
 KBUILD_CFLAGS += $(call cc-option, -Wlogical-op)
 KBUILD_CFLAGS += -Wmissing-field-initializers
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/2] Makefile.extrawarn: move -Wcast-align to W=3
  2020-10-26 22:03 [PATCH 1/2] Makefile.extrawarn: move -Wcast-align to W=3 Arnd Bergmann
  2020-10-26 22:03 ` [PATCH 2/2] Makefile.extrawarn: limit -Wnested-externs to clang Arnd Bergmann
@ 2020-10-27  1:42 ` Nathan Chancellor
  2020-11-23 11:17   ` Masahiro Yamada
  1 sibling, 1 reply; 8+ messages in thread
From: Nathan Chancellor @ 2020-10-27  1:42 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Masahiro Yamada, Michal Marek, Arnd Bergmann, Nick Desaulniers,
	linux-kbuild, linux-kernel, clang-built-linux

On Mon, Oct 26, 2020 at 11:03:13PM +0100, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> This warning behaves differently depending on the architecture
> and compiler. Using x86 gcc, we get no output at all because
> gcc knows the architecture can handle unaligned accesses.
> 
> Using x86 clang, or gcc on an architecture that needs to
> manually deal with unaligned accesses, the build log is
> completely flooded with these warnings, as they are commonly
> invoked by inline functions of networking headers, e.g.
> 
> include/linux/skbuff.h:1426:26: warning: cast increases required alignment of target type [-Wcast-align]
> 
> The compiler is correct to point this out, as we are dealing
> with undefined behavior that does cause problems in practice,
> but there is also no good way to rewrite the code in commonly
> included headers to a safer method.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Always sad to see a warning move further down the list but noisy headers
are rough to deal with. This seems okay.

Reviewed-by: Nathan Chancellor <natechancellor@gmail.com>

> ---
>  scripts/Makefile.extrawarn | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn
> index 95e4cdb94fe9..6baee1200615 100644
> --- a/scripts/Makefile.extrawarn
> +++ b/scripts/Makefile.extrawarn
> @@ -60,7 +60,6 @@ endif
>  #
>  ifneq ($(findstring 2, $(KBUILD_EXTRA_WARN)),)
>  
> -KBUILD_CFLAGS += -Wcast-align
>  KBUILD_CFLAGS += -Wdisabled-optimization
>  KBUILD_CFLAGS += -Wnested-externs
>  KBUILD_CFLAGS += -Wshadow
> @@ -80,6 +79,7 @@ endif
>  ifneq ($(findstring 3, $(KBUILD_EXTRA_WARN)),)
>  
>  KBUILD_CFLAGS += -Wbad-function-cast
> +KBUILD_CFLAGS += -Wcast-align
>  KBUILD_CFLAGS += -Wcast-qual
>  KBUILD_CFLAGS += -Wconversion
>  KBUILD_CFLAGS += -Wpacked
> -- 
> 2.27.0
> 

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/2] Makefile.extrawarn: limit -Wnested-externs to clang
  2020-10-26 22:03 ` [PATCH 2/2] Makefile.extrawarn: limit -Wnested-externs to clang Arnd Bergmann
@ 2020-10-27  1:48   ` Nathan Chancellor
  2020-10-27  4:32     ` Nathan Chancellor
  0 siblings, 1 reply; 8+ messages in thread
From: Nathan Chancellor @ 2020-10-27  1:48 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Masahiro Yamada, Michal Marek, Arnd Bergmann, Nick Desaulniers,
	linux-kbuild, linux-kernel, clang-built-linux

On Mon, Oct 26, 2020 at 11:03:14PM +0100, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> The -Wnested-externs warning has become useless with gcc, since
> this warns every time that BUILD_BUG_ON() or similar macros
> are used.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Also see:

2486baae2cf6 ("objtool: Allow nested externs to enable BUILD_BUG()")
6cf4ecf5c51d ("perf build: Allow nested externs to enable BUILD_BUG() usage")

Reviewed-by: Nathan Chancellor <natechancellor@gmail.com>

> ---
>  scripts/Makefile.extrawarn | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn
> index 6baee1200615..9406f752e355 100644
> --- a/scripts/Makefile.extrawarn
> +++ b/scripts/Makefile.extrawarn
> @@ -61,7 +61,10 @@ endif
>  ifneq ($(findstring 2, $(KBUILD_EXTRA_WARN)),)
>  
>  KBUILD_CFLAGS += -Wdisabled-optimization
> +ifdef CONFIG_CC_IS_CLANG
>  KBUILD_CFLAGS += -Wnested-externs
> +endif
> +
>  KBUILD_CFLAGS += -Wshadow
>  KBUILD_CFLAGS += $(call cc-option, -Wlogical-op)
>  KBUILD_CFLAGS += -Wmissing-field-initializers
> -- 
> 2.27.0
> 

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/2] Makefile.extrawarn: limit -Wnested-externs to clang
  2020-10-27  1:48   ` Nathan Chancellor
@ 2020-10-27  4:32     ` Nathan Chancellor
  2020-11-23 12:00       ` Masahiro Yamada
  0 siblings, 1 reply; 8+ messages in thread
From: Nathan Chancellor @ 2020-10-27  4:32 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Masahiro Yamada, Michal Marek, Arnd Bergmann, Nick Desaulniers,
	linux-kbuild, linux-kernel, clang-built-linux

On Mon, Oct 26, 2020 at 06:48:46PM -0700, Nathan Chancellor wrote:
> On Mon, Oct 26, 2020 at 11:03:14PM +0100, Arnd Bergmann wrote:
> > From: Arnd Bergmann <arnd@arndb.de>
> > 
> > The -Wnested-externs warning has become useless with gcc, since
> > this warns every time that BUILD_BUG_ON() or similar macros
> > are used.
> > 
> > Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> 
> Also see:
> 
> 2486baae2cf6 ("objtool: Allow nested externs to enable BUILD_BUG()")
> 6cf4ecf5c51d ("perf build: Allow nested externs to enable BUILD_BUG() usage")
> 
> Reviewed-by: Nathan Chancellor <natechancellor@gmail.com>

Actually, just delete this line altogether. -Wnested-externs is a GCC
only warning, the flag is only present in clang for compatibility with
GCC:

https://clang.llvm.org/docs/DiagnosticsReference.html#wnested-externs

With that, my reviewed by still stands.

Cheers,
Nathan

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/2] Makefile.extrawarn: move -Wcast-align to W=3
  2020-10-27  1:42 ` [PATCH 1/2] Makefile.extrawarn: move -Wcast-align to W=3 Nathan Chancellor
@ 2020-11-23 11:17   ` Masahiro Yamada
  2020-11-24 15:42     ` Arnd Bergmann
  0 siblings, 1 reply; 8+ messages in thread
From: Masahiro Yamada @ 2020-11-23 11:17 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: Arnd Bergmann, Michal Marek, Arnd Bergmann, Nick Desaulniers,
	Linux Kbuild mailing list, Linux Kernel Mailing List,
	clang-built-linux

On Tue, Oct 27, 2020 at 10:42 AM Nathan Chancellor
<natechancellor@gmail.com> wrote:
>
> On Mon, Oct 26, 2020 at 11:03:13PM +0100, Arnd Bergmann wrote:
> > From: Arnd Bergmann <arnd@arndb.de>
> >
> > This warning behaves differently depending on the architecture
> > and compiler. Using x86 gcc, we get no output at all because
> > gcc knows the architecture can handle unaligned accesses.
> >
> > Using x86 clang, or gcc on an architecture that needs to
> > manually deal with unaligned accesses, the build log is
> > completely flooded with these warnings, as they are commonly
> > invoked by inline functions of networking headers, e.g.
> >
> > include/linux/skbuff.h:1426:26: warning: cast increases required alignment of target type [-Wcast-align]
> >
> > The compiler is correct to point this out, as we are dealing
> > with undefined behavior that does cause problems in practice,
> > but there is also no good way to rewrite the code in commonly
> > included headers to a safer method.
> >
> > Signed-off-by: Arnd Bergmann <arnd@arndb.de>
>
> Always sad to see a warning move further down the list but noisy headers
> are rough to deal with. This seems okay.
>
> Reviewed-by: Nathan Chancellor <natechancellor@gmail.com>
>
> > ---
> >  scripts/Makefile.extrawarn | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn
> > index 95e4cdb94fe9..6baee1200615 100644
> > --- a/scripts/Makefile.extrawarn
> > +++ b/scripts/Makefile.extrawarn
> > @@ -60,7 +60,6 @@ endif
> >  #
> >  ifneq ($(findstring 2, $(KBUILD_EXTRA_WARN)),)
> >
> > -KBUILD_CFLAGS += -Wcast-align
> >  KBUILD_CFLAGS += -Wdisabled-optimization
> >  KBUILD_CFLAGS += -Wnested-externs
> >  KBUILD_CFLAGS += -Wshadow
> > @@ -80,6 +79,7 @@ endif
> >  ifneq ($(findstring 3, $(KBUILD_EXTRA_WARN)),)
> >
> >  KBUILD_CFLAGS += -Wbad-function-cast
> > +KBUILD_CFLAGS += -Wcast-align
> >  KBUILD_CFLAGS += -Wcast-qual
> >  KBUILD_CFLAGS += -Wconversion
> >  KBUILD_CFLAGS += -Wpacked
> > --
> > 2.27.0
> >


Applied to linux-kbuild. Thanks.

But, I think people already tend to ignore W=2 warnings.


-- 
Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/2] Makefile.extrawarn: limit -Wnested-externs to clang
  2020-10-27  4:32     ` Nathan Chancellor
@ 2020-11-23 12:00       ` Masahiro Yamada
  0 siblings, 0 replies; 8+ messages in thread
From: Masahiro Yamada @ 2020-11-23 12:00 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: Arnd Bergmann, Michal Marek, Arnd Bergmann, Nick Desaulniers,
	Linux Kbuild mailing list, Linux Kernel Mailing List,
	clang-built-linux

On Tue, Oct 27, 2020 at 1:32 PM Nathan Chancellor
<natechancellor@gmail.com> wrote:
>
> On Mon, Oct 26, 2020 at 06:48:46PM -0700, Nathan Chancellor wrote:
> > On Mon, Oct 26, 2020 at 11:03:14PM +0100, Arnd Bergmann wrote:
> > > From: Arnd Bergmann <arnd@arndb.de>
> > >
> > > The -Wnested-externs warning has become useless with gcc, since
> > > this warns every time that BUILD_BUG_ON() or similar macros
> > > are used.
> > >
> > > Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> >
> > Also see:
> >
> > 2486baae2cf6 ("objtool: Allow nested externs to enable BUILD_BUG()")
> > 6cf4ecf5c51d ("perf build: Allow nested externs to enable BUILD_BUG() usage")
> >
> > Reviewed-by: Nathan Chancellor <natechancellor@gmail.com>
>
> Actually, just delete this line altogether. -Wnested-externs is a GCC
> only warning, the flag is only present in clang for compatibility with
> GCC:
>
> https://clang.llvm.org/docs/DiagnosticsReference.html#wnested-externs
>
> With that, my reviewed by still stands.
>

I agree.



Arnd, will you send v2?

Please include
https://clang.llvm.org/docs/DiagnosticsReference.html#wnested-externs
as a reference.

Thanks.

-- 
Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/2] Makefile.extrawarn: move -Wcast-align to W=3
  2020-11-23 11:17   ` Masahiro Yamada
@ 2020-11-24 15:42     ` Arnd Bergmann
  0 siblings, 0 replies; 8+ messages in thread
From: Arnd Bergmann @ 2020-11-24 15:42 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: Nathan Chancellor, Michal Marek, Arnd Bergmann, Nick Desaulniers,
	Linux Kbuild mailing list, Linux Kernel Mailing List,
	clang-built-linux

On Mon, Nov 23, 2020 at 12:18 PM Masahiro Yamada <masahiroy@kernel.org> wrote:
>
> Applied to linux-kbuild. Thanks.
>
> But, I think people already tend to ignore W=2 warnings.

Yes, this is what I was trying to change with this series and a couple of other
patches I sent. When all the warnings from commonly included headers are
gone, W=2 actually becomes somewhat useful.

      Arnd

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2020-11-24 15:42 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-26 22:03 [PATCH 1/2] Makefile.extrawarn: move -Wcast-align to W=3 Arnd Bergmann
2020-10-26 22:03 ` [PATCH 2/2] Makefile.extrawarn: limit -Wnested-externs to clang Arnd Bergmann
2020-10-27  1:48   ` Nathan Chancellor
2020-10-27  4:32     ` Nathan Chancellor
2020-11-23 12:00       ` Masahiro Yamada
2020-10-27  1:42 ` [PATCH 1/2] Makefile.extrawarn: move -Wcast-align to W=3 Nathan Chancellor
2020-11-23 11:17   ` Masahiro Yamada
2020-11-24 15:42     ` Arnd Bergmann

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).