qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4 0/3] Enable clang build on Windows
@ 2025-01-10 20:33 Pierrick Bouvier
  2025-01-10 20:33 ` [PATCH v4 1/3] win32: remove usage of attribute gcc_struct Pierrick Bouvier
                   ` (5 more replies)
  0 siblings, 6 replies; 24+ messages in thread
From: Pierrick Bouvier @ 2025-01-10 20:33 UTC (permalink / raw)
  To: qemu-devel
  Cc: Mahmoud Mandour, Markus Armbruster, Daniel P. Berrangé,
	Thomas Huth, Paolo Bonzini, Pierrick Bouvier, Stefano Garzarella,
	Philippe Mathieu-Daudé, Alex Bennée, Michael S. Tsirkin,
	Marc-André Lureau, Alexandre Iooss

For now, it was only possible to build plugins using GCC on Windows. However,
windows-aarch64 only supports Clang.
This biggest roadblock was to get rid of gcc_struct attribute, which is not
supported by Clang. After investigation, we proved it was safe to drop it.

Built and tested on Windows (all msys env)/Linux/MacOS for x86_64 and aarch64
hosts.

v1 contained warning fixes and various bits that have been upstreamed already.
The only bits left in this series are the gcc_struct removal, and fixing the
plugins build with clang.

This series is for 10.0, as we decided to not include the gcc_struct removal is
9.2 release.

All patches are now reviewed, so this series can be pulled. I'll report that to
MSYS2 too, so we can enable clang environments for QEMU.

v1: https://patchew.org/QEMU/20241031040426.772604-1-pierrick.bouvier@linaro.org/

v2:
- drop attribute gcc_struct instead of using -mno-ms-bitfields option
- add a section about bitfields in documentation

v3:
- explain why gcc_struct attribute matters in packed structs in commit message
- reword the bitfields documentation with suggestions given

v4:
- edit for bitfields doc requested by Philippe

Pierrick Bouvier (3):
  win32: remove usage of attribute gcc_struct
  docs/devel/style: add a section about bitfield, and disallow them for
    packed structures
  plugins: enable linking with clang/lld

 docs/devel/style.rst                      | 20 +++++++++++++++++++
 meson.build                               |  6 +++---
 include/qemu/compiler.h                   |  7 +------
 scripts/cocci-macro-file.h                |  6 +-----
 subprojects/libvhost-user/libvhost-user.h |  6 +-----
 contrib/plugins/meson.build               |  2 +-
 plugins/meson.build                       | 24 +++++++++++++++++++----
 tests/tcg/plugins/meson.build             |  3 +--
 8 files changed, 48 insertions(+), 26 deletions(-)

-- 
2.39.5



^ permalink raw reply	[flat|nested] 24+ messages in thread

* [PATCH v4 1/3] win32: remove usage of attribute gcc_struct
  2025-01-10 20:33 [PATCH v4 0/3] Enable clang build on Windows Pierrick Bouvier
@ 2025-01-10 20:33 ` Pierrick Bouvier
  2025-01-13 23:38   ` Michael S. Tsirkin
  2025-01-10 20:34 ` [PATCH v4 2/3] docs/devel/style: add a section about bitfield, and disallow them for packed structures Pierrick Bouvier
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 24+ messages in thread
From: Pierrick Bouvier @ 2025-01-10 20:33 UTC (permalink / raw)
  To: qemu-devel
  Cc: Mahmoud Mandour, Markus Armbruster, Daniel P. Berrangé,
	Thomas Huth, Paolo Bonzini, Pierrick Bouvier, Stefano Garzarella,
	Philippe Mathieu-Daudé, Alex Bennée, Michael S. Tsirkin,
	Marc-André Lureau, Alexandre Iooss, Richard Henderson

This attribute is not recognized by clang.

An investigation has been performed to ensure this attribute has no
effect on layout of structures we use in QEMU [1], so it's safe to
remove now.

In the future, we'll forbid introducing new bitfields in packed struct,
as they are the one potentially impacted by this change.

[1] https://lore.kernel.org/qemu-devel/66c346de-7e20-4831-b3eb-1cda83240af9@linaro.org/

Reviewed-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Acked-by: Stefano Garzarella <sgarzare@redhat.com>
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
---
 meson.build                               | 5 -----
 include/qemu/compiler.h                   | 7 +------
 scripts/cocci-macro-file.h                | 6 +-----
 subprojects/libvhost-user/libvhost-user.h | 6 +-----
 4 files changed, 3 insertions(+), 21 deletions(-)

diff --git a/meson.build b/meson.build
index d06f59095c6..da279cc1124 100644
--- a/meson.build
+++ b/meson.build
@@ -377,11 +377,6 @@ 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
 
 # Choose instruction set (currently x86-only)
diff --git a/include/qemu/compiler.h b/include/qemu/compiler.h
index c06954ccb41..d904408e5ed 100644
--- a/include/qemu/compiler.h
+++ b/include/qemu/compiler.h
@@ -22,12 +22,7 @@
 #define QEMU_EXTERN_C extern
 #endif
 
-#if defined(_WIN32) && (defined(__x86_64__) || defined(__i386__))
-# define QEMU_PACKED __attribute__((gcc_struct, packed))
-#else
-# define QEMU_PACKED __attribute__((packed))
-#endif
-
+#define QEMU_PACKED __attribute__((packed))
 #define QEMU_ALIGNED(X) __attribute__((aligned(X)))
 
 #ifndef glue
diff --git a/scripts/cocci-macro-file.h b/scripts/cocci-macro-file.h
index d247a5086e9..c64831d5408 100644
--- a/scripts/cocci-macro-file.h
+++ b/scripts/cocci-macro-file.h
@@ -23,11 +23,7 @@
 #define G_GNUC_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
 #define G_GNUC_NULL_TERMINATED __attribute__((sentinel))
 
-#if defined(_WIN32) && (defined(__x86_64__) || defined(__i386__))
-# define QEMU_PACKED __attribute__((gcc_struct, packed))
-#else
-# define QEMU_PACKED __attribute__((packed))
-#endif
+#define QEMU_PACKED __attribute__((packed))
 
 #define cat(x,y) x ## y
 #define cat2(x,y) cat(x,y)
diff --git a/subprojects/libvhost-user/libvhost-user.h b/subprojects/libvhost-user/libvhost-user.h
index deb40e77b3f..2ffc58c11b1 100644
--- a/subprojects/libvhost-user/libvhost-user.h
+++ b/subprojects/libvhost-user/libvhost-user.h
@@ -186,11 +186,7 @@ typedef struct VhostUserShared {
     unsigned char uuid[UUID_LEN];
 } VhostUserShared;
 
-#if defined(_WIN32) && (defined(__x86_64__) || defined(__i386__))
-# define VU_PACKED __attribute__((gcc_struct, packed))
-#else
-# define VU_PACKED __attribute__((packed))
-#endif
+#define VU_PACKED __attribute__((packed))
 
 typedef struct VhostUserMsg {
     int request;
-- 
2.39.5



^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v4 2/3] docs/devel/style: add a section about bitfield, and disallow them for packed structures
  2025-01-10 20:33 [PATCH v4 0/3] Enable clang build on Windows Pierrick Bouvier
  2025-01-10 20:33 ` [PATCH v4 1/3] win32: remove usage of attribute gcc_struct Pierrick Bouvier
@ 2025-01-10 20:34 ` Pierrick Bouvier
  2025-01-10 20:34 ` [PATCH v4 3/3] plugins: enable linking with clang/lld Pierrick Bouvier
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 24+ messages in thread
From: Pierrick Bouvier @ 2025-01-10 20:34 UTC (permalink / raw)
  To: qemu-devel
  Cc: Mahmoud Mandour, Markus Armbruster, Daniel P. Berrangé,
	Thomas Huth, Paolo Bonzini, Pierrick Bouvier, Stefano Garzarella,
	Philippe Mathieu-Daudé, Alex Bennée, Michael S. Tsirkin,
	Marc-André Lureau, Alexandre Iooss, Richard Henderson

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
---
 docs/devel/style.rst | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/docs/devel/style.rst b/docs/devel/style.rst
index 2f68b500798..d025933808e 100644
--- a/docs/devel/style.rst
+++ b/docs/devel/style.rst
@@ -416,6 +416,26 @@ definitions instead of typedefs in headers and function prototypes; this
 avoids problems with duplicated typedefs and reduces the need to include
 headers from other headers.
 
+Bitfields
+---------
+
+C bitfields can be a cause of non-portability issues, especially under windows
+where `MSVC has a different way to lay them out than GCC
+<https://gcc.gnu.org/onlinedocs/gcc/x86-Type-Attributes.html>`_, or where
+endianness matters.
+
+For this reason, we disallow usage of bitfields in packed structures and in any
+structures which are supposed to exactly match a specific layout in guest
+memory. Some existing code may use it, and we carefully ensured the layout was
+the one expected.
+
+We also suggest avoiding bitfields even in structures where the exact
+layout does not matter, unless you can show that they provide a significant
+usability benefit.
+
+We encourage the usage of ``include/hw/registerfields.h`` as a safe replacement
+for bitfields.
+
 Reserved namespaces in C and POSIX
 ----------------------------------
 
-- 
2.39.5



^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v4 3/3] plugins: enable linking with clang/lld
  2025-01-10 20:33 [PATCH v4 0/3] Enable clang build on Windows Pierrick Bouvier
  2025-01-10 20:33 ` [PATCH v4 1/3] win32: remove usage of attribute gcc_struct Pierrick Bouvier
  2025-01-10 20:34 ` [PATCH v4 2/3] docs/devel/style: add a section about bitfield, and disallow them for packed structures Pierrick Bouvier
@ 2025-01-10 20:34 ` Pierrick Bouvier
  2025-01-10 20:37 ` [PATCH v4 0/3] Enable clang build on Windows Pierrick Bouvier
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 24+ messages in thread
From: Pierrick Bouvier @ 2025-01-10 20:34 UTC (permalink / raw)
  To: qemu-devel
  Cc: Mahmoud Mandour, Markus Armbruster, Daniel P. Berrangé,
	Thomas Huth, Paolo Bonzini, Pierrick Bouvier, Stefano Garzarella,
	Philippe Mathieu-Daudé, Alex Bennée, Michael S. Tsirkin,
	Marc-André Lureau, Alexandre Iooss

Windows uses a special mechanism to enable plugins to work (DLL delay
loading). Option for lld is different than ld.

