Skip to contentSkip to conversation

Misc changes to allow building with Windows Clang

PATCH Superseded Kostiantyn Kostiuk 6 participants 37 messages Mar 26 – Mar 27 Arm/Amlogic Meson SoC support

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover Misc changes to allow building with Windows Clang

This is the first set of changes to allow building qemu-ga with Microsoft Windows Clang. It includes some cleanups and fixes that also make the code more portable. The main goal is to be able to build qemu-ga with the MSVC toolchain because MinGW-w64 is not available for ARM64 Windows.

These changes were tested on CentOS Stream, Arch Linux, FreeBSD, NetBSD. Full QEMU tree was compiled without any issues on all these platforms.

The full set of changes consists of about fifteen more patches. Once that is complete, I will add documentation on how to build qemu-ga with MSVC clang and a CI job that tests it.

Kostiantyn Kostiuk (6):
meson: Use stddef.h instead of unistd.h
qom: Use g_ascii_strcasecmp instead of strcasecmp
osdep: Remove unused strings.h
Remove unused dirent.h
Remove unused sys/param.h
meson: Build block_syms and qemu_syms only when enable_modules

Paolo Bonzini (1):
storage-daemon: use same link arguments as other tools

 include/qemu/osdep.h       |  1 -
 meson.build                | 35 +++++++++++++++++++----------------
 qom/object.c               |  4 ++--
 storage-daemon/meson.build | 16 ++++++++--------
 util/drm.c                 |  1 -
 util/path.c                |  2 --
 6 files changed, 29 insertions(+), 30 deletions(-)

--
2.52.0

#1 lore raw

PATCH 1/7 meson: Use stddef.h instead of unistd.h

This is more cross-platform way.

---
 meson.build | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meson.build +1 -1
