Makefile.extrawarn: move -Wcast-align to W=3
PATCH 1/2 Makefile.extrawarn: move -Wcast-align to W=3
From: Arnd Bergmann <[email protected]>
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.
--- scripts/Makefile.extrawarn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/Makefile.extrawarn +1 -1
@@ -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
Signature · 1 line
2.27.0
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.
--- scripts/Makefile.extrawarn | 3 +++ 1 file changed, 3 insertions(+)
scripts/Makefile.extrawarn +3 -0
@@ -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
Signature · 1 line
2.27.0
Re: [PATCH 2/2] Makefile.extrawarn: limit -Wnested-externs to clang
Quoted 7 lines · Arnd Bergmann
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")
Quoted 22 lines
--- scripts/Makefile.extrawarn | 3 +++ 1 file changed, 3 insertions(+)scripts/Makefile.extrawarn +3
-0@@ -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-initializersSignature · 1 line
2.27.0
Re: [PATCH 2/2] Makefile.extrawarn: limit -Wnested-externs to clang
Quoted 7 lines · Nathan Chancellor
Quoted 6 lines · Arnd Bergmann
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.
Quoted 8 lines
Quoted 1 line
Signed-off-by Arnd Bergmann <[email protected]>Also see:
2486baae2cf6("objtool: Allow nested externs to enableBUILD_BUG()")6cf4ecf5c51d("perf build: Allow nested externs to enableBUILD_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
Re: [PATCH 2/2] Makefile.extrawarn: limit -Wnested-externs to clang
Quoted 18 lines · Nathan Chancellor
Quoted 7 lines · Nathan Chancellor
Quoted 6 lines · Arnd Bergmann
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.Quoted 8 lines
Quoted 1 line
Signed-off-by Arnd Bergmann <[email protected]>Also see:
2486baae2cf6("objtool: Allow nested externs to enableBUILD_BUG()")6cf4ecf5c51d("perf build: Allow nested externs to enableBUILD_BUG()usage")Reviewed-by Nathan Chancellor <[email protected]>
Quoted 8 lines
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.
Signature · 2 lines
Best Regards Masahiro Yamada
Quoted 11 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
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.
Quoted 8 lines
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 <[email protected]>
Always sad to see a warning move further down the list but noisy headers are rough to deal with. This seems okay.
Quoted 27 lines
--- scripts/Makefile.extrawarn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)scripts/Makefile.extrawarn +1
-1@@ -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 += -WpackedSignature · 1 line
2.27.0
Quoted 46 lines · Nathan Chancellor
Quoted 11 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
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.
Quoted 8 lines
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 <[email protected]>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 <[email protected]>Quoted 19 lines
--- scripts/Makefile.extrawarn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)scripts/Makefile.extrawarn +0
-1@@ -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)),)
Quoted 8 lines
Quoted 8 lines
scripts/Makefile.extrawarn +1
-1KBUILD_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.
Signature · 2 lines
Best Regards Masahiro Yamada
Quoted 4 lines · Masahiro Yamada
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