MSYS2 clang based environment use lld by default, so restricting to this
config on Windows is safe, and will avoid false bug reports.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
---
 meson.build                   |  5 +++++
 contrib/plugins/meson.build   |  2 +-
 plugins/meson.build           | 24 ++++++++++++++++++++----
 tests/tcg/plugins/meson.build |  3 +--
 4 files changed, 27 insertions(+), 7 deletions(-)

diff --git a/meson.build b/meson.build
index da279cc1124..15a066043b7 100644
--- a/meson.build
+++ b/meson.build
@@ -377,6 +377,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'
+  # plugins use delaylib, and clang needs to be used with lld to make it work.
+  if compiler.get_id() == 'clang' and compiler.get_linker_id() != 'ld.lld'
+    error('On windows, you need to use lld with clang - use msys2 clang64/clangarm64 env')
+  endif
 endif
 
 # Choose instruction set (currently x86-only)
diff --git a/contrib/plugins/meson.build b/contrib/plugins/meson.build
index 63a32c2b4f0..484b9a808c8 100644
--- a/contrib/plugins/meson.build
+++ b/contrib/plugins/meson.build
@@ -12,7 +12,7 @@ if get_option('plugins')
       t += shared_module(i, files(i + '.c') + 'win32_linker.c',
                         include_directories: '../../include/qemu',
                         link_depends: [win32_qemu_plugin_api_lib],
-                        link_args: ['-Lplugins', '-lqemu_plugin_api'],
+                        link_args: win32_qemu_plugin_api_link_flags,
                         dependencies: glib)
     else
       t += shared_module(i, files(i + '.c'),
diff --git a/plugins/meson.build b/plugins/meson.build
index 98542e926f8..d60be2a4d6d 100644
--- a/plugins/meson.build
+++ b/plugins/meson.build
@@ -17,14 +17,15 @@ if not enable_modules
       capture: true,
       command: ['sed', '-ne', 's/^[[:space:]]*\\(qemu_.*\\);/_\\1/p', '@INPUT@'])
     emulator_link_args += ['-Wl,-exported_symbols_list,plugins/qemu-plugins-ld64.symbols']
+  elif host_os == 'windows' and meson.get_compiler('c').get_id() == 'clang'
+    # LLVM/lld does not support exporting specific symbols. However, it works
+    # out of the box with dllexport/dllimport attribute we set in the code.
   else
     emulator_link_args += ['-Xlinker', '--dynamic-list=' + qemu_plugin_symbols.full_path()]
   endif
 endif
 
 if host_os == 'windows'
-  dlltool = find_program('dlltool', required: true)
-
   # Generate a .lib file for plugins to link against.
   # First, create a .def file listing all the symbols a plugin should expect to have
   # available in qemu
@@ -33,12 +34,27 @@ if host_os == 'windows'
     output: 'qemu_plugin_api.def',
     capture: true,
     command: ['sed', '-e', '0,/^/s//EXPORTS/; s/[{};]//g', '@INPUT@'])
+
   # then use dlltool to assemble a delaylib.