index d7c4095b39..711dafa9ce 100644
@@ -1060,7 +1060,7 @@ endif
 
 if not cc.compiles('''
   #include <glib.h>
-  #include <unistd.h>
+  #include <stddef.h>
 
   #define QEMU_BUILD_BUG_ON(x) \
   typedef char qemu_build_bug_on[(x)?-1:1] __attribute__((unused));
Signature · 1 line
2.52.0
Reviewed-by on v1 1/7
#2 lore raw

Re: [PATCH 1/7] meson: Use stddef.h instead of unistd.h

Quoted 13 lines · Kostiantyn Kostiuk

This is more cross-platform way.

---
 meson.build | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meson.build +0 -0
index d7c4095b39..711dafa9ce 100644

meson.build endif · line 1063

Quoted 5 lines
meson.build +1 -1
@@ -1060,7 +1060,7 @@ endif
 
 if not cc.compiles('''
   #include <glib.h>
-  #include <unistd.h>
+  #include <stddef.h>

POSIX says stddef.h provides size_t, which is the only thing we care about here. (But it also says that unistd.h provides it, so your platform is broken.)

This is the kind of detail that should be in the commit message:
you need to explain why it is OK to make the change and why the previous code is wrong.

thanks
-- PMM

#3 lore raw

Re: [PATCH 1/7] meson: Use stddef.h instead of unistd.h

Il gio 26 mar 2026, 17:34 Peter Maydell <[email protected]> ha scritto:

Quoted 4 lines

POSIX says stddef.h provides size_t, which is the only thing we care about here. (But it also says that unistd.h provides it, so your platform is broken.)

It's not POSIX to begin with. :) There are other small differences between MSVC and Mingw runtimes but the main one is exactly that it doesn't have unistd.h at all.

Having taken a peek at the full set of changes needed to build qemu-ga with MSVC runtime, most of them are cleanups like these ones that (review comments aside) make sense on their own anyway. In some cases... a bit less.

Paolo

This is the kind of detail that should be in the commit message:

Quoted 9 lines

you need to explain why it is OK to make the change and why the previous code is wrong.

thanks
-- PMM

#4 lore raw

PATCH 2/7 qom: Use g_ascii_strcasecmp instead of strcasecmp

In reply to Kostiantyn Kostiuk
---
 qom/object.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
qom/object.c +2 -2
index ff8ede8a32..e5c0c2f53e 100644
@@ -1193,8 +1193,8 @@ GSList *object_class_get_list(const char *implements_type,
 
 static gint object_class_cmp(gconstpointer a, gconstpointer b, gpointer d)
 {
-    return strcasecmp(object_class_get_name((ObjectClass *)a),
-                      object_class_get_name((ObjectClass *)b));
+    return g_ascii_strcasecmp(object_class_get_name((ObjectClass *)a),
+                              object_class_get_name((ObjectClass *)b));
 }
 
 GSList *object_class_get_list_sorted(const char *implements_type,
Signature · 1 line
2.52.0
Reviewed-by on v1 2/7
#5 lore raw

Re: [PATCH 2/7] qom: Use g_ascii_strcasecmp instead of strcasecmp

Quoted 11 lines · Kostiantyn Kostiuk
---
 qom/object.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
qom/object.c +0 -0
index ff8ede8a32..e5c0c2f53e 100644

qom/object.c GSList *object_class_get_list(const char *implements_type, · line 1198

Quoted 8 lines
qom/object.c +2 -2
@@ -1193,8 +1193,8 @@ GSList *object_class_get_list(const char *implements_type,
 
 static gint object_class_cmp(gconstpointer a, gconstpointer b, gpointer d)
 {
-    return strcasecmp(object_class_get_name((ObjectClass *)a),
-                      object_class_get_name((ObjectClass *)b));
+    return g_ascii_strcasecmp(object_class_get_name((ObjectClass *)a),
+                              object_class_get_name((ObjectClass *)b));
 }

The commit message should note that this is a change in semantics (g_ascii_strcasecmp() doesn't honour locale but strcasecmp() does) but that this is OK for two reasons:
(1) we want the comparison on class names to be a plain ASCII one, not to do weird things with "I" in Turkish locales, so g_ascii_strcasecmp() is better as it's explicit about that
(2) QEMU always runs with the C locale so there's not an actual behaviour change here

(I forgot about point (2) in my email on the other branch of this thread -- apologies for the confusion.)

-- PMM

#6 lore raw

PATCH 3/7 osdep: Remove unused strings.h

In reply to Kostiantyn Kostiuk
---
 include/qemu/osdep.h | 1 -
 1 file changed, 1 deletion(-)
include/qemu/osdep.h +0 -1
index f151578b5c..2f0e61ad6b 100644
@@ -114,7 +114,6 @@ QEMU_EXTERN_C int daemon(int, int);
 #include <stdio.h>
 
 #include <string.h>
-#include <strings.h>
 #include <inttypes.h>
 #include <limits.h>
 /* Put unistd.h before time.h as that triggers localtime_r/gmtime_r
Signature · 1 line
2.52.0
#7 lore raw

Re: [PATCH 3/7] osdep: Remove unused strings.h

Quoted 11 lines · Kostiantyn Kostiuk
---
 include/qemu/osdep.h | 1 -
 1 file changed, 1 deletion(-)
include/qemu/osdep.h +0 -0
index f151578b5c..2f0e61ad6b 100644

include/qemu/osdep.h QEMU_EXTERN_C int daemon(int, int); · line 119

Quoted 7 lines
include/qemu/osdep.h +0 -1
@@ -114,7 +114,6 @@ QEMU_EXTERN_C int daemon(int, int);
 #include <stdio.h>
 
 #include <string.h>
-#include <strings.h>
 #include <inttypes.h>
 #include <limits.h>
 /* Put unistd.h before time.h as that triggers localtime_r/gmtime_r

This needs more rationale about why we can drop the header. POSIX says it brings in ffs(), strncasecmp_l() and strcasecmp_l(), which we don't use, but also strcasecmp() and strncasecmp() which we definitely do use.

Some libcs (notably glibc) may also define those in string.h, but the manpage says that's a backward-compatibility thing, so we shouldn't rely on it.

-- PMM

#8 lore raw

Re: [PATCH 3/7] osdep: Remove unused strings.h

Quoted 15 lines · Peter Maydell
Quoted 13 lines · Kostiantyn Kostiuk
---
 include/qemu/osdep.h | 1 -
 1 file changed, 1 deletion(-)
include/qemu/osdep.h +0 -0
index f151578b5c..2f0e61ad6b 100644
@@ -114,7 +114,6 @@ QEMU_EXTERN_C int daemon(int, int);
 #include <stdio.h>
 
Quoted 11 lines

include/qemu/osdep.h QEMU_EXTERN_C int daemon(int, int); · line 119

Quoted 5 lines
include/qemu/osdep.h +0 -1
 #include <string.h>
-#include <strings.h>
 #include <inttypes.h>
 #include <limits.h>
 /* Put unistd.h before time.h as that triggers localtime_r/gmtime_r

This needs more rationale about why we can drop the header. POSIX says it brings in ffs(), strncasecmp_l() and strcasecmp_l(), which we don't use, but also strcasecmp() and strncasecmp() which we definitely do use.

Will be ok if I replace strcasecmp with g_ascii_strcasecmp (and other functions)
in the full QEMU tree?

Currently, I see in QEMU we have a mix of strcasecmp/g_ascii_strcasecmp. In some places we use glb2, in some libc.

Quoted 7 lines

Some libcs (notably glibc) may also define those in string.h, but the manpage says that's a backward-compatibility thing, so we shouldn't rely on it.

-- PMM

#9 lore raw

Re: [PATCH 3/7] osdep: Remove unused strings.h

Quoted 33 lines · Kostiantyn Kostiuk
Quoted 15 lines · Peter Maydell
Quoted 13 lines · Kostiantyn Kostiuk
---
 include/qemu/osdep.h | 1 -
 1 file changed, 1 deletion(-)
include/qemu/osdep.h +0 -0
index f151578b5c..2f0e61ad6b 100644
@@ -114,7 +114,6 @@ QEMU_EXTERN_C int daemon(int, int);
 #include <stdio.h>
 
Quoted 10 lines

include/qemu/osdep.h QEMU_EXTERN_C int daemon(int, int); · line 119

Quoted 5 lines
include/qemu/osdep.h +0 -1
 #include <string.h>
-#include <strings.h>
 #include <inttypes.h>
 #include <limits.h>
 /* Put unistd.h before time.h as that triggers localtime_r/gmtime_r

This needs more rationale about why we can drop the header. POSIX says it brings in ffs(), strncasecmp_l() and strcasecmp_l(), which we don't use, but also strcasecmp() and strncasecmp() which we definitely do use.

Quoted 5 lines

Will be ok if I replace strcasecmp with g_ascii_strcasecmp (and other functions) in the full QEMU tree?

Currently, I see in QEMU we have a mix of strcasecmp/g_ascii_strcasecmp. In some places we use glb2, in some libc.

Yes, it would be OK, but we need to be a bit careful, because strcasecmp() and g_ascii_strcasecmp() aren't identical; the former honours locale and the latter is a pure ASCII comparison. So we need to check that that's what we want. A quick look at the grep results suggests that in fact we really do want an ASCII comparison in all these places (and the locale stuff in strcasecmp can be a source of bugs, as noted e.g. here:
https://daniel.haxx.se/blog/2008/10/15/strcasecmp-in-turkish/ ); but it does need a little bit of a check of the context where the functions are used. Where we're doing something like "check this input value matches 'off'" this is a code cleanup regardless of portability requirements.

thanks
-- PMM

#10 lore raw

Re: [PATCH 3/7] osdep: Remove unused strings.h

Quoted 44 lines · Peter Maydell
Quoted 6 lines · Kostiantyn Kostiuk

On Thu, Mar 26, 2026 at 6:20 PM Peter Maydell <[email protected]>

Quoted 2 lines · wrote:
Quoted 2 lines

On Thu, 26 Mar 2026 at 16:02, Kostiantyn Kostiuk <[email protected]>

Quoted 25 lines · wrote:
Quoted 13 lines
Quoted 13 lines
---
 include/qemu/osdep.h | 1 -
 1 file changed, 1 deletion(-)
include/qemu/osdep.h +0 -0
index f151578b5c..2f0e61ad6b 100644
@@ -114,7 +114,6 @@ QEMU_EXTERN_C int daemon(int, int);
 #include <stdio.h>
 
Quoted 10 lines

include/qemu/osdep.h QEMU_EXTERN_C int daemon(int, int); · line 119

Quoted 5 lines
include/qemu/osdep.h +0 -1
 #include <string.h>
-#include <strings.h>
 #include <inttypes.h>
 #include <limits.h>
 /* Put unistd.h before time.h as that triggers localtime_r/gmtime_r

This needs more rationale about why we can drop the header. POSIX says it brings in ffs(), strncasecmp_l() and strcasecmp_l(), which we don't use, but also strcasecmp() and strncasecmp() which we definitely do use.

Quoted 1 line

Will be ok if I replace strcasecmp with g_ascii_strcasecmp (and other

functions)

Quoted 4 lines

in the full QEMU tree?

Currently, I see in QEMU we have a mix of strcasecmp/g_ascii_strcasecmp. In some places we use glb2, in some libc.

Quoted 14 lines

Yes, it would be OK, but we need to be a bit careful, because strcasecmp() and g_ascii_strcasecmp() aren't identical; the former honours locale and the latter is a pure ASCII comparison. So we need to check that that's what we want. A quick look at the grep results suggests that in fact we really do want an ASCII comparison in all these places (and the locale stuff in strcasecmp can be a source of bugs, as noted e.g. here:
https://daniel.haxx.se/blog/2008/10/15/strcasecmp-in-turkish/ ); but it does need a little bit of a check of the context where the functions are used. Where we're doing something like "check this input value matches 'off'" this is a code cleanup regardless of portability requirements.

Is this ok to update several strcasecmp usage in one commit, or better to split it per component?

Quoted 4 lines

thanks
-- PMM

#11 lore raw

Re: [PATCH 3/7] osdep: Remove unused strings.h

Quoted 26 lines · Kostiantyn Kostiuk
Quoted 8 lines · Peter Maydell
Quoted 5 lines · Kostiantyn Kostiuk

Will be ok if I replace strcasecmp with g_ascii_strcasecmp (and other functions) in the full QEMU tree?

Currently, I see in QEMU we have a mix of strcasecmp/g_ascii_strcasecmp. In some places we use glb2, in some libc.

Quoted 13 lines

Yes, it would be OK, but we need to be a bit careful, because strcasecmp() and g_ascii_strcasecmp() aren't identical; the former honours locale and the latter is a pure ASCII comparison. So we need to check that that's what we want. A quick look at the grep results suggests that in fact we really do want an ASCII comparison in all these places (and the locale stuff in strcasecmp can be a source of bugs, as noted e.g. here:
https://daniel.haxx.se/blog/2008/10/15/strcasecmp-in-turkish/ ); but it does need a little bit of a check of the context where the functions are used. Where we're doing something like "check this input value matches 'off'" this is a code cleanup regardless of portability requirements.

Quoted 2 lines

Is this ok to update several strcasecmp usage in one commit, or better to split it per component?

I think I would split it per component, because the people who might care about it are different in each case.

-- PMM

#12 lore raw

PATCH 4/7 Remove unused dirent.h

In reply to Kostiantyn Kostiuk
---
 util/drm.c  | 1 -
 util/path.c | 1 -
 2 files changed, 2 deletions(-)
util/drm.c +0 -1
index dae8ffebc8..afa9c400df 100644
@@ -18,7 +18,6 @@
 #include "qemu/drm.h"
 
 #include <glob.h>
-#include <dirent.h>
 
 int qemu_drm_rendernode_open(const char *rendernode)
 {
util/path.c +0 -1
index 8e174eb436..72a255890e 100644
@@ -5,7 +5,6 @@
 */
 #include "qemu/osdep.h"
 #include <sys/param.h>
-#include <dirent.h>
 #include "qemu/cutils.h"
 #include "qemu/path.h"
 #include "qemu/thread.h"
Signature · 1 line
2.52.0
#13 lore raw

Re: [PATCH 4/7] Remove unused dirent.h

Quoted 12 lines · Kostiantyn Kostiuk
---
 util/drm.c  | 1 -
 util/path.c | 1 -
 2 files changed, 2 deletions(-)
util/drm.c +0 -0
index dae8ffebc8..afa9c400df 100644

util/drm.c line 23

Quoted 7 lines
util/drm.c +0 -1
@@ -18,7 +18,6 @@
 #include "qemu/drm.h"
 
 #include <glob.h>
-#include <dirent.h>
 
 int qemu_drm_rendernode_open(const char *rendernode)
 {

This file uses opendir()/readdir()/closedir(), all of which are specified to be brought in by <dirent.h>, so we can't drop this include.

util/path.c line 10

Quoted 12 lines
util/path.c +0 -1
index 8e174eb436..72a255890e 100644
@@ -5,7 +5,6 @@
 */
 #include "qemu/osdep.h"
 #include <sys/param.h>
-#include <dirent.h>
 #include "qemu/cutils.h"
 #include "qemu/path.h"
 #include "qemu/thread.h"

This one is OK to drop, because the rewrite of path.c in commit f3a8bdc1d5b26 removed the uses of the dirent.h functions.

thanks
-- PMM

#14 lore raw

Re: [PATCH 4/7] Remove unused dirent.h

Quoted 10 lines · Peter Maydell
Quoted 6 lines

#include <glob.h>
-#include <dirent.h>

  int qemu_drm_rendernode_open(const char *rendernode)
  {

This file uses opendir()/readdir()/closedir(), all of which are specified to be brought in by <dirent.h>, so we can't drop this include.

It's also compiled only if host_os != 'windows', so it doesn't matter for the purpose of compiling qemu-ga with MSVC/clang-cl.

Paolo

#15 lore raw

PATCH 5/7 Remove unused sys/param.h

In reply to Kostiantyn Kostiuk
---
 util/path.c | 1 -
 1 file changed, 1 deletion(-)
util/path.c +0 -1
index 72a255890e..e1565894d2 100644
@@ -4,7 +4,6 @@
    The assumption is that this area does not change.
 */
 #include "qemu/osdep.h"
-#include <sys/param.h>
 #include "qemu/cutils.h"
 #include "qemu/path.h"
 #include "qemu/thread.h"
Signature · 1 line
2.52.0
Reviewed-by on v1 5/7
#16 lore raw

Re: [PATCH 5/7] Remove unused sys/param.h

Quoted 11 lines · Kostiantyn Kostiuk
---
 util/path.c | 1 -
 1 file changed, 1 deletion(-)
util/path.c +0 -0
index 72a255890e..e1565894d2 100644

util/path.c line 9

Quoted 7 lines
util/path.c +0 -1
@@ -4,7 +4,6 @@
    The assumption is that this area does not change.
 */
 #include "qemu/osdep.h"
-#include <sys/param.h>
 #include "qemu/cutils.h"
 #include "qemu/path.h"
 #include "qemu/thread.h"

We dropped the use of PATH_MAX in commit f3a8bdc1d5b26 (which basically completely rewrote the path handling); I think that was likely why we wanted param.h.

thanks
-- PMM

#17 lore raw

Re: [PATCH 5/7] Remove unused sys/param.h

Hi Peter,

This is a very old commit. I tested removing sys/param.h based on 512b794b109 (Update version for v11.0.0-rc1 release).
The full QEMU tree was compiled successfully, so I am not sure why we need it.

Best Regards,
Kostiantyn Kostiuk.

Quoted 31 lines · Peter Maydell
Quoted 11 lines · Kostiantyn Kostiuk
---
 util/path.c | 1 -
 1 file changed, 1 deletion(-)
util/path.c +0 -0
index 72a255890e..e1565894d2 100644

util/path.c line 9

Quoted 7 lines
util/path.c +0 -1
@@ -4,7 +4,6 @@
    The assumption is that this area does not change.
 */
 #include "qemu/osdep.h"
-#include <sys/param.h>
 #include "qemu/cutils.h"
 #include "qemu/path.h"
 #include "qemu/thread.h"

We dropped the use of PATH_MAX in commit f3a8bdc1d5b26 (which basically completely rewrote the path handling); I think that was likely why we wanted param.h.

thanks
-- PMM

#18 lore raw

Re: [PATCH 5/7] Remove unused sys/param.h

Quoted 5 lines · Kostiantyn Kostiuk

Hi Peter,

This is a very old commit. I tested removing sys/param.h based on 512b794b109 (Update version for v11.0.0-rc1 release). The full QEMU tree was compiled successfully, so I am not sure why we need it.

Note that "it compiled OK" is not a 100% reliable way to check for "do we need this include?". For historical and backwards-compatibility reasons, the glibc headers have various places where one header might pull in another. The glibc developers have in the past done cleanup work where they fix that kind of thing so you only get the function definition when you include the header that the standards say you need for that function; it's quite plausible they might do that again in future. So the best approach is to check the POSIX spec etc to see which header it says you need to include, and include that one.

-- PMM

#19 lore raw

PATCH 6/7 storage-daemon: use same link arguments as other tools

In reply to Kostiantyn Kostiuk

From: Paolo Bonzini <[email protected]>

---
 meson.build                |  8 ++++----
 storage-daemon/meson.build | 16 ++++++++--------
 2 files changed, 12 insertions(+), 12 deletions(-)
meson.build +4 -4
index 711dafa9ce..e1baa0ea80 100644
@@ -4496,15 +4496,15 @@ if xkbcommon.found()
 endif
 
 if have_tools
-  link_args = enable_modules ? ['@block.syms'] : []
+  tools_link_args = enable_modules ? ['@block.syms'] : []
   qemu_img = executable('qemu-img', [files('qemu-img.c'), hxdep],
-             link_args: link_args, link_depends: block_syms,
+             link_args: tools_link_args, link_depends: block_syms,
              dependencies: [authz, block, crypto, io, qom, qemuutil], install: true)
   qemu_io = executable('qemu-io', files('qemu-io.c'),
-             link_args: link_args, link_depends: block_syms,
+             link_args: tools_link_args, link_depends: block_syms,
              dependencies: [block, qemuutil], install: true)
   qemu_nbd = executable('qemu-nbd', files('qemu-nbd.c'),
-               link_args: link_args, link_depends: block_syms,
+               link_args: tools_link_args, link_depends: block_syms,
                dependencies: [blockdev, qemuutil, selinux],
                install: true)
 
storage-daemon/meson.build +8 -8
index 5e61a9d1bd..fc088cbea7 100644
@@ -1,14 +1,14 @@
+assert(have_tools)
+
 qsd_ss = ss.source_set()
 qsd_ss.add(files('qemu-storage-daemon.c'))
 qsd_ss.add(blockdev, chardev, qmp, qom, qemuutil)
 
 subdir('qapi')
 
-if have_tools
-  qsd_ss = qsd_ss.apply({})
-  qsd = executable('qemu-storage-daemon',
-                   qsd_ss.sources(),
-                   link_args: '@block.syms', link_depends: block_syms,
-                   dependencies: qsd_ss.dependencies(),
-                   install: true)
-endif
+qsd_ss = qsd_ss.apply({})
+qsd = executable('qemu-storage-daemon',
+                 qsd_ss.sources(),
+                 link_args: tools_link_args, link_depends: block_syms,
+                 dependencies: qsd_ss.dependencies(),
+                 install: true)
Signature · 1 line
2.52.0
#21 lore raw

PATCH 7/7 meson: Build block_syms and qemu_syms only when enable_modules

In reply to Kostiantyn Kostiuk
---
 meson.build | 25 ++++++++++++++-----------
 1 file changed, 14 insertions(+), 11 deletions(-)
meson.build +14 -11
index e1baa0ea80..c7ab9c47c4 100644
@@ -3897,6 +3897,9 @@ modinfo_generate = find_program('scripts/modinfo-generate.py')
 modinfo_files = []
 audio_modinfo_files = []
 
+block_syms = []
+qemu_syms = []
+
 block_mods = []
 system_mods = []
 emulator_modules = []
@@ -4012,18 +4015,18 @@ if enable_modules
   if emulator_modules.length() > 0
     alias_target('modules', emulator_modules)
   endif
-endif
 
-nm = find_program('nm')
-undefsym = find_program('scripts/undefsym.py')
-block_syms = custom_target('block.syms', output: 'block.syms',
-                             input: [libqemuutil, block_mods],
-                             capture: true,
-                             command: [undefsym, nm, '@INPUT@'])
-qemu_syms = custom_target('qemu.syms', output: 'qemu.syms',
-                             input: [libqemuutil, system_mods],
-                             capture: true,
-                             command: [undefsym, nm, '@INPUT@'])
+  nm = find_program('nm')
+  undefsym = find_program('scripts/undefsym.py')
+  block_syms = custom_target('block.syms', output: 'block.syms',
+                              input: [libqemuutil, block_mods],
+                              capture: true,
+                              command: [undefsym, nm, '@INPUT@'])
+  qemu_syms = custom_target('qemu.syms', output: 'qemu.syms',
+                              input: [libqemuutil, system_mods],
+                              capture: true,
+                              command: [undefsym, nm, '@INPUT@'])
+endif
 
 authz_ss = authz_ss.apply({})
 libauthz = static_library('authz', authz_ss.sources() + genh,
Signature · 1 line
2.52.0
#22 lore raw

Re: [PATCH 7/7] meson: Build block_syms and qemu_syms only when enable_modules

Am 26.03.2026 um 17:00 hat Kostiantyn Kostiuk geschrieben:

Quoted 1 line

I'm not a meson expert, but the change itself looks ok to me.

However, the commit message is definitely a bit too empty. It should say why you want to make this change.

Kevin

#23 lore raw

Re: [PATCH 7/7] meson: Build block_syms and qemu_syms only when enable_modules

Quoted 7 lines · Kevin Wolf

Am 26.03.2026 um 17:00 hat Kostiantyn Kostiuk geschrieben:

Quoted 1 line

I'm not a meson expert, but the change itself looks ok to me.

However, the commit message is definitely a bit too empty. It should say why you want to make this change.

Agreed, I *think* it's because scripts/undefsym.py would immediately exit here:

    if len(args) <= 3:
        sys.exit(0)

but it should be spelled out.

Paolo

#24 lore raw

Re: [PATCH 7/7] meson: Build block_syms and qemu_syms only when enable_modules

Am 27.03.2026 um 11:47 hat Paolo Bonzini geschrieben:

Quoted 9 lines · Kevin Wolf
Quoted 7 lines

Am 26.03.2026 um 17:00 hat Kostiantyn Kostiuk geschrieben:

Quoted 1 line

I'm not a meson expert, but the change itself looks ok to me.

However, the commit message is definitely a bit too empty. It should say why you want to make this change.

Quoted 7 lines

Agreed, I *think* it's because scripts/undefsym.py would immediately exit here:

    if len(args) <= 3:
        sys.exit(0)

but it should be spelled out.

If that's a problem, why doesn't ./configure --disable-modules fail on Linux?

Kevin

#25 lore raw

Re: [PATCH 7/7] meson: Build block_syms and qemu_syms only when enable_modules

Quoted 14 lines · Kevin Wolf

Am 27.03.2026 um 11:47 hat Paolo Bonzini geschrieben:

Quoted 7 lines · Kevin Wolf
Quoted 6 lines

Am 26.03.2026 um 17:00 hat Kostiantyn Kostiuk geschrieben:

Quoted 1 line

I'm not a meson expert, but the change itself looks ok to me.

However, the commit message is definitely a bit too empty. It should

say

Quoted 5 lines
Quoted 1 line

why you want to make this change.

Agreed, I *think* it's because scripts/undefsym.py would immediately exit here:

Quoted 8 lines
Quoted 4 lines
    if len(args) <= 3:
        sys.exit(0)

but it should be spelled out.

If that's a problem, why doesn't ./configure --disable-modules fail on Linux?

It does not fail because it exits with 0, no error. Problem in my environment because nm is missing, but at the same time, running undefsym when modules are disabled has zero sense because nothing will be generated

Quoted 4 lines

Kevin

#26 lore raw

Re: [PATCH 7/7] meson: Build block_syms and qemu_syms only when enable_modules

Am 27.03.2026 um 12:10 hat Kostiantyn Kostiuk geschrieben:

Quoted 21 lines · Kevin Wolf
Quoted 20 lines

Am 27.03.2026 um 11:47 hat Paolo Bonzini geschrieben:

Quoted 7 lines · Kevin Wolf
Quoted 6 lines

Am 26.03.2026 um 17:00 hat Kostiantyn Kostiuk geschrieben:

Quoted 1 line

I'm not a meson expert, but the change itself looks ok to me.

However, the commit message is definitely a bit too empty. It should

say

Quoted 9 lines
Quoted 1 line

why you want to make this change.

Agreed, I *think* it's because scripts/undefsym.py would immediately exit here:

    if len(args) <= 3:
        sys.exit(0)

but it should be spelled out.

Quoted 7 lines
Quoted 2 lines

If that's a problem, why doesn't ./configure --disable-modules fail on Linux?

It does not fail because it exits with 0, no error. Problem in my environment because nm is missing, but at the same time, running undefsym when modules are disabled has zero sense because nothing will be generated

Ok, makes sense. Then how about making the subject line something like "meson: Don't require nm for non-modular builds", and explaining in the commit message on which platform nm is missing and that the change is harmless because it already didn't do anything before?

Kevin

#27 lore raw
In reply to Kostiantyn Kostiuk
Quoted 8 lines · Kostiantyn Kostiuk

This is the first set of changes to allow building qemu-ga with Microsoft Windows Clang. It includes some cleanups and fixes that also make the code more portable. The main goal is to be able to build qemu-ga with the MSVC toolchain because MinGW-w64 is not available for ARM64 Windows.

Hello,

MinGW-w64 is available for arm64 Windows, although it’s more mature with Clang as a compiler instead of of MSVC.

Is it more of a packaging issue with distributions?

Thank you,
-Mohamed

#28 lore raw
Quoted 12 lines · Mohamed Mediouni
Quoted 9 lines · Kostiantyn Kostiuk

This is the first set of changes to allow building qemu-ga with Microsoft Windows Clang. It includes some cleanups and fixes that also make the code more portable. The main goal is to be able to build qemu-ga with the MSVC toolchain because MinGW-w64 is not available for ARM64 Windows.

Quoted 4 lines

Hello,

MinGW-w64 is available for arm64 Windows, although it’s more mature with Clang as a compiler instead of of MSVC.

Typo, meant instead of gcc

Upstream GCC also has aarch64-w64-mingw32 nowadays

For QEMU arm64 Windows builds, we currently use the aarch64-w64-mingw32 triplet with Clang.

Quoted 6 lines

Is it more of a packaging issue with distributions?

Thank you,
-Mohamed

#29 lore raw
In reply to Mohamed Mediouni
Quoted 6 lines · Mohamed Mediouni
Quoted 2 lines

On 26. Mar 2026, at 17:00, Kostiantyn Kostiuk <[email protected]>

Quoted 2 lines · wrote:

This is the first set of changes to allow building qemu-ga with

Microsoft Windows Clang.

Quoted 8 lines
Quoted 1 line

It includes some cleanups and fixes that also make the code more

portable.

Quoted 3 lines

The main goal is to be able to build qemu-ga with the MSVC toolchain because MinGW-w64 is not available for ARM64 Windows.

Hello,

MinGW-w64 is available for arm64 Windows, although it’s more

mature with Clang as a compiler instead of of MSVC.

Quoted 1 line

I expect to use clang from the MSVC environment, not the MSVC compiler

Quoted 8 lines

Is it more of a packaging issue with distributions?

Thank you,
-Mohamed

#30 lore raw
Quoted 18 lines · Kostiantyn Kostiuk

On Thu, Mar 26, 2026 at 6:35 PM Mohamed Mediouni <[email protected] <mailto:[email protected]>> wrote:

> On 26. Mar 2026, at 17:00, Kostiantyn Kostiuk
<[email protected] <mailto:[email protected]>> wrote:
>
> This is the first set of changes to allow building qemu-ga with
Microsoft Windows Clang.
> It includes some cleanups and fixes that also make the code more
portable.
> The main goal is to be able to build qemu-ga with the MSVC toolchain > because MinGW-w64 is not available for ARM64 Windows.
>
Hello,

Quoted 7 lines

MinGW-w64 is available for arm64 Windows, although it’s more

mature with Clang as a compiler instead of of MSVC.

I expect to use clang from the MSVC environment, not the MSVC compiler

Is the difference that this clang does not come with mingw preinstalled, and thus require using msvc headers/libraries instead?

In all cases, it's just better to use msys2 environment. What is your limitation with it?

Quoted 7 lines

Is it more of a packaging issue with distributions?

Thank you,
-Mohamed

#31 lore raw
Quoted 23 lines · Pierrick Bouvier
Quoted 7 lines · Kostiantyn Kostiuk

On Thu, Mar 26, 2026 at 6:35 PM Mohamed Mediouni <[email protected] <mailto:[email protected]>> wrote:

Quoted 8 lines

> On 26. Mar 2026, at 17:00, Kostiantyn Kostiuk
<[email protected] <mailto:[email protected]>> wrote:
>
> This is the first set of changes to allow building qemu-ga with
Microsoft Windows Clang.
> It includes some cleanups and fixes that also make the code more
portable.
> The main goal is to be able to build qemu-ga with the MSVC

toolchain

Quoted 6 lines

> because MinGW-w64 is not available for ARM64 Windows. >
Hello,

MinGW-w64 is available for arm64 Windows, although it’s more

Quoted 9 lines
Quoted 5 lines

mature with Clang as a compiler instead of of MSVC.

I expect to use clang from the MSVC environment, not the MSVC compiler

Is the difference that this clang does not come with mingw preinstalled, and thus require using msvc headers/libraries instead?

Yes, the difference is that MSVC Clang comes with MSVC headers/libraries, not a Linux/MinGW one

Quoted 4 lines

In all cases, it's just better to use msys2 environment. What is your limitation with it?

This requires additional maintenance of the MSYS2 environment. Also, MSYS2 is a rolling release distribution, while we definitely need to know the version of dependencies and control them.

Quoted 10 lines
Quoted 8 lines

Is it more of a packaging issue with distributions?

Thank you,
-Mohamed

#32 lore raw
Quoted 39 lines · Kostiantyn Kostiuk

On Thu, Mar 26, 2026 at 6:48 PM Pierrick Bouvier <[email protected] <mailto:[email protected]>> wrote:

On 3/26/26 9:43 AM, Kostiantyn Kostiuk wrote:
>
>
>
> On Thu, Mar 26, 2026 at 6:35 PM Mohamed Mediouni
> <[email protected] <mailto:[email protected]>
<mailto:[email protected] <mailto:[email protected]>>> wrote:
>
>
>      > On 26. Mar 2026, at 17:00, Kostiantyn Kostiuk >     <[email protected] <mailto:[email protected]>
<mailto:[email protected] <mailto:[email protected]>>> wrote:
>      >
>      > This is the first set of changes to allow building qemu-ga
with
>     Microsoft Windows Clang.
>      > It includes some cleanups and fixes that also make the
code more
>     portable.
>      > The main goal is to be able to build qemu-ga with the MSVC
toolchain
>      > because MinGW-w64 is not available for ARM64 Windows. >      >
>     Hello,
>
>     MinGW-w64 is available for arm64 Windows, although it’s more >
>     mature with Clang as a compiler instead of of MSVC. >
>
> I expect to use clang from the MSVC environment, not the MSVC
compiler
>

Quoted 7 lines

Is the difference that this clang does not come with mingw preinstalled,
and thus require using msvc headers/libraries instead?

Yes, the difference is that MSVC Clang comes with MSVC headers/ libraries, not a Linux/MinGW one

I'm surprised you don't run into other issues than the one this series fixes, that's great!

Quoted 9 lines

In all cases, it's just better to use msys2 environment. What is your limitation with it?

This requires additional maintenance of the MSYS2 environment. Also, MSYS2 is a rolling release distribution, while we definitely need to know the version of dependencies and control them.

The maintenance is quite low in my experience, but I understand the concern with the rolling release aspect of it. By curiosity, for dependencies in MSVC environment, do you use a package manager (vcpkg, winget, other) or build them from source?

Quoted 9 lines
     >
     >     Is it more of a packaging issue with distributions?
     >
     >     Thank you,
     >     -Mohamed
     >
     >
#33 lore raw
Quoted 63 lines · Pierrick Bouvier
Quoted 40 lines · Kostiantyn Kostiuk

On Thu, Mar 26, 2026 at 6:48 PM Pierrick Bouvier <[email protected] <mailto:[email protected]>> wrote:

On 3/26/26 9:43 AM, Kostiantyn Kostiuk wrote:
>
>
>
> On Thu, Mar 26, 2026 at 6:35 PM Mohamed Mediouni
> <[email protected] <mailto:[email protected]>
<mailto:[email protected] <mailto:[email protected]>>> wrote:
>
>
>      > On 26. Mar 2026, at 17:00, Kostiantyn Kostiuk >     <[email protected] <mailto:[email protected]>
<mailto:[email protected] <mailto:[email protected]>>> wrote:
>      >
>      > This is the first set of changes to allow building qemu-ga
with
>     Microsoft Windows Clang.
>      > It includes some cleanups and fixes that also make the
code more
>     portable.
>      > The main goal is to be able to build qemu-ga with the MSVC
toolchain
>      > because MinGW-w64 is not available for ARM64 Windows. >      >
>     Hello,
>
>     MinGW-w64 is available for arm64 Windows, although it’s more >
>     mature with Clang as a compiler instead of of MSVC. >
>
> I expect to use clang from the MSVC environment, not the MSVC
compiler
>

Quoted 8 lines

Is the difference that this clang does not come with mingw preinstalled,
and thus require using msvc headers/libraries instead?

Yes, the difference is that MSVC Clang comes with MSVC headers/ libraries, not a Linux/MinGW one

I'm surprised you don't run into other issues than the one this series fixes, that's great!

Quoted 9 lines

In all cases, it's just better to use msys2 environment. What is your limitation with it?

This requires additional maintenance of the MSYS2 environment. Also, MSYS2 is a rolling release distribution, while we definitely need to know the version of dependencies and control them.

Quoted 5 lines

The maintenance is quite low in my experience, but I understand the concern with the rolling release aspect of it.
By curiosity, for dependencies in MSVC environment, do you use a package manager (vcpkg, winget, other) or build them from source?

As a complement, you can use msys2 and install manually the versions you want for dependencies, and mirror them for reproducibility if you're concerned they disappear. I would not worry too much about following the toolchain and build tools from the rolling release, and you would just have to do it for libraries QEMU use.

See for instance index of packages here:
https://repo.msys2.org/mingw/clangarm64/

Quoted 10 lines
Quoted 9 lines
      >
      >     Is it more of a packaging issue with distributions?
      >
      >     Thank you,
      >     -Mohamed
      >
      >
#34 lore raw
Quoted 71 lines · Pierrick Bouvier
Quoted 56 lines · Pierrick Bouvier
Quoted 40 lines · Kostiantyn Kostiuk

On Thu, Mar 26, 2026 at 6:48 PM Pierrick Bouvier <[email protected] <mailto:[email protected]>> wrote:

On 3/26/26 9:43 AM, Kostiantyn Kostiuk wrote:
>
>
>
> On Thu, Mar 26, 2026 at 6:35 PM Mohamed Mediouni
> <[email protected] <mailto:[email protected]>
<mailto:[email protected] <mailto:[email protected]>>> wrote:
>
>
> > On 26. Mar 2026, at 17:00, Kostiantyn Kostiuk
> <[email protected] <mailto:[email protected]>
<mailto:[email protected] <mailto:[email protected]>>> wrote:
> >
> > This is the first set of changes to allow building qemu-ga
with
> Microsoft Windows Clang.
> > It includes some cleanups and fixes that also make the
code more
> portable.
> > The main goal is to be able to build qemu-ga with the MSVC
toolchain
> > because MinGW-w64 is not available for ARM64 Windows.
> >
> Hello,
>
> MinGW-w64 is available for arm64 Windows, although it’s more
>
> mature with Clang as a compiler instead of of MSVC.
>
>
> I expect to use clang from the MSVC environment, not the MSVC
compiler
>

Quoted 8 lines

Is the difference that this clang does not come with mingw preinstalled,
and thus require using msvc headers/libraries instead?

Yes, the difference is that MSVC Clang comes with MSVC headers/ libraries, not a Linux/MinGW one

I'm surprised you don't run into other issues than the one this series fixes, that's great!

Quoted 5 lines

In all cases, it's just better to use msys2 environment. What is your limitation with it?

Quoted 9 lines
Quoted 4 lines

This requires additional maintenance of the MSYS2 environment. Also, MSYS2 is a rolling release distribution, while we definitely need to know the version of dependencies and control them.

The maintenance is quite low in my experience, but I understand the concern with the rolling release aspect of it.
By curiosity, for dependencies in MSVC environment, do you use a package manager (vcpkg, winget, other) or build them from source?

Quoted 5 lines

As a complement, you can use msys2 and install manually the versions you want for dependencies, and mirror them for reproducibility if you're concerned they disappear. I would not worry too much about following the toolchain and build tools from the rolling release, and you would just have to do it for libraries QEMU use.

See for instance index of packages here:
https://repo.msys2.org/mingw/clangarm64/

Hi,

There’s also this: https://github.com/mstorsjo/llvm-mingw for a full build from source.

My own setup is LLVM + MinGW built from source and then a hacked up a bit version of MXE to build glib, gtk and others, but those aren’t needed for the guest agent

#35 lore raw
In reply to Mohamed Mediouni
Quoted 8 lines · Mohamed Mediouni
Quoted 8 lines · Kostiantyn Kostiuk

This is the first set of changes to allow building qemu-ga with Microsoft Windows Clang. It includes some cleanups and fixes that also make the code more portable. The main goal is to be able to build qemu-ga with the MSVC toolchain because MinGW-w64 is not available for ARM64 Windows.

Quoted 5 lines

Hello,

MinGW-w64 is available for arm64 Windows, although it’s more mature with Clang as a compiler instead of of MSVC.

As a complement to Mohamed message, this documentation will help you to build QEMU on windows platforms (including arm64):
https://www.qemu.org/docs/master/devel/build-environment.html#windows

Just make sure to do this from the console you get with:
c:/msys64/msys2_shell.cmd -defterm -here -no-start -clangarm64

Quoted 6 lines

Is it more of a packaging issue with distributions?

Thank you,
-Mohamed

#36 lore raw
In reply to Mohamed Mediouni

Il gio 26 mar 2026, 17:34 Mohamed Mediouni <[email protected]> ha scritto:

Quoted 11 lines
Quoted 2 lines

On 26. Mar 2026, at 17:00, Kostiantyn Kostiuk <[email protected]>

Quoted 2 lines · wrote:

This is the first set of changes to allow building qemu-ga with

Microsoft Windows Clang.

Quoted 1 line

It includes some cleanups and fixes that also make the code more

portable.

Quoted 3 lines

The main goal is to be able to build qemu-ga with the MSVC toolchain because MinGW-w64 is not available for ARM64 Windows.

Quoted 7 lines

Hello,

MinGW-w64 is available for arm64 Windows, although it’s more mature with Clang as a compiler instead of of MSVC.

Is it more of a packaging issue with distributions?

Yeah, I think this is about *Fedora* mingw specifically.

The packaging/version pinning aspect probably can be handled with a Meson subproject for glib (and other dependencies if any).

Paolo

Quoted 4 lines

Thank you,
-Mohamed