[Bug build/29373] Canadian Compilation Failed! gdbsupport/packed.h:41:40: error: static assertion failed for x86_64-w64-mingw32 host.

euloanty at live dot com sourceware-bugzilla@sourceware.org
Tue Jul 19 04:21:47 GMT 2022


https://sourceware.org/bugzilla/show_bug.cgi?id=29373

--- Comment #5 from cqwrteur <euloanty at live dot com> ---
(In reply to Pedro Alves from comment #4)
> I can reproduce this here, cross building with mingw on Fedora.
> 
> This is indeed an ABI issue -- mingw defaults to "-mms-bitfields", which
> affects how bitfields are laid out.  Luckily, there's an attribute to switch
> ABI on a per struct basis.  See:
> 
>   https://gcc.gnu.org/onlinedocs/gcc/x86-Variable-Attributes.html
> 
> This fixes the build for me:
> 
> diff --git c/gdbsupport/packed.h w/gdbsupport/packed.h
> index 3468cf44207..a3389afdfb7 100644
> --- c/gdbsupport/packed.h
> +++ w/gdbsupport/packed.h
> @@ -20,6 +20,12 @@
>  
>  #include "traits.h"
>  
> +#ifdef __MINGW32__
> +# define ATTRIBUTE_GCC_STRUCT  __attribute__((gcc_struct))
> +#else
> +# define ATTRIBUTE_GCC_STRUCT
> +#endif
> +
>  /* Each instantiation and full specialization of the packed template
>     defines a type that behaves like a given scalar type, but that has
>     byte alignment, and, may optionally have a smaller size than the
> @@ -58,7 +64,7 @@ struct packed
>  
>  private:
>    T m_val : (Bytes * HOST_CHAR_BIT) ATTRIBUTE_PACKED;
> -};
> +} ATTRIBUTE_GCC_STRUCT;
>  
>  /* Add some comparisons between std::atomic<packed<T>> and T.  We need
>     this because the regular comparisons would require two implicit

Also cygwin and other pe targets.

you probably need 


#if __has_cpp_attribute(__gnu__::__gcc_struct__)
#define ATTRIBUTE_GCC_STRUCT [[__gnu__::__gcc_struct__]]
#endif

something like that to detect the feature

-- 
You are receiving this mail because:
You are on the CC list for the bug.


More information about the Gdb-prs mailing list