* [PATCH] kbuild: remove GCC's default -Wpacked-bitfield-compat flag
@ 2024-03-06 12:47 Masahiro Yamada
2024-03-06 16:49 ` Nathan Chancellor
0 siblings, 1 reply; 3+ messages in thread
From: Masahiro Yamada @ 2024-03-06 12:47 UTC (permalink / raw)
To: linux-kbuild
Cc: linux-kernel, Masahiro Yamada, Bill Wendling, Justin Stitt,
Nathan Chancellor, Nick Desaulniers, Nicolas Schier, llvm
Commit 4a5838ad9d2d ("kbuild: Add extra gcc checks") added the
-Wpacked-bitfield-compat flag.
GCC manual says:
"This warning is enabled by default. Use -Wno-packed-bitfield-compat
to disable this warning."
The test code in the manual:
struct foo
{
char a:4;
char b:8;
} __attribute__ ((packed));
... emits "note: offset of packed bit-field ‘b’ has changed in GCC 4.4"
without W=3.
Let's remove it, as it is a default with GCC.
Clang does not support this flag, so its removal will not affect Clang
builds.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---
| 1 -
1 file changed, 1 deletion(-)
--git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn
index a9e552a1e910..8192b497aae8 100644
--- a/scripts/Makefile.extrawarn
+++ b/scripts/Makefile.extrawarn
@@ -185,7 +185,6 @@ KBUILD_CFLAGS += -Wpointer-arith
KBUILD_CFLAGS += -Wredundant-decls
KBUILD_CFLAGS += -Wsign-compare
KBUILD_CFLAGS += -Wswitch-default
-KBUILD_CFLAGS += $(call cc-option, -Wpacked-bitfield-compat)
KBUILD_CPPFLAGS += -DKBUILD_EXTRA_WARN3
--
2.40.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] kbuild: remove GCC's default -Wpacked-bitfield-compat flag
2024-03-06 12:47 [PATCH] kbuild: remove GCC's default -Wpacked-bitfield-compat flag Masahiro Yamada
@ 2024-03-06 16:49 ` Nathan Chancellor
2024-03-10 18:37 ` David Laight
0 siblings, 1 reply; 3+ messages in thread
From: Nathan Chancellor @ 2024-03-06 16:49 UTC (permalink / raw)
To: Masahiro Yamada
Cc: linux-kbuild, linux-kernel, Bill Wendling, Justin Stitt,
Nick Desaulniers, Nicolas Schier, llvm
On Wed, Mar 06, 2024 at 09:47:09PM +0900, Masahiro Yamada wrote:
> Commit 4a5838ad9d2d ("kbuild: Add extra gcc checks") added the
> -Wpacked-bitfield-compat flag.
>
> GCC manual says:
> "This warning is enabled by default. Use -Wno-packed-bitfield-compat
> to disable this warning."
>
> The test code in the manual:
>
> struct foo
> {
> char a:4;
> char b:8;
> } __attribute__ ((packed));
>
> ... emits "note: offset of packed bit-field ‘b’ has changed in GCC 4.4"
> without W=3.
>
> Let's remove it, as it is a default with GCC.
>
> Clang does not support this flag, so its removal will not affect Clang
> builds.
>
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
> ---
>
> scripts/Makefile.extrawarn | 1 -
> 1 file changed, 1 deletion(-)
>
> diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn
> index a9e552a1e910..8192b497aae8 100644
> --- a/scripts/Makefile.extrawarn
> +++ b/scripts/Makefile.extrawarn
> @@ -185,7 +185,6 @@ KBUILD_CFLAGS += -Wpointer-arith
> KBUILD_CFLAGS += -Wredundant-decls
> KBUILD_CFLAGS += -Wsign-compare
> KBUILD_CFLAGS += -Wswitch-default
> -KBUILD_CFLAGS += $(call cc-option, -Wpacked-bitfield-compat)
>
> KBUILD_CPPFLAGS += -DKBUILD_EXTRA_WARN3
>
> --
> 2.40.1
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: [PATCH] kbuild: remove GCC's default -Wpacked-bitfield-compat flag
2024-03-06 16:49 ` Nathan Chancellor
@ 2024-03-10 18:37 ` David Laight
0 siblings, 0 replies; 3+ messages in thread
From: David Laight @ 2024-03-10 18:37 UTC (permalink / raw)
To: 'Nathan Chancellor', Masahiro Yamada
Cc: linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org,
Bill Wendling, Justin Stitt, Nick Desaulniers, Nicolas Schier,
llvm@lists.linux.dev
From: Nathan Chancellor
> Sent: 06 March 2024 16:50
>
> On Wed, Mar 06, 2024 at 09:47:09PM +0900, Masahiro Yamada wrote:
> > Commit 4a5838ad9d2d ("kbuild: Add extra gcc checks") added the
> > -Wpacked-bitfield-compat flag.
> >
> > GCC manual says:
> > "This warning is enabled by default. Use -Wno-packed-bitfield-compat
> > to disable this warning."
> >
> > The test code in the manual:
> >
> > struct foo
> > {
> > char a:4;
> > char b:8;
> > } __attribute__ ((packed));
> >
> > ... emits "note: offset of packed bit-field ‘b’ has changed in GCC 4.4"
> > without W=3.
> >
> > Let's remove it, as it is a default with GCC.
> >
> > Clang does not support this flag, so its removal will not affect Clang
> > builds.
> >
> > Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
>
> Reviewed-by: Nathan Chancellor <nathan@kernel.org>
gcc generates pretty crap code for the above.
clang is ok unless you extend the structure to 3 bytes.
See:
https://godbolt.org/z/9c1csonY9
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-03-10 18:37 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-06 12:47 [PATCH] kbuild: remove GCC's default -Wpacked-bitfield-compat flag Masahiro Yamada
2024-03-06 16:49 ` Nathan Chancellor
2024-03-10 18:37 ` David Laight
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).