Re: [PATCH 01/17] kbuild: Disable -Waddress-of-packed-member for gcc 9
From: Arnd Bergmann
Date: Fri Mar 22 2019 - 09:59:12 EST
On Thu, Mar 21, 2019 at 11:00 PM Andi Kleen <andi@xxxxxxxxxxxxxx> wrote:
>
> From: Andi Kleen <ak@xxxxxxxxxxxxxxx>
>
> This warning is very noisy in a default build with gcc 9.
> Move it into W=2 only.
>
> Cc: arnd@xxxxxxxx
> Cc: Masahiro Yamada <yamada.masahiro@xxxxxxxxxxxxx>
> Signed-off-by: Andi Kleen <ak@xxxxxxxxxxxxxxx>
I think W=2 is too aggressive. On many architectures, this finds
real bugs and the false positives tend to be trivial to fix
(by removing the bogus __packed annotation), which improves
the generated code in the process.
Moving it to W=1 for the moment is probably fine, but ideally
I think we should fix the kernel to behave according to the
C standard.
Arnd
> ---
> Makefile | 1 +
> scripts/Makefile.extrawarn | 1 +
> 2 files changed, 2 insertions(+)
>
> diff --git a/Makefile b/Makefile
> index 71c2c482e2a2..78efbb172991 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -676,6 +676,7 @@ KBUILD_CFLAGS += $(call cc-disable-warning,frame-address,)
> KBUILD_CFLAGS += $(call cc-disable-warning, format-truncation)
> KBUILD_CFLAGS += $(call cc-disable-warning, format-overflow)
> KBUILD_CFLAGS += $(call cc-disable-warning, int-in-bool-context)
> +KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member)
>
> ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
> KBUILD_CFLAGS += $(call cc-option,-Oz,-Os)
> diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn
> index 768306add591..ed974a0f4a47 100644
> --- a/scripts/Makefile.extrawarn
> +++ b/scripts/Makefile.extrawarn
> @@ -43,6 +43,7 @@ warning-2 += $(call cc-option, -Wmissing-field-initializers)
> warning-2 += $(call cc-option, -Wsign-compare)
> warning-2 += $(call cc-option, -Wmaybe-uninitialized)
> warning-2 += $(call cc-option, -Wunused-macros)
> +warning-2 += $(call cc-option, -Waddress-of-packed-member)
>
> warning-3 := -Wbad-function-cast
> warning-3 += -Wcast-qual
> --
> 2.20.1
>