+  # The delaylib will have an "imaginary" name (qemu.exe), that is used by the
+  # linker file we add with plugins (win32_linker.c) to identify that we want
+  # to find missing symbols in current program.
+  win32_qemu_plugin_api_link_flags = ['-Lplugins', '-lqemu_plugin_api']
+  if meson.get_compiler('c').get_id() == 'clang'
+    # With LLVM/lld, delaylib is specified at link time (-delayload)
+    dlltool = find_program('llvm-dlltool', required: true)
+    dlltool_cmd = [dlltool, '-d', '@INPUT@', '-l', '@OUTPUT@', '-D', 'qemu.exe']
+    win32_qemu_plugin_api_link_flags += ['-Wl,-delayload=qemu.exe']
+  else
+    # With gcc/ld, delay lib is built with a specific delay parameter.
+    dlltool = find_program('dlltool', required: true)
+    dlltool_cmd = [dlltool, '--input-def', '@INPUT@',
+                   '--output-delaylib', '@OUTPUT@', '--dllname', 'qemu.exe']
+  endif
   win32_qemu_plugin_api_lib = configure_file(
     input: win32_plugin_def,
     output: 'libqemu_plugin_api.a',
-    command: [dlltool, '--input-def', '@INPUT@',
-              '--output-delaylib', '@OUTPUT@', '--dllname', 'qemu.exe']
+    command: dlltool_cmd
   )
 endif
 specific_ss.add(files(
diff --git a/tests/tcg/plugins/meson.build b/tests/tcg/plugins/meson.build
index f847849b1b7..87a17d67bd4 100644
--- a/tests/tcg/plugins/meson.build
+++ b/tests/tcg/plugins/meson.build
@@ -5,9 +5,8 @@ if get_option('plugins')
       t += shared_module(i, files(i + '.c') + '../../../contrib/plugins/win32_linker.c',
                         include_directories: '../../../include/qemu',
                         link_depends: [win32_qemu_plugin_api_lib],
-                        link_args: ['-Lplugins', '-lqemu_plugin_api'],
+                        link_args: win32_qemu_plugin_api_link_flags,
                         dependencies: glib)
-
     else
       t += shared_module(i, files(i + '.c'),
                         include_directories: '../../../include/qemu',
-- 
2.39.5



^ permalink raw reply related	[flat|nested] 24+ messages in thread

* Re: [PATCH v4 0/3] Enable clang build on Windows
  2025-01-10 20:33 [PATCH v4 0/3] Enable clang build on Windows Pierrick Bouvier
                   ` (2 preceding siblings ...)
  2025-01-10 20:34 ` [PATCH v4 3/3] plugins: enable linking with clang/lld Pierrick Bouvier
@ 2025-01-10 20:37 ` Pierrick Bouvier
  2025-01-11 15:47   ` Philippe Mathieu-Daudé
  2025-01-11 22:08 ` Stefan Weil via
  2025-01-14  8:20 ` Alex Bennée
  5 siblings, 1 reply; 24+ messages in thread
From: Pierrick Bouvier @ 2025-01-10 20:37 UTC (permalink / raw)
  To: qemu-devel
  Cc: Mahmoud Mandour, Markus Armbruster, Daniel P. Berrangé,
	Thomas Huth, Paolo Bonzini, Stefano Garzarella,
	Philippe Mathieu-Daudé, Alex Bennée, Michael S. Tsirkin,
	Marc-André Lureau, Alexandre Iooss

On 1/10/25 12:33, Pierrick Bouvier wrote:
> For now, it was only possible to build plugins using GCC on Windows. However,
> windows-aarch64 only supports Clang.
> This biggest roadblock was to get rid of gcc_struct attribute, which is not
> supported by Clang. After investigation, we proved it was safe to drop it.
> 
> Built and tested on Windows (all msys env)/Linux/MacOS for x86_64 and aarch64
> hosts.
> 
> v1 contained warning fixes and various bits that have been upstreamed already.
> The only bits left in this series are the gcc_struct removal, and fixing the
> plugins build with clang.
> 
> This series is for 10.0, as we decided to not include the gcc_struct removal is
> 9.2 release.
> 
> All patches are now reviewed, so this series can be pulled. I'll report that to
> MSYS2 too, so we can enable clang environments for QEMU.
> 
> v1: https://patchew.org/QEMU/20241031040426.772604-1-pierrick.bouvier@linaro.org/
> 
> v2:
> - drop attribute gcc_struct instead of using -mno-ms-bitfields option
> - add a section about bitfields in documentation
> 
> v3:
> - explain why gcc_struct attribute matters in packed structs in commit message
> - reword the bitfields documentation with suggestions given
> 
> v4:
> - edit for bitfields doc requested by Philippe
> 
> Pierrick Bouvier (3):
>    win32: remove usage of attribute gcc_struct
>    docs/devel/style: add a section about bitfield, and disallow them for
>      packed structures
>    plugins: enable linking with clang/lld
> 
>   docs/devel/style.rst                      | 20 +++++++++++++++++++
>   meson.build                               |  6 +++---
>   include/qemu/compiler.h                   |  7 +------
>   scripts/cocci-macro-file.h                |  6 +-----
>   subprojects/libvhost-user/libvhost-user.h |  6 +-----
>   contrib/plugins/meson.build               |  2 +-
>   plugins/meson.build                       | 24 +++++++++++++++++++----
>   tests/tcg/plugins/meson.build             |  3 +--
>   8 files changed, 48 insertions(+), 26 deletions(-)
> 

It would be nice if a maintainer could pull this, so we can get this 
merged upstream.

Thanks,
Pierrick


^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v4 0/3] Enable clang build on Windows
  2025-01-10 20:37 ` [PATCH v4 0/3] Enable clang build on Windows Pierrick Bouvier
@ 2025-01-11 15:47   ` Philippe Mathieu-Daudé
  2025-01-12 18:03     ` Philippe Mathieu-Daudé
  2025-01-13  6:26     ` Thomas Huth
  0 siblings, 2 replies; 24+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-01-11 15:47 UTC (permalink / raw)
  To: Pierrick Bouvier, qemu-devel
  Cc: Mahmoud Mandour, Markus Armbruster, Daniel P. Berrangé,
	Thomas Huth, Paolo Bonzini, Stefano Garzarella, Alex Bennée,
	Michael S. Tsirkin, Marc-André Lureau, Alexandre Iooss

On 10/1/25 21:37, Pierrick Bouvier wrote:
> On 1/10/25 12:33, Pierrick Bouvier wrote:
>> For now, it was only possible to build plugins using GCC on Windows. 
>> However,
>> windows-aarch64 only supports Clang.
>> This biggest roadblock was to get rid of gcc_struct attribute, which 
>> is not
>> supported by Clang. After investigation, we proved it was safe to drop 
>> it.
>>
>> Built and tested on Windows (all msys env)/Linux/MacOS for x86_64 and 
>> aarch64
>> hosts.
>>
>> v1 contained warning fixes and various bits that have been upstreamed 
>> already.
>> The only bits left in this series are the gcc_struct removal, and 
>> fixing the
>> plugins build with clang.
>>
>> This series is for 10.0, as we decided to not include the gcc_struct 
>> removal is
>> 9.2 release.
>>
>> All patches are now reviewed, so this series can be pulled. I'll 
>> report that to
>> MSYS2 too, so we can enable clang environments for QEMU.
>>
>> v1: https://patchew.org/QEMU/20241031040426.772604-1- 
>> pierrick.bouvier@linaro.org/
>>
>> v2:
>> - drop attribute gcc_struct instead of using -mno-ms-bitfields option
>> - add a section about bitfields in documentation
>>
>> v3:
>> - explain why gcc_struct attribute matters in packed structs in commit 
>> message
>> - reword the bitfields documentation with suggestions given
>>
>> v4:
>> - edit for bitfields doc requested by Philippe
>>
>> Pierrick Bouvier (3):
>>    win32: remove usage of attribute gcc_struct
>>    docs/devel/style: add a section about bitfield, and disallow them for
>>      packed structures
>>    plugins: enable linking with clang/lld
>>
>>   docs/devel/style.rst                      | 20 +++++++++++++++++++
>>   meson.build                               |  6 +++---
>>   include/qemu/compiler.h                   |  7 +------
>>   scripts/cocci-macro-file.h                |  6 +-----
>>   subprojects/libvhost-user/libvhost-user.h |  6 +-----
>>   contrib/plugins/meson.build               |  2 +-
>>   plugins/meson.build                       | 24 +++++++++++++++++++----
>>   tests/tcg/plugins/meson.build             |  3 +--
>>   8 files changed, 48 insertions(+), 26 deletions(-)
>>
> 
> It would be nice if a maintainer could pull this, so we can get this 
> merged upstream.

That'd be Thomas or Alex I suppose.


^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v4 0/3] Enable clang build on Windows
  2025-01-10 20:33 [PATCH v4 0/3] Enable clang build on Windows Pierrick Bouvier
                   ` (3 preceding siblings ...)
  2025-01-10 20:37 ` [PATCH v4 0/3] Enable clang build on Windows Pierrick Bouvier
@ 2025-01-11 22:08 ` Stefan Weil via
  2025-01-12 17:54   ` Pierrick Bouvier
  2025-02-18  4:11   ` Brian Cain
  2025-01-14  8:20 ` Alex Bennée
  5 siblings, 2 replies; 24+ messages in thread
From: Stefan Weil via @ 2025-01-11 22:08 UTC (permalink / raw)
  To: Pierrick Bouvier, qemu-devel
  Cc: Mahmoud Mandour, Markus Armbruster, Daniel P. Berrangé,
	Thomas Huth, Paolo Bonzini, Stefano Garzarella,
	Philippe Mathieu-Daudé, Alex Bennée, Michael S. Tsirkin,
	Marc-André Lureau, Alexandre Iooss

Am 10.01.25 um 21:33 schrieb Pierrick Bouvier:
> For now, it was only possible to build plugins using GCC on Windows. However,
> windows-aarch64 only supports Clang.
> This biggest roadblock was to get rid of gcc_struct attribute, which is not
> supported by Clang. After investigation, we proved it was safe to drop it.
> 
> Built and tested on Windows (all msys env)/Linux/MacOS for x86_64 and aarch64
> hosts.
> 
> v1 contained warning fixes and various bits that have been upstreamed already.
> The only bits left in this series are the gcc_struct removal, and fixing the
> plugins build with clang.
> 
> This series is for 10.0, as we decided to not include the gcc_struct removal is
> 9.2 release.
> 
> All patches are now reviewed, so this series can be pulled. I'll report that to
> MSYS2 too, so we can enable clang environments for QEMU.
> 
> v1: https://patchew.org/QEMU/20241031040426.772604-1-pierrick.bouvier@linaro.org/
> 
> v2:
> - drop attribute gcc_struct instead of using -mno-ms-bitfields option
> - add a section about bitfields in documentation
> 
> v3:
> - explain why gcc_struct attribute matters in packed structs in commit message
> - reword the bitfields documentation with suggestions given
> 
> v4:
> - edit for bitfields doc requested by Philippe
> 
> Pierrick Bouvier (3):
>    win32: remove usage of attribute gcc_struct
>    docs/devel/style: add a section about bitfield, and disallow them for
>      packed structures
>    plugins: enable linking with clang/lld
> 
>   docs/devel/style.rst                      | 20 +++++++++++++++++++
>   meson.build                               |  6 +++---
>   include/qemu/compiler.h                   |  7 +------
>   scripts/cocci-macro-file.h                |  6 +-----
>   subprojects/libvhost-user/libvhost-user.h |  6 +-----
>   contrib/plugins/meson.build               |  2 +-
>   plugins/meson.build                       | 24 +++++++++++++++++++----
>   tests/tcg/plugins/meson.build             |  3 +--
>   8 files changed, 48 insertions(+), 26 deletions(-)

This nice series allows building QEMU for Windows with the LLVM cross 
compiler on my ARM64 machine, so you can add

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

I only needed a trivial additional fix in scripts/nsis.py for `make 
installer` because the usual GNU objdump and the LLVM objdump (or the 
cross x86_64-w64-mingw32-objdump in my test) produce slightly different 
output (indentation with \t, indentation with four spaces). I'll prepare 
a patch which eliminates the need for objdump, so no intermediate fix is 
needed for this.

Stefan W.



^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v4 0/3] Enable clang build on Windows
  2025-01-11 22:08 ` Stefan Weil via
@ 2025-01-12 17:54   ` Pierrick Bouvier
  2025-02-18  4:11   ` Brian Cain
  1 sibling, 0 replies; 24+ messages in thread
From: Pierrick Bouvier @ 2025-01-12 17:54 UTC (permalink / raw)
  To: Stefan Weil, qemu-devel
  Cc: Mahmoud Mandour, Markus Armbruster, Daniel P. Berrangé,
	Thomas Huth, Paolo Bonzini, Stefano Garzarella,
	Philippe Mathieu-Daudé, Alex Bennée, Michael S. Tsirkin,
	Marc-André Lureau, Alexandre Iooss

On 1/11/25 14:08, Stefan Weil wrote:
> Am 10.01.25 um 21:33 schrieb Pierrick Bouvier:
>> For now, it was only possible to build plugins using GCC on Windows. However,
>> windows-aarch64 only supports Clang.
>> This biggest roadblock was to get rid of gcc_struct attribute, which is not
>> supported by Clang. After investigation, we proved it was safe to drop it.
>>
>> Built and tested on Windows (all msys env)/Linux/MacOS for x86_64 and aarch64
>> hosts.
>>
>> v1 contained warning fixes and various bits that have been upstreamed already.
>> The only bits left in this series are the gcc_struct removal, and fixing the
>> plugins build with clang.
>>
>> This series is for 10.0, as we decided to not include the gcc_struct removal is
>> 9.2 release.
>>
>> All patches are now reviewed, so this series can be pulled. I'll report that to
>> MSYS2 too, so we can enable clang environments for QEMU.
>>
>> v1: https://patchew.org/QEMU/20241031040426.772604-1-pierrick.bouvier@linaro.org/
>>
>> v2:
>> - drop attribute gcc_struct instead of using -mno-ms-bitfields option
>> - add a section about bitfields in documentation
>>
>> v3:
>> - explain why gcc_struct attribute matters in packed structs in commit message
>> - reword the bitfields documentation with suggestions given
>>
>> v4:
>> - edit for bitfields doc requested by Philippe
>>
>> Pierrick Bouvier (3):
>>     win32: remove usage of attribute gcc_struct
>>     docs/devel/style: add a section about bitfield, and disallow them for
>>       packed structures
>>     plugins: enable linking with clang/lld
>>
>>    docs/devel/style.rst                      | 20 +++++++++++++++++++
>>    meson.build                               |  6 +++---
>>    include/qemu/compiler.h                   |  7 +------
>>    scripts/cocci-macro-file.h                |  6 +-----
>>    subprojects/libvhost-user/libvhost-user.h |  6 +-----
>>    contrib/plugins/meson.build               |  2 +-
>>    plugins/meson.build                       | 24 +++++++++++++++++++----
>>    tests/tcg/plugins/meson.build             |  3 +--
>>    8 files changed, 48 insertions(+), 26 deletions(-)
> 
> This nice series allows building QEMU for Windows with the LLVM cross
> compiler on my ARM64 machine, so you can add
> 
> Tested-by: Stefan Weil <sw@weilnetz.de>
> 
> I only needed a trivial additional fix in scripts/nsis.py for `make
> installer` because the usual GNU objdump and the LLVM objdump (or the
> cross x86_64-w64-mingw32-objdump in my test) produce slightly different
> output (indentation with \t, indentation with four spaces). I'll prepare
> a patch which eliminates the need for objdump, so no intermediate fix is
> needed for this.
> 
> Stefan W.
> 

Thanks for testing it Stefan.

Once merged, I'll share this with MSYS2 folks, so they can backport this 
series to 9.2, and enable clang based environments (including for 
windows-arm64).

Regards,
Pierrick


^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v4 0/3] Enable clang build on Windows
  2025-01-11 15:47   ` Philippe Mathieu-Daudé
@ 2025-01-12 18:03     ` Philippe Mathieu-Daudé
  2025-01-13  6:26     ` Thomas Huth
  1 sibling, 0 replies; 24+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-01-12 18:03 UTC (permalink / raw)
  To: Pierrick Bouvier, qemu-devel
  Cc: Mahmoud Mandour, Markus Armbruster, Daniel P. Berrangé,
	Thomas Huth, Paolo Bonzini, Stefano Garzarella, Alex Bennée,
	Michael S. Tsirkin, Marc-André Lureau, Alexandre Iooss

