Skip to contentSkip to conversation

kbuild: remove GCC's default -Wpacked-bitfield-compat flag

PATCH In review Masahiro Yamada 3 participants 3 messages Mar 6, 2024 – Mar 10, 2024 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kbuild: remove GCC's default -Wpacked-bitfield-compat flag

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.

---

 scripts/Makefile.extrawarn | 1 -
 1 file changed, 1 deletion(-)
scripts/Makefile.extrawarn +0 -1
index a9e552a1e910..8192b497aae8 100644
@@ -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
 
Signature · 1 line
2.40.1
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 18 lines · Masahiro Yamada

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.

Quoted 6 lines

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.

Quoted 21 lines

---

 scripts/Makefile.extrawarn | 1 -
 1 file changed, 1 deletion(-)
scripts/Makefile.extrawarn +0 -1
index a9e552a1e910..8192b497aae8 100644
@@ -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
 
Signature · 1 line
2.40.1
#2 lore raw

From: Nathan Chancellor

Quoted 21 lines

Sent: 06 March 2024 16:50

Quoted 18 lines · Masahiro Yamada

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.

Quoted 8 lines
Quoted 6 lines

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.

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)