[PATCH] meson.build: Check for the availability of __attribute__((gcc_struct)) on MSYS2

Thomas Huth posted 1 patch 3 months, 1 week ago
meson.build | 5 +++++
1 file changed, 5 insertions(+)
[PATCH] meson.build: Check for the availability of __attribute__((gcc_struct)) on MSYS2
Posted by Thomas Huth 3 months, 1 week ago
Since quite a while MSYS2 now supports Clang as a compiler, too.
Unfortunately, this compiler is lacking the __attribute__((gcc_struct))
that we need for compiling on Windows. But since the compiler is
available now, some people started to use it to compile QEMU on MSYS2,
apparently ignoring the compiler warnings (see for example the ticket at
https://gitlab.com/qemu-project/qemu/-/issues/2476 ). These builds are
likely broken in a couple of spots, so let's make sure that we rather
bail out early in the configuration phase instead of allowing the build
to succeed with warnings.

Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 meson.build | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/meson.build b/meson.build
index 81ecd4bae7..fbda17c987 100644
--- a/meson.build
+++ b/meson.build
@@ -315,6 +315,11 @@ elif host_os == 'sunos'
   qemu_common_flags += '-D__EXTENSIONS__'
 elif host_os == 'haiku'
   qemu_common_flags += ['-DB_USE_POSITIVE_POSIX_ERRORS', '-D_BSD_SOURCE', '-fPIC']
+elif host_os == 'windows'
+  if not compiler.compiles('struct x { int y; } __attribute__((gcc_struct));',
+                           args: '-Werror')
+    error('Your compiler does not support __attribute__((gcc_struct)) - please use GCC instead of Clang')
+  endif
 endif
 
 # __sync_fetch_and_and requires at least -march=i486. Many toolchains
-- 
2.46.0
Re: [PATCH] meson.build: Check for the availability of __attribute__((gcc_struct)) on MSYS2
Posted by Stefan Weil via 3 months, 1 week ago
Am 15.08.24 um 14:27 schrieb Thomas Huth:

> Since quite a while MSYS2 now supports Clang as a compiler, too.
> Unfortunately, this compiler is lacking the __attribute__((gcc_struct))
> that we need for compiling on Windows. But since the compiler is
> available now, some people started to use it to compile QEMU on MSYS2,
> apparently ignoring the compiler warnings (see for example the ticket at
> https://gitlab.com/qemu-project/qemu/-/issues/2476 ). These builds are
> likely broken in a couple of spots, so let's make sure that we rather
> bail out early in the configuration phase instead of allowing the build
> to succeed with warnings.
>
> Signed-off-by: Thomas Huth <thuth@redhat.com>
> ---
>   meson.build | 5 +++++
>   1 file changed, 5 insertions(+)
>
> diff --git a/meson.build b/meson.build
> index 81ecd4bae7..fbda17c987 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -315,6 +315,11 @@ elif host_os == 'sunos'
>     qemu_common_flags += '-D__EXTENSIONS__'
>   elif host_os == 'haiku'
>     qemu_common_flags += ['-DB_USE_POSITIVE_POSIX_ERRORS', '-D_BSD_SOURCE', '-fPIC']
> +elif host_os == 'windows'
> +  if not compiler.compiles('struct x { int y; } __attribute__((gcc_struct));',
> +                           args: '-Werror')
> +    error('Your compiler does not support __attribute__((gcc_struct)) - please use GCC instead of Clang')
> +  endif
>   endif
>   
>   # __sync_fetch_and_and requires at least -march=i486. Many toolchains


Tested-by: Stefan Weil <sw@weilnetz.de>