On 11/1/25 16:47, Philippe Mathieu-Daudé wrote:
> On 10/1/25 21:37, Pierrick Bouvier wrote:
>> On 1/10/25 12:33, Pierrick Bouvier wrote:
>>> For now, it was only possible to build plugins using GCC on Windows. 
>>> However,
>>> windows-aarch64 only supports Clang.
>>> This biggest roadblock was to get rid of gcc_struct attribute, which 
>>> is not
>>> supported by Clang. After investigation, we proved it was safe to 
>>> drop it.
>>>
>>> Built and tested on Windows (all msys env)/Linux/MacOS for x86_64 and 
>>> aarch64
>>> hosts.
>>>
>>> v1 contained warning fixes and various bits that have been upstreamed 
>>> already.
>>> The only bits left in this series are the gcc_struct removal, and 
>>> fixing the
>>> plugins build with clang.
>>>
>>> This series is for 10.0, as we decided to not include the gcc_struct 
>>> removal is
>>> 9.2 release.
>>>
>>> All patches are now reviewed, so this series can be pulled. I'll 
>>> report that to
>>> MSYS2 too, so we can enable clang environments for QEMU.
>>>
>>> v1: https://patchew.org/QEMU/20241031040426.772604-1- 
>>> pierrick.bouvier@linaro.org/
>>>
>>> v2:
>>> - drop attribute gcc_struct instead of using -mno-ms-bitfields option
>>> - add a section about bitfields in documentation
>>>
>>> v3:
>>> - explain why gcc_struct attribute matters in packed structs in 
>>> commit message
>>> - reword the bitfields documentation with suggestions given
>>>
>>> v4:
>>> - edit for bitfields doc requested by Philippe
>>>
>>> Pierrick Bouvier (3):
>>>    win32: remove usage of attribute gcc_struct
>>>    docs/devel/style: add a section about bitfield, and disallow them for
>>>      packed structures
>>>    plugins: enable linking with clang/lld
>>>
>>>   docs/devel/style.rst                      | 20 +++++++++++++++++++
>>>   meson.build                               |  6 +++---
>>>   include/qemu/compiler.h                   |  7 +------
>>>   scripts/cocci-macro-file.h                |  6 +-----
>>>   subprojects/libvhost-user/libvhost-user.h |  6 +-----
>>>   contrib/plugins/meson.build               |  2 +-
>>>   plugins/meson.build                       | 24 +++++++++++++++++++----
>>>   tests/tcg/plugins/meson.build             |  3 +--
>>>   8 files changed, 48 insertions(+), 26 deletions(-)
>>>
>>
>> It would be nice if a maintainer could pull this, so we can get this 
>> merged upstream.
> 
> That'd be Thomas or Alex I suppose.

(That said, I don't mind to merge if they are busy).

Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org>


^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v4 0/3] Enable clang build on Windows
  2025-01-11 15:47   ` Philippe Mathieu-Daudé
  2025-01-12 18:03     ` Philippe Mathieu-Daudé
@ 2025-01-13  6:26     ` Thomas Huth
  2025-01-13 20:17       ` Pierrick Bouvier
  1 sibling, 1 reply; 24+ messages in thread
From: Thomas Huth @ 2025-01-13  6:26 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, Pierrick Bouvier, qemu-devel,
	Alex Bennée
  Cc: Mahmoud Mandour, Markus Armbruster, Daniel P. Berrangé,
	Paolo Bonzini, Stefano Garzarella, Michael S. Tsirkin,
	Marc-André Lureau, Alexandre Iooss

On 11/01/2025 16.47, Philippe Mathieu-Daudé wrote:
> On 10/1/25 21:37, Pierrick Bouvier wrote:
>> On 1/10/25 12:33, Pierrick Bouvier wrote:
>>> For now, it was only possible to build plugins using GCC on Windows. 
>>> However,
>>> windows-aarch64 only supports Clang.
>>> This biggest roadblock was to get rid of gcc_struct attribute, which is not
>>> supported by Clang. After investigation, we proved it was safe to drop it.
>>>
>>> Built and tested on Windows (all msys env)/Linux/MacOS for x86_64 and 
>>> aarch64
>>> hosts.
>>>
>>> v1 contained warning fixes and various bits that have been upstreamed 
>>> already.
>>> The only bits left in this series are the gcc_struct removal, and fixing the
>>> plugins build with clang.
>>>
>>> This series is for 10.0, as we decided to not include the gcc_struct 
>>> removal is
>>> 9.2 release.
>>>
>>> All patches are now reviewed, so this series can be pulled. I'll report 
>>> that to
>>> MSYS2 too, so we can enable clang environments for QEMU.
>>>
>>> v1: https://patchew.org/QEMU/20241031040426.772604-1- 
>>> pierrick.bouvier@linaro.org/
>>>
>>> v2:
>>> - drop attribute gcc_struct instead of using -mno-ms-bitfields option
>>> - add a section about bitfields in documentation
>>>
>>> v3:
>>> - explain why gcc_struct attribute matters in packed structs in commit 
>>> message
>>> - reword the bitfields documentation with suggestions given
>>>
>>> v4:
>>> - edit for bitfields doc requested by Philippe
>>>
>>> Pierrick Bouvier (3):
>>>    win32: remove usage of attribute gcc_struct
>>>    docs/devel/style: add a section about bitfield, and disallow them for
>>>      packed structures
>>>    plugins: enable linking with clang/lld
>>>
>>>   docs/devel/style.rst                      | 20 +++++++++++++++++++
>>>   meson.build                               |  6 +++---
>>>   include/qemu/compiler.h                   |  7 +------
>>>   scripts/cocci-macro-file.h                |  6 +-----
>>>   subprojects/libvhost-user/libvhost-user.h |  6 +-----
>>>   contrib/plugins/meson.build               |  2 +-
>>>   plugins/meson.build                       | 24 +++++++++++++++++++----
>>>   tests/tcg/plugins/meson.build             |  3 +--
>>>   8 files changed, 48 insertions(+), 26 deletions(-)
>>>
>>
>> It would be nice if a maintainer could pull this, so we can get this 
>> merged upstream.
> 
> That'd be Thomas or Alex I suppose.

This touches plugins, so I think it should go through Alex' tree?

  Thomas




^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v4 0/3] Enable clang build on Windows
  2025-01-13  6:26     ` Thomas Huth
@ 2025-01-13 20:17       ` Pierrick Bouvier
  2025-01-13 21:19         ` Alex Bennée
  0 siblings, 1 reply; 24+ messages in thread
From: Pierrick Bouvier @ 2025-01-13 20:17 UTC (permalink / raw)
  To: Thomas Huth, Philippe Mathieu-Daudé, qemu-devel,
	Alex Bennée
  Cc: Mahmoud Mandour, Markus Armbruster, Daniel P. Berrangé,
	Paolo Bonzini, Stefano Garzarella, Michael S. Tsirkin,
	Marc-André Lureau, Alexandre Iooss

On 1/12/25 22:26, Thomas Huth wrote:
> On 11/01/2025 16.47, Philippe Mathieu-Daudé wrote:
>> On 10/1/25 21:37, Pierrick Bouvier wrote:
>>> On 1/10/25 12:33, Pierrick Bouvier wrote:
>>>> For now, it was only possible to build plugins using GCC on Windows.
>>>> However,
>>>> windows-aarch64 only supports Clang.
>>>> This biggest roadblock was to get rid of gcc_struct attribute, which is not
>>>> supported by Clang. After investigation, we proved it was safe to drop it.
>>>>
>>>> Built and tested on Windows (all msys env)/Linux/MacOS for x86_64 and
>>>> aarch64
>>>> hosts.
>>>>
>>>> v1 contained warning fixes and various bits that have been upstreamed
>>>> already.
>>>> The only bits left in this series are the gcc_struct removal, and fixing the
>>>> plugins build with clang.
>>>>
>>>> This series is for 10.0, as we decided to not include the gcc_struct
>>>> removal is
>>>> 9.2 release.
>>>>
>>>> All patches are now reviewed, so this series can be pulled. I'll report
>>>> that to
>>>> MSYS2 too, so we can enable clang environments for QEMU.
>>>>
>>>> v1: https://patchew.org/QEMU/20241031040426.772604-1-
>>>> pierrick.bouvier@linaro.org/
>>>>
>>>> v2:
>>>> - drop attribute gcc_struct instead of using -mno-ms-bitfields option
>>>> - add a section about bitfields in documentation
>>>>
>>>> v3:
>>>> - explain why gcc_struct attribute matters in packed structs in commit
>>>> message
>>>> - reword the bitfields documentation with suggestions given
>>>>
>>>> v4:
>>>> - edit for bitfields doc requested by Philippe
>>>>
>>>> Pierrick Bouvier (3):
>>>>     win32: remove usage of attribute gcc_struct
>>>>     docs/devel/style: add a section about bitfield, and disallow them for
>>>>       packed structures
>>>>     plugins: enable linking with clang/lld
>>>>
>>>>    docs/devel/style.rst                      | 20 +++++++++++++++++++
>>>>    meson.build                               |  6 +++---
>>>>    include/qemu/compiler.h                   |  7 +------
>>>>    scripts/cocci-macro-file.h                |  6 +-----
>>>>    subprojects/libvhost-user/libvhost-user.h |  6 +-----
>>>>    contrib/plugins/meson.build               |  2 +-
>>>>    plugins/meson.build                       | 24 +++++++++++++++++++----
>>>>    tests/tcg/plugins/meson.build             |  3 +--
>>>>    8 files changed, 48 insertions(+), 26 deletions(-)
>>>>
>>>
>>> It would be nice if a maintainer could pull this, so we can get this
>>> merged upstream.
>>
>> That'd be Thomas or Alex I suppose.
> 
> This touches plugins, so I think it should go through Alex' tree?
> 
>    Thomas
> 
> 

It's touching plugins, but it does a system wide change as well (which 
is the most important part).

It's not really important who merges this, but it would be better if the 
series could be pulled as a whole, instead of breaking it into multiple 
subsystems.

Thanks,
Pierrick

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v4 0/3] Enable clang build on Windows
  2025-01-13 20:17       ` Pierrick Bouvier
@ 2025-01-13 21:19         ` Alex Bennée
  2025-01-13 21:22           ` Pierrick Bouvier
  0 siblings, 1 reply; 24+ messages in thread
From: Alex Bennée @ 2025-01-13 21:19 UTC (permalink / raw)
  To: Pierrick Bouvier
  Cc: Thomas Huth, Philippe Mathieu-Daudé, qemu-devel,
	Mahmoud Mandour, Markus Armbruster, Daniel P. Berrangé,
	Paolo Bonzini, Stefano Garzarella, Michael S. Tsirkin,
	Marc-André Lureau, Alexandre Iooss

Pierrick Bouvier <pierrick.bouvier@linaro.org> writes:

