Re: [PATCH] Kbuild: suppress packed-not-aligned warning for default setting only

From: Arnd Bergmann
Date: Wed Jan 17 2018 - 14:40:45 EST


On Wed, Jan 17, 2018 at 5:12 PM, Masahiro Yamada
<yamada.masahiro@xxxxxxxxxxxxx> wrote:
> 2018-01-11 18:22 GMT+09:00 Xiongfeng Wang <wangxiongfeng2@xxxxxxxxxx>:
>> From: Xiongfeng Wang <xiongfeng.wang@xxxxxxxxxx>
>>
>> gcc-8 reports many -Wpacked-not-aligned warnings. The below are some
>> examples.
>>
>> ./include/linux/ceph/msgr.h:67:1: warning: alignment 1 of 'struct
>> ceph_entity_addr' is less than 8 [-Wpacked-not-aligned]
>> } __attribute__ ((packed));
>>
>> ./include/linux/ceph/msgr.h:67:1: warning: alignment 1 of 'struct
>> ceph_entity_addr' is less than 8 [-Wpacked-not-aligned]
>> } __attribute__ ((packed));
>>
>> ./include/linux/ceph/msgr.h:67:1: warning: alignment 1 of 'struct
>> ceph_entity_addr' is less than 8 [-Wpacked-not-aligned]
>> } __attribute__ ((packed));
>>
>> This patch suppress this kind of warnings for default setting.
>>
>> Signed-off-by: Xiongfeng Wang <xiongfeng.wang@xxxxxxxxxx>
>> ---
>> scripts/Makefile.extrawarn | 3 +++
>> 1 file changed, 3 insertions(+)
>>
>> diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn
>> index c6ebf42..8d53570 100644
>> --- a/scripts/Makefile.extrawarn
>> +++ b/scripts/Makefile.extrawarn
>> @@ -11,6 +11,8 @@
>> # are not supported by all versions of the compiler
>> # ==========================================================================
>>
>> +KBUILD_CFLAGS += $(call cc-disable-warning, packed-not-aligned)
>> +
>
> I moved this to else case of KBUILD_ENABLE_EXTRA_GCC_CHECKS
>
> Please let me know if you see a problem.

It means we get the warning for any argument to W=, not just W=1, but
that's probably fine. I'd like to one day clean up the clang warnings
and those that we disable unconditionally in the top-level Makefile
so that each warning gets enabled at a specific level. For the time
being, I'm happy with the packed-not-aligned disabled by default.

Arnd