[Intel-wired-lan] [tnguy-net-queue:dev-queue 2/12] include/linux/build_bug.h:78:41: error: static assertion failed: "sizeof(__uapi_uuid_t) == sizeof(uuid_t) && __alignof__(__uapi_uuid_t) == __alignof__(uuid_t)"

Dan Williams dan.j.williams at intel.com
Thu Apr 10 17:48:00 UTC 2025


Jason Gunthorpe wrote:
> On Wed, Apr 09, 2025 at 07:01:29PM -0700, Dan Williams wrote:
> 
> > diff --git a/include/uapi/cxl/features.h b/include/uapi/cxl/features.h
> > index dd8874860cec..06a1ae3f3fd0 100644
> > --- a/include/uapi/cxl/features.h
> > +++ b/include/uapi/cxl/features.h
> > @@ -14,7 +14,8 @@ typedef unsigned char __uapi_uuid_t[16];
> >  #ifdef __KERNEL__
> >  #include <linux/uuid.h>
> >  static_assert(sizeof(__uapi_uuid_t) == sizeof(uuid_t) &&
> > -	      __alignof__(__uapi_uuid_t) == __alignof__(uuid_t));
> > +	      __alignof__(struct { __uapi_uuid_t uuid; }) ==
> > +		      __alignof__(struct { uuid_t uuid; }));
> 
> Really? I'm surprised that the struct wrapper increases the
> alignment..

I was also surprised that gcc has different rules for this alignment
across compilers. Empirically this change solves the assertion, but I
admit this was just the result of tinkering until the error goes away.

For this arm-gcc-8.5.0 compiler the alignments are:

1: __uapi_uuid_t
4: uuid_t
4: struct { __uapi_uuid_t uuid; }
4: struct { uuid_t uuid; }

For x86-gcc-14.2.1:

1: __uapi_uuid_t
1: uuid_t
1: struct { __uapi_uuid_t uuid; }
1: struct { uuid_t uuid; }

So your intution that the struct wrapper does not matter holds in that
latter case.


More information about the Intel-wired-lan mailing list