> On 1/12/25 22:26, Thomas Huth wrote:
>> On 11/01/2025 16.47, Philippe Mathieu-Daudé wrote:
>>> On 10/1/25 21:37, Pierrick Bouvier wrote:
>>>> On 1/10/25 12:33, Pierrick Bouvier wrote:
>>>>> For now, it was only possible to build plugins using GCC on Windows.
>>>>> However,
>>>>> windows-aarch64 only supports Clang.
>>>>> This biggest roadblock was to get rid of gcc_struct attribute, which is not
>>>>> supported by Clang. After investigation, we proved it was safe to drop it.
>>>>>
>>>>> Built and tested on Windows (all msys env)/Linux/MacOS for x86_64 and
>>>>> aarch64
>>>>> hosts.
>>>>>
>>>>> v1 contained warning fixes and various bits that have been upstreamed
>>>>> already.
>>>>> The only bits left in this series are the gcc_struct removal, and fixing the
>>>>> plugins build with clang.
>>>>>
>>>>> This series is for 10.0, as we decided to not include the gcc_struct
>>>>> removal is
>>>>> 9.2 release.
>>>>>
>>>>> All patches are now reviewed, so this series can be pulled. I'll report
>>>>> that to
>>>>> MSYS2 too, so we can enable clang environments for QEMU.
>>>>>
>>>>> v1: https://patchew.org/QEMU/20241031040426.772604-1-
>>>>> pierrick.bouvier@linaro.org/
>>>>>
>>>>> v2:
>>>>> - drop attribute gcc_struct instead of using -mno-ms-bitfields option
>>>>> - add a section about bitfields in documentation
>>>>>
>>>>> v3:
>>>>> - explain why gcc_struct attribute matters in packed structs in commit
>>>>> message
>>>>> - reword the bitfields documentation with suggestions given
>>>>>
>>>>> v4:
>>>>> - edit for bitfields doc requested by Philippe
>>>>>
>>>>> Pierrick Bouvier (3):
>>>>>     win32: remove usage of attribute gcc_struct
>>>>>     docs/devel/style: add a section about bitfield, and disallow them for
>>>>>       packed structures
>>>>>     plugins: enable linking with clang/lld
>>>>>
>>>>>    docs/devel/style.rst                      | 20 +++++++++++++++++++
>>>>>    meson.build                               |  6 +++---
>>>>>    include/qemu/compiler.h                   |  7 +------
>>>>>    scripts/cocci-macro-file.h                |  6 +-----
>>>>>    subprojects/libvhost-user/libvhost-user.h |  6 +-----
>>>>>    contrib/plugins/meson.build               |  2 +-
>>>>>    plugins/meson.build                       | 24 +++++++++++++++++++----
>>>>>    tests/tcg/plugins/meson.build             |  3 +--
>>>>>    8 files changed, 48 insertions(+), 26 deletions(-)
>>>>>
>>>>
>>>> It would be nice if a maintainer could pull this, so we can get this
>>>> merged upstream.
>>>
>>> That'd be Thomas or Alex I suppose.
>> This touches plugins, so I think it should go through Alex' tree?
>>    Thomas
>> 
>
> It's touching plugins, but it does a system wide change as well (which
> is the most important part).
>
> It's not really important who merges this, but it would be better if
> the series could be pulled as a whole, instead of breaking it into
> multiple subsystems.

I'll look at it tomorrow when going through my maintainer queue.

>
> Thanks,
> Pierrick

-- 
Alex Bennée
Virtualisation Tech Lead @ Linaro


^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v4 0/3] Enable clang build on Windows
  2025-01-13 21:19         ` Alex Bennée
@ 2025-01-13 21:22           ` Pierrick Bouvier
  0 siblings, 0 replies; 24+ messages in thread
From: Pierrick Bouvier @ 2025-01-13 21:22 UTC (permalink / raw)
  To: Alex Bennée
  Cc: Thomas Huth, Philippe Mathieu-Daudé, qemu-devel,
	Mahmoud Mandour, Markus Armbruster, Daniel P. Berrangé,
	Paolo Bonzini, Stefano Garzarella, Michael S. Tsirkin,
	Marc-André Lureau, Alexandre Iooss

On 1/13/25 13:19, Alex Bennée wrote:
> Pierrick Bouvier <pierrick.bouvier@linaro.org> writes:
> 
>> On 1/12/25 22:26, Thomas Huth wrote:
>>> On 11/01/2025 16.47, Philippe Mathieu-Daudé wrote:
>>>> On 10/1/25 21:37, Pierrick Bouvier wrote:
>>>>> On 1/10/25 12:33, Pierrick Bouvier wrote:
>>>>>> For now, it was only possible to build plugins using GCC on Windows.
>>>>>> However,
>>>>>> windows-aarch64 only supports Clang.
>>>>>> This biggest roadblock was to get rid of gcc_struct attribute, which is not
>>>>>> supported by Clang. After investigation, we proved it was safe to drop it.
>>>>>>
>>>>>> Built and tested on Windows (all msys env)/Linux/MacOS for x86_64 and
>>>>>> aarch64
>>>>>> hosts.
>>>>>>
>>>>>> v1 contained warning fixes and various bits that have been upstreamed
>>>>>> already.
>>>>>> The only bits left in this series are the gcc_struct removal, and fixing the
>>>>>> plugins build with clang.
>>>>>>
>>>>>> This series is for 10.0, as we decided to not include the gcc_struct
>>>>>> removal is
>>>>>> 9.2 release.
>>>>>>
>>>>>> All patches are now reviewed, so this series can be pulled. I'll report
>>>>>> that to
>>>>>> MSYS2 too, so we can enable clang environments for QEMU.
>>>>>>
>>>>>> v1: https://patchew.org/QEMU/20241031040426.772604-1-
>>>>>> pierrick.bouvier@linaro.org/
>>>>>>
>>>>>> v2:
>>>>>> - drop attribute gcc_struct instead of using -mno-ms-bitfields option
>>>>>> - add a section about bitfields in documentation
>>>>>>
>>>>>> v3:
>>>>>> - explain why gcc_struct attribute matters in packed structs in commit
>>>>>> message
>>>>>> - reword the bitfields documentation with suggestions given
>>>>>>
>>>>>> v4:
>>>>>> - edit for bitfields doc requested by Philippe
>>>>>>
>>>>>> Pierrick Bouvier (3):
>>>>>>      win32: remove usage of attribute gcc_struct
>>>>>>      docs/devel/style: add a section about bitfield, and disallow them for
>>>>>>        packed structures
>>>>>>      plugins: enable linking with clang/lld
>>>>>>
>>>>>>     docs/devel/style.rst                      | 20 +++++++++++++++++++
>>>>>>     meson.build                               |  6 +++---
>>>>>>     include/qemu/compiler.h                   |  7 +------
>>>>>>     scripts/cocci-macro-file.h                |  6 +-----
>>>>>>     subprojects/libvhost-user/libvhost-user.h |  6 +-----
>>>>>>     contrib/plugins/meson.build               |  2 +-
>>>>>>     plugins/meson.build                       | 24 +++++++++++++++++++----
>>>>>>     tests/tcg/plugins/meson.build             |  3 +--
>>>>>>     8 files changed, 48 insertions(+), 26 deletions(-)
>>>>>>
>>>>>
>>>>> It would be nice if a maintainer could pull this, so we can get this
>>>>> merged upstream.
>>>>
>>>> That'd be Thomas or Alex I suppose.
>>> This touches plugins, so I think it should go through Alex' tree?
>>>     Thomas
>>>
>>
>> It's touching plugins, but it does a system wide change as well (which
>> is the most important part).
>>
>> It's not really important who merges this, but it would be better if
>> the series could be pulled as a whole, instead of breaking it into
>> multiple subsystems.
> 
> I'll look at it tomorrow when going through my maintainer queue.
>

Thanks Alex :).

>>
>> Thanks,
>> Pierrick
> 


^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v4 1/3] win32: remove usage of attribute gcc_struct
  2025-01-10 20:33 ` [PATCH v4 1/3] win32: remove usage of attribute gcc_struct Pierrick Bouvier
@ 2025-01-13 23:38   ` Michael S. Tsirkin
  0 siblings, 0 replies; 24+ messages in thread
From: Michael S. Tsirkin @ 2025-01-13 23:38 UTC (permalink / raw)
  To: Pierrick Bouvier
  Cc: qemu-devel, Mahmoud Mandour, Markus Armbruster,
	Daniel P. Berrangé, Thomas Huth, Paolo Bonzini,
	Stefano Garzarella, Philippe Mathieu-Daudé, Alex Bennée,
	Marc-André Lureau, Alexandre Iooss, Richard Henderson

On Fri, Jan 10, 2025 at 12:33:59PM -0800, Pierrick Bouvier wrote:
> This attribute is not recognized by clang.
> 
> An investigation has been performed to ensure this attribute has no
> effect on layout of structures we use in QEMU [1], so it's safe to
> remove now.
> 
> In the future, we'll forbid introducing new bitfields in packed struct,
> as they are the one potentially impacted by this change.
> 
> [1] https://lore.kernel.org/qemu-devel/66c346de-7e20-4831-b3eb-1cda83240af9@linaro.org/
> Reviewed-by: Thomas Huth <thuth@redhat.com>
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
> Acked-by: Stefano Garzarella <sgarzare@redhat.com>
> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
> ---
>  meson.build                               | 5 -----
>  include/qemu/compiler.h                   | 7 +------
>  scripts/cocci-macro-file.h                | 6 +-----
>  subprojects/libvhost-user/libvhost-user.h | 6 +-----
>  4 files changed, 3 insertions(+), 21 deletions(-)
> 
> diff --git a/meson.build b/meson.build
> index d06f59095c6..da279cc1124 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -377,11 +377,6 @@ 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
>  
>  # Choose instruction set (currently x86-only)
> diff --git a/include/qemu/compiler.h b/include/qemu/compiler.h
> index c06954ccb41..d904408e5ed 100644
> --- a/include/qemu/compiler.h
> +++ b/include/qemu/compiler.h
> @@ -22,12 +22,7 @@
>  #define QEMU_EXTERN_C extern
>  #endif
>  
> -#if defined(_WIN32) && (defined(__x86_64__) || defined(__i386__))
> -# define QEMU_PACKED __attribute__((gcc_struct, packed))
> -#else
> -# define QEMU_PACKED __attribute__((packed))
> -#endif
> -
> +#define QEMU_PACKED __attribute__((packed))
>  #define QEMU_ALIGNED(X) __attribute__((aligned(X)))
>  
>  #ifndef glue
> diff --git a/scripts/cocci-macro-file.h b/scripts/cocci-macro-file.h
> index d247a5086e9..c64831d5408 100644
> --- a/scripts/cocci-macro-file.h
> +++ b/scripts/cocci-macro-file.h
> @@ -23,11 +23,7 @@
>  #define G_GNUC_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
>  #define G_GNUC_NULL_TERMINATED __attribute__((sentinel))
>  
> -#if defined(_WIN32) && (defined(__x86_64__) || defined(__i386__))
> -# define QEMU_PACKED __attribute__((gcc_struct, packed))
> -#else
> -# define QEMU_PACKED __attribute__((packed))
> -#endif
> +#define QEMU_PACKED __attribute__((packed))
>  
>  #define cat(x,y) x ## y
>  #define cat2(x,y) cat(x,y)
> diff --git a/subprojects/libvhost-user/libvhost-user.h b/subprojects/libvhost-user/libvhost-user.h
> index deb40e77b3f..2ffc58c11b1 100644
> --- a/subprojects/libvhost-user/libvhost-user.h
> +++ b/subprojects/libvhost-user/libvhost-user.h
> @@ -186,11 +186,7 @@ typedef struct VhostUserShared {
>      unsigned char uuid[UUID_LEN];
>  } VhostUserShared;
>  
> -#if defined(_WIN32) && (defined(__x86_64__) || defined(__i386__))
> -# define VU_PACKED __attribute__((gcc_struct, packed))
> -#else
> -# define VU_PACKED __attribute__((packed))
> -#endif
> +#define VU_PACKED __attribute__((packed))
>  
>  typedef struct VhostUserMsg {
>      int request;



Acked-by: Michael S. Tsirkin <mst@redhat.com>

> -- 
> 2.39.5



^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v4 0/3] Enable clang build on Windows
  2025-01-10 20:33 [PATCH v4 0/3] Enable clang build on Windows Pierrick Bouvier
                   ` (4 preceding siblings ...)
  2025-01-11 22:08 ` Stefan Weil via
