[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <080d9e5c-fe1f-4a64-2938-8ca6d8a98d78@hartkopp.net>
Date: Tue, 23 Mar 2021 13:49:01 +0100
From: Oliver Hartkopp <socketcan@...tkopp.net>
To: Rasmus Villemoes <linux@...musvillemoes.dk>,
Marc Kleine-Budde <mkl@...gutronix.de>,
Rong Chen <rong.a.chen@...el.com>,
Patrick Menschel <menschel.p@...teo.de>
Cc: kernel test robot <lkp@...el.com>, kbuild-all@...ts.01.org,
linux-kernel@...r.kernel.org, linux-can <linux-can@...r.kernel.org>
Subject: Re: [kbuild-all] Re: include/linux/compiler_types.h:315:38: error:
call to '__compiletime_assert_536' declared with attribute error:
BUILD_BUG_ON failed: offsetof(struct can_frame, len) != offsetof(struct
canfd_frame, len) || offsetof(struct can_frame, data) != offsetof(struc...
On 23.03.21 12:36, Rasmus Villemoes wrote:
> On 23/03/2021 08.45, Oliver Hartkopp wrote:
>
>> IMO we facing a compiler problem here - and we should be very happy that
>> the BUILD_BUG_ON() triggered an issue after years of silence.
>>
>> I do not have a good feeling about what kind of strange effects this
>> compiler issue might have in other code of other projects.
>>
>> So I would explicitly suggest NOT to change the af_can.c code to work
>> around this compiler issue.
>>
>> Let the gcc people fix their product and let them thank all of us for
>> detecting it.
>
> I'm sure you'd be eligible for a full refund in case this was a bug in
> gcc. It is not. It's a pretty clear ABI requirement for (at least some
> flavors of) ARM:
>
> https://stackoverflow.com/questions/43786747/struct-layout-in-apcs-gnu-abi
>
> and more directly from the horse's mouth:
>
> https://developer.arm.com/documentation/dui0067/d/arm-compiler-reference/c-and-c---implementation-details/structures--unions--enumerations--and-bitfields
>
> Field alignment
>
> Structures are arranged with the first-named component at the lowest
> address. Fields are aligned as follows:
>
> A field with a char type is aligned to the next available byte.
>
> A field with a short type is aligned to the next even-addressed
> byte.
>
> Bitfield alignment depends on how the bitfield is declared. See
> Bitfields in packed structures for more information.
>
> All other types are aligned on word boundaries.
>
> That anonymous union falls into the "All other types" bullet.
>
> __packed is the documented and standard way to overrule the
> compiler's/ABI's layout decisions.
So why is there a difference between
gcc version 10.2.0
and
gcc version 10.2.1 20210110 (Debian 10.2.1-6)
https://lore.kernel.org/linux-can/20210323073437.yo63wreqnubbeqby@pengutronix.de/
??
Would this mean that either STRUCTURE_SIZE_BOUNDARY or the command line
option -mstructure_size_boundary=<n>
are set differently?
https://stackoverflow.com/questions/43786747/struct-layout-in-apcs-gnu-abi/43829053#43829053
I'm not a compiler expert but this does not seem to be consistent.
Especially as we only have byte sizes (inside and outside of the union)
and "A field with a char type is aligned to the next available byte."
The union is indeed aligned to the word boundary - but the following
byte is not aligned to the next available byte.
Regards,
Oliver
Powered by blists - more mailing lists