2020-10-27 00:07:00

by Arnd Bergmann

[permalink] [raw]
Subject: [PATCH 2/2] Makefile.extrawarn: limit -Wnested-externs to clang

From: Arnd Bergmann <[email protected]>

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 <[email protected]>
---
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


2020-10-27 19:34:15

by Nathan Chancellor

[permalink] [raw]
Subject: Re: [PATCH 2/2] Makefile.extrawarn: limit -Wnested-externs to clang

On Mon, Oct 26, 2020 at 11:03:14PM +0100, Arnd Bergmann wrote:
> From: Arnd Bergmann <[email protected]>
>
> 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 <[email protected]>

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 <[email protected]>

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

2020-10-27 21:11:37

by Nathan Chancellor

[permalink] [raw]
Subject: Re: [PATCH 2/2] Makefile.extrawarn: limit -Wnested-externs to clang

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 <[email protected]>
> >
> > 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 <[email protected]>
>
> 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 <[email protected]>

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

2020-11-23 12:04:17

by Masahiro Yamada

[permalink] [raw]
Subject: Re: [PATCH 2/2] Makefile.extrawarn: limit -Wnested-externs to clang

On Tue, Oct 27, 2020 at 1:32 PM Nathan Chancellor
<[email protected]> 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 <[email protected]>
> > >
> > > 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 <[email protected]>
> >
> > 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 <[email protected]>
>
> 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