@ 2025-01-14  8:20 ` Alex Bennée
  2025-01-14  8:35   ` Philippe Mathieu-Daudé
  5 siblings, 1 reply; 24+ messages in thread
From: Alex Bennée @ 2025-01-14  8:20 UTC (permalink / raw)
  To: Pierrick Bouvier
  Cc: qemu-devel, Mahmoud Mandour, Markus Armbruster,
	Daniel P. Berrangé, Thomas Huth, Paolo Bonzini,
	Stefano Garzarella, Philippe Mathieu-Daudé,
	Michael S. Tsirkin, Marc-André Lureau, Alexandre Iooss

Pierrick Bouvier <pierrick.bouvier@linaro.org> writes:

> For now, it was only possible to build plugins using GCC on Windows. However,
> windows-aarch64 only supports Clang.
> This biggest roadblock was to get rid of gcc_struct attribute, which is not
> supported by Clang. After investigation, we proved it was safe to drop it.
>
> Built and tested on Windows (all msys env)/Linux/MacOS for x86_64 and aarch64
> hosts.
<snip>

Queued to maintainer/jan-2025 and testing/next, thanks.

-- 
Alex Bennée
Virtualisation Tech Lead @ Linaro


^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v4 0/3] Enable clang build on Windows
  2025-01-14  8:20 ` Alex Bennée
@ 2025-01-14  8:35   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 24+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-01-14  8:35 UTC (permalink / raw)
  To: Alex Bennée, Pierrick Bouvier
  Cc: qemu-devel, Mahmoud Mandour, Markus Armbruster,
	Daniel P. Berrangé, Thomas Huth, Paolo Bonzini,
	Stefano Garzarella, Michael S. Tsirkin, Marc-André Lureau,
	Alexandre Iooss

On 14/1/25 09:20, Alex Bennée wrote:
> Pierrick Bouvier <pierrick.bouvier@linaro.org> writes:
> 
>> For now, it was only possible to build plugins using GCC on Windows. However,
>> windows-aarch64 only supports Clang.
>> This biggest roadblock was to get rid of gcc_struct attribute, which is not
>> supported by Clang. After investigation, we proved it was safe to drop it.
>>
>> Built and tested on Windows (all msys env)/Linux/MacOS for x86_64 and aarch64
>> hosts.
> <snip>
> 
> Queued to maintainer/jan-2025 and testing/next, thanks.

Please also take this one on top:
https://lore.kernel.org/qemu-devel/20250111215244.1680931-1-sw@weilnetz.de/

Thanks!


^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v4 0/3] Enable clang build on Windows
  2025-01-11 22:08 ` Stefan Weil via
  2025-01-12 17:54   ` Pierrick Bouvier
@ 2025-02-18  4:11   ` Brian Cain
  2025-02-18 16:22     ` Pierrick Bouvier
  1 sibling, 1 reply; 24+ messages in thread
From: Brian Cain @ 2025-02-18  4:11 UTC (permalink / raw)
  To: Stefan Weil, Pierrick Bouvier, qemu-devel
  Cc: Mahmoud Mandour, Markus Armbruster, Daniel P. Berrangé,
	Thomas Huth, Paolo Bonzini, Stefano Garzarella,
	Philippe Mathieu-Daudé, Alex Bennée, Michael S. Tsirkin,
	Marc-André Lureau, Alexandre Iooss


On 1/11/2025 4:08 PM, Stefan Weil via wrote:
> Am 10.01.25 um 21:33 schrieb Pierrick Bouvier:
>> For now, it was only possible to build plugins using GCC on Windows. 
>> However,
>> windows-aarch64 only supports Clang.
>> This biggest roadblock was to get rid of gcc_struct attribute, which 
>> is not
>> supported by Clang. After investigation, we proved it was safe to 
>> drop it.
>>
>> Built and tested on Windows (all msys env)/Linux/MacOS for x86_64 and 
>> aarch64
>> hosts.
>>
>> v1 contained warning fixes and various bits that have been upstreamed 
>> already.
>> The only bits left in this series are the gcc_struct removal, and 
>> fixing the
>> plugins build with clang.
>>
>> This series is for 10.0, as we decided to not include the gcc_struct 
>> removal is
>> 9.2 release.
>>
>> All patches are now reviewed, so this series can be pulled. I'll 
>> report that to
>> MSYS2 too, so we can enable clang environments for QEMU.
>>
>> v1: 
>> https://patchew.org/QEMU/20241031040426.772604-1-pierrick.bouvier@linaro.org/
>>
>> v2:
>> - drop attribute gcc_struct instead of using -mno-ms-bitfields option
>> - add a section about bitfields in documentation
>>
>> v3:
>> - explain why gcc_struct attribute matters in packed structs in 
>> commit message
>> - reword the bitfields documentation with suggestions given
>>
>> v4:
>> - edit for bitfields doc requested by Philippe
>>
>> Pierrick Bouvier (3):
>>    win32: remove usage of attribute gcc_struct
>>    docs/devel/style: add a section about bitfield, and disallow them for
>>      packed structures
>>    plugins: enable linking with clang/lld
>>
>>   docs/devel/style.rst                      | 20 +++++++++++++++++++
>>   meson.build                               |  6 +++---
>>   include/qemu/compiler.h                   |  7 +------
>>   scripts/cocci-macro-file.h                |  6 +-----
>>   subprojects/libvhost-user/libvhost-user.h |  6 +-----
>>   contrib/plugins/meson.build               |  2 +-
>>   plugins/meson.build                       | 24 +++++++++++++++++++----
>>   tests/tcg/plugins/meson.build             |  3 +--
>>   8 files changed, 48 insertions(+), 26 deletions(-)
>
> This nice series allows building QEMU for Windows with the LLVM cross 
> compiler on my ARM64 machine, so you can add

Is this toolchain available publicly or did you build it yourself?  It 
would be handy if there were a linux x86_64 hosted cross-toolchain that 
can target Windows-aarch64.  Or linux aarch64 hosted would be pretty 
good, too.

Is there an MSYS2 or other distributor that provides windows-aarch64 
builds of the glib and other library dependencies?

>
> Tested-by: Stefan Weil <sw@weilnetz.de>
>
> I only needed a trivial additional fix in scripts/nsis.py for `make 
> installer` because the usual GNU objdump and the LLVM objdump (or the 
> cross x86_64-w64-mingw32-objdump in my test) produce slightly 
> different output (indentation with \t, indentation with four spaces). 
> I'll prepare a patch which eliminates the need for objdump, so no 
> intermediate fix is needed for this.
>
> Stefan W.
>


^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v4 0/3] Enable clang build on Windows
  2025-02-18  4:11   ` Brian Cain
@ 2025-02-18 16:22     ` Pierrick Bouvier
  2025-02-18 16:26       ` Daniel P. Berrangé
  2025-02-18 20:59       ` Stefan Weil via
  0 siblings, 2 replies; 24+ messages in thread
From: Pierrick Bouvier @ 2025-02-18 16:22 UTC (permalink / raw)
  To: Brian Cain, Stefan Weil, qemu-devel
  Cc: Mahmoud Mandour, Markus Armbruster, Daniel P. Berrangé,
	Thomas Huth, Paolo Bonzini, Stefano Garzarella,
	Philippe Mathieu-Daudé, Alex Bennée, Michael S. Tsirkin,
	Marc-André Lureau, Alexandre Iooss

Hi Brian,

On 2/17/25 20:11, Brian Cain wrote:
> 
> On 1/11/2025 4:08 PM, Stefan Weil via wrote:
>> Am 10.01.25 um 21:33 schrieb Pierrick Bouvier:
>>> For now, it was only possible to build plugins using GCC on Windows.
>>> However,
>>> windows-aarch64 only supports Clang.
>>> This biggest roadblock was to get rid of gcc_struct attribute, which
>>> is not
>>> supported by Clang. After investigation, we proved it was safe to
>>> drop it.
>>>
>>> Built and tested on Windows (all msys env)/Linux/MacOS for x86_64 and
>>> aarch64
>>> hosts.
>>>
>>> v1 contained warning fixes and various bits that have been upstreamed
>>> already.
>>> The only bits left in this series are the gcc_struct removal, and
>>> fixing the
>>> plugins build with clang.
>>>
>>> This series is for 10.0, as we decided to not include the gcc_struct
>>> removal is
>>> 9.2 release.
>>>
>>> All patches are now reviewed, so this series can be pulled. I'll
>>> report that to
>>> MSYS2 too, so we can enable clang environments for QEMU.
>>>
>>> v1:
>>> https://patchew.org/QEMU/20241031040426.772604-1-pierrick.bouvier@linaro.org/
>>>
>>> v2:
>>> - drop attribute gcc_struct instead of using -mno-ms-bitfields option
>>> - add a section about bitfields in documentation
>>>
>>> v3:
>>> - explain why gcc_struct attribute matters in packed structs in
>>> commit message
>>> - reword the bitfields documentation with suggestions given
>>>
>>> v4:
>>> - edit for bitfields doc requested by Philippe
>>>
>>> Pierrick Bouvier (3):
>>>     win32: remove usage of attribute gcc_struct
>>>     docs/devel/style: add a section about bitfield, and disallow them for
>>>       packed structures
>>>     plugins: enable linking with clang/lld
>>>
>>>    docs/devel/style.rst                      | 20 +++++++++++++++++++
>>>    meson.build                               |  6 +++---
>>>    include/qemu/compiler.h                   |  7 +------
>>>    scripts/cocci-macro-file.h                |  6 +-----
>>>    subprojects/libvhost-user/libvhost-user.h |  6 +-----
>>>    contrib/plugins/meson.build               |  2 +-
>>>    plugins/meson.build                       | 24 +++++++++++++++++++----
>>>    tests/tcg/plugins/meson.build             |  3 +--
>>>    8 files changed, 48 insertions(+), 26 deletions(-)
>>
>> This nice series allows building QEMU for Windows with the LLVM cross
>> compiler on my ARM64 machine, so you can add
> 
> Is this toolchain available publicly or did you build it yourself?  It
> would be handy if there were a linux x86_64 hosted cross-toolchain that
> can target Windows-aarch64.  Or linux aarch64 hosted would be pretty
> good, too.
> 

At the moment, the only open source toolchain supporting windows-arm64 
is llvm-mingw (https://github.com/mstorsjo/llvm-mingw).
There is some progress on gcc, but it is not yet fully upstream.
MSYS2 uses llvm-mingw for windows-arm64 environment.

On my side, I used a windows-arm64 machine with MSYS2 native environment.

It would be handy to cross compile, and the problem is not really QEMU 
itself, but to cross compile all the dependencies.
For x86_64, we use fedora, which provides convenient precompiled mingw 
packages for dependencies.
It's definitely not impossible to do the same for windows-arm64, but it 
just takes much more effort.

> Is there an MSYS2 or other distributor that provides windows-aarch64
> builds of the glib and other library dependencies?
> 

MSYS2 does, but it's complicated to download packages by hand if it's 
your idea. Better to cross compile it.

Regards,
Pierrick

>>
>> Tested-by: Stefan Weil <sw@weilnetz.de>
>>
>> I only needed a trivial additional fix in scripts/nsis.py for `make
>> installer` because the usual GNU objdump and the LLVM objdump (or the
>> cross x86_64-w64-mingw32-objdump in my test) produce slightly
>> different output (indentation with \t, indentation with four spaces).
>> I'll prepare a patch which eliminates the need for objdump, so no
>> intermediate fix is needed for this.
>>
>> Stefan W.
>>


^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v4 0/3] Enable clang build on Windows
  2025-02-18 16:22     ` Pierrick Bouvier
@ 2025-02-18 16:26       ` Daniel P. Berrangé
  2025-02-18 20:59       ` Stefan Weil via
  1 sibling, 0 replies; 24+ messages in thread
From: Daniel P. Berrangé @ 2025-02-18 16:26 UTC (permalink / raw)
  To: Pierrick Bouvier
  Cc: Brian Cain, Stefan Weil, qemu-devel, Mahmoud Mandour,
	Markus Armbruster, Thomas Huth, Paolo Bonzini, Stefano Garzarella,
	Philippe Mathieu-Daudé, Alex Bennée, Michael S. Tsirkin,
	Marc-André Lureau, Alexandre Iooss

On Tue, Feb 18, 2025 at 08:22:14AM -0800, Pierrick Bouvier wrote:
> Hi Brian,
> 
> On 2/17/25 20:11, Brian Cain wrote:
> > 
> > On 1/11/2025 4:08 PM, Stefan Weil via wrote:
> > > Am 10.01.25 um 21:33 schrieb Pierrick Bouvier:
> > > > For now, it was only possible to build plugins using GCC on Windows.
> > > > However,
> > > > windows-aarch64 only supports Clang.
> > > > This biggest roadblock was to get rid of gcc_struct attribute, which
> > > > is not
> > > > supported by Clang. After investigation, we proved it was safe to
> > > > drop it.
> > > > 
> > > > Built and tested on Windows (all msys env)/Linux/MacOS for x86_64 and
> > > > aarch64
> > > > hosts.
> > > > 
> > > > v1 contained warning fixes and various bits that have been upstreamed
> > > > already.
> > > > The only bits left in this series are the gcc_struct removal, and
> > > > fixing the
> > > > plugins build with clang.
> > > > 
> > > > This series is for 10.0, as we decided to not include the gcc_struct
> > > > removal is
> > > > 9.2 release.
> > > > 
> > > > All patches are now reviewed, so this series can be pulled. I'll
> > > > report that to
> > > > MSYS2 too, so we can enable clang environments for QEMU.
> > > > 
> > > > v1:
> > > > https://patchew.org/QEMU/20241031040426.772604-1-pierrick.bouvier@linaro.org/
> > > > 
> > > > v2:
> > > > - drop attribute gcc_struct instead of using -mno-ms-bitfields option
> > > > - add a section about bitfields in documentation
> > > > 
> > > > v3:
> > > > - explain why gcc_struct attribute matters in packed structs in
> > > > commit message
> > > > - reword the bitfields documentation with suggestions given
> > > > 
> > > > v4:
> > > > - edit for bitfields doc requested by Philippe
> > > > 
> > > > Pierrick Bouvier (3):
> > > >     win32: remove usage of attribute gcc_struct
> > > >     docs/devel/style: add a section about bitfield, and disallow them for
> > > >       packed structures
> > > >     plugins: enable linking with clang/lld
> > > > 
> > > >    docs/devel/style.rst                      | 20 +++++++++++++++++++
> > > >    meson.build                               |  6 +++---
> > > >    include/qemu/compiler.h                   |  7 +------
> > > >    scripts/cocci-macro-file.h                |  6 +-----
> > > >    subprojects/libvhost-user/libvhost-user.h |  6 +-----
> > > >    contrib/plugins/meson.build               |  2 +-
> > > >    plugins/meson.build                       | 24 +++++++++++++++++++----
> > > >    tests/tcg/plugins/meson.build             |  3 +--
> > > >    8 files changed, 48 insertions(+), 26 deletions(-)
> > > 
> > > This nice series allows building QEMU for Windows with the LLVM cross
> > > compiler on my ARM64 machine, so you can add
> > 
> > Is this toolchain available publicly or did you build it yourself?  It
> > would be handy if there were a linux x86_64 hosted cross-toolchain that
> > can target Windows-aarch64.  Or linux aarch64 hosted would be pretty
> > good, too.
> > 
> 
> At the moment, the only open source toolchain supporting windows-arm64 is
> llvm-mingw (https://github.com/mstorsjo/llvm-mingw).
> There is some progress on gcc, but it is not yet fully upstream.
> MSYS2 uses llvm-mingw for windows-arm64 environment.
> 
> On my side, I used a windows-arm64 machine with MSYS2 native environment.
> 
> It would be handy to cross compile, and the problem is not really QEMU
> itself, but to cross compile all the dependencies.
> For x86_64, we use fedora, which provides convenient precompiled mingw
> packages for dependencies.
> It's definitely not impossible to do the same for windows-arm64, but it just
> takes much more effort.

Once GCC supports arm64 for mingw, we could propose enabling
this in Fedora and enabling the it in the build deps.  Not a
terribly complex bit of work, but probably a bit of a time
sink to get all the pieces sorted. If this is important to
QEMU long term though, it'l be worth the effort, as the
Fedora mingw containers are what everyone is used to for
testing Windows buildability.


With regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|



^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v4 0/3] Enable clang build on Windows
  2025-02-18 16:22     ` Pierrick Bouvier
  2025-02-18 16:26       ` Daniel P. Berrangé
@ 2025-02-18 20:59       ` Stefan Weil via
  2025-02-18 23:17         ` Pierrick Bouvier
  1 sibling, 1 reply; 24+ messages in thread
From: Stefan Weil via @ 2025-02-18 20:59 UTC (permalink / raw)
  To: Pierrick Bouvier, Brian Cain, qemu-devel
  Cc: Mahmoud Mandour, Markus Armbruster, Daniel P. Berrangé,
	Thomas Huth, Paolo Bonzini, Stefano Garzarella,
	Philippe Mathieu-Daudé, Alex Bennée, Michael S. Tsirkin,
	Marc-André Lureau, Alexandre Iooss

Am 18.02.25 um 17:22 schrieb Pierrick Bouvier:
> On 2/17/25 20:11, Brian Cain wrote:
>> Is this toolchain available publicly or did you build it yourself?  It
>> would be handy if there were a linux x86_64 hosted cross-toolchain that
>> can target Windows-aarch64.  Or linux aarch64 hosted would be pretty
>> good, too.
>>
> 
> At the moment, the only open source toolchain supporting windows-arm64 
> is llvm-mingw (https://github.com/mstorsjo/llvm-mingw).
> There is some progress on gcc, but it is not yet fully upstream.
> MSYS2 uses llvm-mingw for windows-arm64 environment.
> 
> On my side, I used a windows-arm64 machine with MSYS2 native environment.
> 
> It would be handy to cross compile, and the problem is not really QEMU 
> itself, but to cross compile all the dependencies.
> For x86_64, we use fedora, which provides convenient precompiled mingw 
> packages for dependencies.
> It's definitely not impossible to do the same for windows-arm64, but it 
> just takes much more effort.
> 
>> Is there an MSYS2 or other distributor that provides windows-aarch64
>> builds of the glib and other library dependencies?
>>
> 
> MSYS2 does, but it's complicated to download packages by hand if it's 
> your idea. Better to cross compile it.

I could run a QEMU cross compile on Debian with the llvm toolchain and 
msys2 clangarm64 packages installed with pacman. The resulting installer 
is here:

https://qemu.weilnetz.de/aarch64/

The only tools which was missing and which I had to build before running 
the QEMU build is aarch64-w64-mingw32-windmc.

It looks like the NSIS installer is i386 code, so I don't know whether 
it can be used on Windows for aarch64.

I also have no suitable Windows host for testing the binaries, so no 
test was done.

Stefan W.


^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v4 0/3] Enable clang build on Windows
  2025-02-18 20:59       ` Stefan Weil via
@ 2025-02-18 23:17         ` Pierrick Bouvier
  2025-02-19  6:39           ` Stefan Weil via
  0 siblings, 1 reply; 24+ messages in thread
From: Pierrick Bouvier @ 2025-02-18 23:17 UTC (permalink / raw)
  To: Stefan Weil, Brian Cain, qemu-devel
  Cc: Mahmoud Mandour, Markus Armbruster, Daniel P. Berrangé,
	Thomas Huth, Paolo Bonzini, Stefano Garzarella,
	Philippe Mathieu-Daudé, Alex Bennée, Michael S. Tsirkin,
	Marc-André Lureau, Alexandre Iooss

On 2/18/25 12:59, Stefan Weil wrote:
> Am 18.02.25 um 17:22 schrieb Pierrick Bouvier:
>> On 2/17/25 20:11, Brian Cain wrote:
>>> Is this toolchain available publicly or did you build it yourself?  It
>>> would be handy if there were a linux x86_64 hosted cross-toolchain that
>>> can target Windows-aarch64.  Or linux aarch64 hosted would be pretty
>>> good, too.
>>>
>>
>> At the moment, the only open source toolchain supporting windows-arm64
>> is llvm-mingw (https://github.com/mstorsjo/llvm-mingw).
>> There is some progress on gcc, but it is not yet fully upstream.
>> MSYS2 uses llvm-mingw for windows-arm64 environment.
>>
>> On my side, I used a windows-arm64 machine with MSYS2 native environment.
>>
>> It would be handy to cross compile, and the problem is not really QEMU
>> itself, but to cross compile all the dependencies.
>> For x86_64, we use fedora, which provides convenient precompiled mingw
>> packages for dependencies.
>> It's definitely not impossible to do the same for windows-arm64, but it
>> just takes much more effort.
>>
>>> Is there an MSYS2 or other distributor that provides windows-aarch64
>>> builds of the glib and other library dependencies?
>>>
>>
>> MSYS2 does, but it's complicated to download packages by hand if it's
>> your idea. Better to cross compile it.
> 
> I could run a QEMU cross compile on Debian with the llvm toolchain and
> msys2 clangarm64 packages installed with pacman. The resulting installer
> is here:
> 

Have you installed the msys2 clangarm64 packages on a windows machine 
first, and then copy them to your Debian machine?

> https://qemu.weilnetz.de/aarch64/
> 
> The only tools which was missing and which I had to build before running
> the QEMU build is aarch64-w64-mingw32-windmc.
> 
> It looks like the NSIS installer is i386 code, so I don't know whether
> it can be used on Windows for aarch64.
> 
> I also have no suitable Windows host for testing the binaries, so no
> test was done.
> 
> Stefan W.


^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v4 0/3] Enable clang build on Windows
  2025-02-18 23:17         ` Pierrick Bouvier
@ 2025-02-19  6:39           ` Stefan Weil via
  2025-02-19  7:01             ` Pierrick Bouvier
  0 siblings, 1 reply; 24+ messages in thread
From: Stefan Weil via @ 2025-02-19  6:39 UTC (permalink / raw)
  To: Pierrick Bouvier, Brian Cain, qemu-devel
  Cc: Mahmoud Mandour, Markus Armbruster, Daniel P. Berrangé,
	Thomas Huth, Paolo Bonzini, Stefano Garzarella,
	Philippe Mathieu-Daudé, Alex Bennée, Michael S. Tsirkin,
	Marc-André Lureau, Alexandre Iooss

Am 19.02.25 um 00:17 schrieb Pierrick Bouvier:

> On 2/18/25 12:59, Stefan Weil wrote:
>>
>> I could run a QEMU cross compile on Debian with the llvm toolchain and
>> msys2 clangarm64 packages installed with pacman. The resulting installer
>> is here:
>>
>
> Have you installed the msys2 clangarm64 packages on a windows machine 
> first, and then copy them to your Debian machine?


No, the packages were directly installed on Linux like in this older 
script which shows how this can be done for i686 and x86-64::

https://github.com/stweil/qemu/blob/master/.github/workflows/pacman.sh

Newer Debian distributions already provide a package for pacman which 
simply needs the right configuration. For older distributions I had to 
build pacman first.

I should also have noted that I used a Linux aarch64 build host, so its 
binutils were able to find the DLL dependencies. This requirement will 
be fixed with a pure Python script for the same purpose.


>
>> https://qemu.weilnetz.de/aarch64/
>>
>> The only tool which was missing and which I had to build before running
>> the QEMU build is aarch64-w64-mingw32-windmc.
>>
>> It looks like the NSIS installer is i386 code, so I don't know whether
>> it can be used on Windows for aarch64.
>>
>> I also have no suitable Windows host for testing the binaries, so no
>> test was done.


^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v4 0/3] Enable clang build on Windows
  2025-02-19  6:39           ` Stefan Weil via
@ 2025-02-19  7:01             ` Pierrick Bouvier
  2025-02-19  7:38               ` Stefan Weil via
  0 siblings, 1 reply; 24+ messages in thread
From: Pierrick Bouvier @ 2025-02-19  7:01 UTC (permalink / raw)
  To: Stefan Weil, Brian Cain, qemu-devel
  Cc: Mahmoud Mandour, Markus Armbruster, Daniel P. Berrangé,
	Thomas Huth, Paolo Bonzini, Stefano Garzarella,
	Philippe Mathieu-Daudé, Alex Bennée, Michael S. Tsirkin,
	Marc-André Lureau, Alexandre Iooss

On 2/18/25 22:39, Stefan Weil wrote:
> Am 19.02.25 um 00:17 schrieb Pierrick Bouvier:
> 
>> On 2/18/25 12:59, Stefan Weil wrote:
>>>
>>> I could run a QEMU cross compile on Debian with the llvm toolchain and
>>> msys2 clangarm64 packages installed with pacman. The resulting installer
>>> is here:
>>>
>>
>> Have you installed the msys2 clangarm64 packages on a windows machine
>> first, and then copy them to your Debian machine?
> 
> 
> No, the packages were directly installed on Linux like in this older
> script which shows how this can be done for i686 and x86-64::
> 
> https://github.com/stweil/qemu/blob/master/.github/workflows/pacman.sh
> 
> Newer Debian distributions already provide a package for pacman which
> simply needs the right configuration. For older distributions I had to
> build pacman first.
> 
> I should also have noted that I used a Linux aarch64 build host, so its
> binutils were able to find the DLL dependencies. This requirement will
> be fixed with a pure Python script for the same purpose.
> 

Oh excellent! I wondered if it was possible or not to do this (didn't 
know if some post install hooks try to execute native code).
Thanks for the link.

> 
>>
>>> https://qemu.weilnetz.de/aarch64/
>>>
>>> The only tool which was missing and which I had to build before running
>>> the QEMU build is aarch64-w64-mingw32-windmc.
>>>
>>> It looks like the NSIS installer is i386 code, so I don't know whether
>>> it can be used on Windows for aarch64.
>>>
>>> I also have no suitable Windows host for testing the binaries, so no
>>> test was done.



^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v4 0/3] Enable clang build on Windows
  2025-02-19  7:01             ` Pierrick Bouvier
@ 2025-02-19  7:38               ` Stefan Weil via
  0 siblings, 0 replies; 24+ messages in thread
From: Stefan Weil via @ 2025-02-19  7:38 UTC (permalink / raw)
  To: Pierrick Bouvier, Brian Cain, qemu-devel
  Cc: Mahmoud Mandour, Markus Armbruster, Daniel P. Berrangé,
	Thomas Huth, Paolo Bonzini, Stefano Garzarella,
	Philippe Mathieu-Daudé, Alex Bennée, Michael S. Tsirkin,
	Marc-André Lureau, Alexandre Iooss

Am 19.02.25 um 08:01 schrieb Pierrick Bouvier:

> On 2/18/25 22:39, Stefan Weil wrote:
>> Am 19.02.25 um 00:17 schrieb Pierrick Bouvier:
>>
>>> On 2/18/25 12:59, Stefan Weil wrote:
>>>>
>>>> I could run a QEMU cross compile on Debian with the llvm toolchain and
>>>> msys2 clangarm64 packages installed with pacman. The resulting 
>>>> installer
>>>> is here:
>>>>
>>>
>>> Have you installed the msys2 clangarm64 packages on a windows machine
>>> first, and then copy them to your Debian machine?
>>
>>
>> No, the packages were directly installed on Linux like in this older
>> script which shows how this can be done for i686 and x86-64::
>>
>> https://github.com/stweil/qemu/blob/master/.github/workflows/pacman.sh
>>
>> Newer Debian distributions already provide a package for pacman which
>> simply needs the right configuration. For older distributions I had to
>> build pacman first.
>>
>> I should also have noted that I used a Linux aarch64 build host, so its
>> binutils were able to find the DLL dependencies. This requirement will
>> be fixed with a pure Python script for the same purpose.
>>
>
> Oh excellent! I wondered if it was possible or not to do this (didn't 
> know if some post install hooks try to execute native code).
> Thanks for the link.


A few of them do this. Usually I simply ignore the resulting errors, but 
it's also possible to provide native Linux executables to get these 
hooks working.



^ permalink raw reply	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2025-02-19  7:39 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-10 20:33 [PATCH v4 0/3] Enable clang build on Windows Pierrick Bouvier
2025-01-10 20:33 ` [PATCH v4 1/3] win32: remove usage of attribute gcc_struct Pierrick Bouvier
2025-01-13 23:38   ` Michael S. Tsirkin
2025-01-10 20:34 ` [PATCH v4 2/3] docs/devel/style: add a section about bitfield, and disallow them for packed structures Pierrick Bouvier
2025-01-10 20:34 ` [PATCH v4 3/3] plugins: enable linking with clang/lld Pierrick Bouvier
2025-01-10 20:37 ` [PATCH v4 0/3] Enable clang build on Windows Pierrick Bouvier
2025-01-11 15:47   ` Philippe Mathieu-Daudé
2025-01-12 18:03     ` Philippe Mathieu-Daudé
2025-01-13  6:26     ` Thomas Huth
2025-01-13 20:17       ` Pierrick Bouvier
2025-01-13 21:19         ` Alex Bennée
2025-01-13 21:22           ` Pierrick Bouvier
2025-01-11 22:08 ` Stefan Weil via
2025-01-12 17:54   ` Pierrick Bouvier
2025-02-18  4:11   ` Brian Cain
2025-02-18 16:22     ` Pierrick Bouvier
2025-02-18 16:26       ` Daniel P. Berrangé
2025-02-18 20:59       ` Stefan Weil via
2025-02-18 23:17         ` Pierrick Bouvier
2025-02-19  6:39           ` Stefan Weil via
2025-02-19  7:01             ` Pierrick Bouvier
2025-02-19  7:38               ` Stefan Weil via
2025-01-14  8:20 ` Alex Bennée
2025-01-14  8:35   ` Philippe Mathieu-Daudé

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).