[PATCH 0/7] Misc changes to allow building with Windows Clang

Kostiantyn Kostiuk posted 7 patches 1 week ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20260326160033.68318-1-kkostiuk@redhat.com
Maintainers: Paolo Bonzini <pbonzini@redhat.com>, "Marc-André Lureau" <marcandre.lureau@redhat.com>, "Daniel P. Berrangé" <berrange@redhat.com>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, Kevin Wolf <kwolf@redhat.com>
There is a newer version of this series
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(-)
[PATCH 0/7] Misc changes to allow building with Windows Clang
Posted by Kostiantyn Kostiuk 1 week ago
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
Re: [PATCH 0/7] Misc changes to allow building with Windows Clang
Posted by Mohamed Mediouni 1 week ago
> On 26. Mar 2026, at 17:00, Kostiantyn Kostiuk <kkostiuk@redhat.com> 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.

Is it more of a packaging issue with distributions?

Thank you,
-Mohamed
Re: [PATCH 0/7] Misc changes to allow building with Windows Clang
Posted by Paolo Bonzini 6 days, 13 hours ago
Il gio 26 mar 2026, 17:34 Mohamed Mediouni <mohamed@unpredictable.fr> ha
scritto:

>
> > On 26. Mar 2026, at 17:00, Kostiantyn Kostiuk <kkostiuk@redhat.com>
> 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.
>
> 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


> Thank you,
> -Mohamed
>
>
Re: [PATCH 0/7] Misc changes to allow building with Windows Clang
Posted by Pierrick Bouvier 1 week ago
On 3/26/26 9:34 AM, Mohamed Mediouni wrote:
> 
>> On 26. Mar 2026, at 17:00, Kostiantyn Kostiuk <kkostiuk@redhat.com> 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.
>

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

> Is it more of a packaging issue with distributions?
> 
> Thank you,
> -Mohamed
> 
> 


Re: [PATCH 0/7] Misc changes to allow building with Windows Clang
Posted by Kostiantyn Kostiuk 1 week ago
On Thu, Mar 26, 2026 at 6:35 PM Mohamed Mediouni <mohamed@unpredictable.fr>
wrote:

>
> > On 26. Mar 2026, at 17:00, Kostiantyn Kostiuk <kkostiuk@redhat.com>
> 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


>
> Is it more of a packaging issue with distributions?
>
> Thank you,
> -Mohamed
>
>
>
Re: [PATCH 0/7] Misc changes to allow building with Windows Clang
Posted by Pierrick Bouvier 1 week ago
On 3/26/26 9:43 AM, Kostiantyn Kostiuk wrote:
> 
> 
> 
> On Thu, Mar 26, 2026 at 6:35 PM Mohamed Mediouni 
> <mohamed@unpredictable.fr <mailto:mohamed@unpredictable.fr>> wrote:
> 
> 
>      > On 26. Mar 2026, at 17:00, Kostiantyn Kostiuk
>     <kkostiuk@redhat.com <mailto:kkostiuk@redhat.com>> 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
>

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?

> 
>     Is it more of a packaging issue with distributions?
> 
>     Thank you,
>     -Mohamed
> 
> 


Re: [PATCH 0/7] Misc changes to allow building with Windows Clang
Posted by Kostiantyn Kostiuk 1 week ago
On Thu, Mar 26, 2026 at 6:48 PM Pierrick Bouvier <
pierrick.bouvier@linaro.org> wrote:

> On 3/26/26 9:43 AM, Kostiantyn Kostiuk wrote:
> >
> >
> >
> > On Thu, Mar 26, 2026 at 6:35 PM Mohamed Mediouni
> > <mohamed@unpredictable.fr <mailto:mohamed@unpredictable.fr>> wrote:
> >
> >
> >      > On 26. Mar 2026, at 17:00, Kostiantyn Kostiuk
> >     <kkostiuk@redhat.com <mailto:kkostiuk@redhat.com>> 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
> >
>
> 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


>
> 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.


>
> >
> >     Is it more of a packaging issue with distributions?
> >
> >     Thank you,
> >     -Mohamed
> >
> >
>
>
Re: [PATCH 0/7] Misc changes to allow building with Windows Clang
Posted by Pierrick Bouvier 1 week ago
On 3/26/26 10:11 AM, Kostiantyn Kostiuk wrote:
> 
> 
> On Thu, Mar 26, 2026 at 6:48 PM Pierrick Bouvier 
> <pierrick.bouvier@linaro.org <mailto:pierrick.bouvier@linaro.org>> wrote:
> 
>     On 3/26/26 9:43 AM, Kostiantyn Kostiuk wrote:
>      >
>      >
>      >
>      > On Thu, Mar 26, 2026 at 6:35 PM Mohamed Mediouni
>      > <mohamed@unpredictable.fr <mailto:mohamed@unpredictable.fr>
>     <mailto:mohamed@unpredictable.fr <mailto:mohamed@unpredictable.fr>>>
>     wrote:
>      >
>      >
>      >      > On 26. Mar 2026, at 17:00, Kostiantyn Kostiuk
>      >     <kkostiuk@redhat.com <mailto:kkostiuk@redhat.com>
>     <mailto:kkostiuk@redhat.com <mailto:kkostiuk@redhat.com>>> 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
>      >
> 
>     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!

> 
>     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?

> 
>      >
>      >     Is it more of a packaging issue with distributions?
>      >
>      >     Thank you,
>      >     -Mohamed
>      >
>      >
> 


Re: [PATCH 0/7] Misc changes to allow building with Windows Clang
Posted by Pierrick Bouvier 1 week ago
On 3/26/26 10:38 AM, Pierrick Bouvier wrote:
> On 3/26/26 10:11 AM, Kostiantyn Kostiuk wrote:
>>
>>
>> On Thu, Mar 26, 2026 at 6:48 PM Pierrick Bouvier
>> <pierrick.bouvier@linaro.org <mailto:pierrick.bouvier@linaro.org>> wrote:
>>
>>      On 3/26/26 9:43 AM, Kostiantyn Kostiuk wrote:
>>       >
>>       >
>>       >
>>       > On Thu, Mar 26, 2026 at 6:35 PM Mohamed Mediouni
>>       > <mohamed@unpredictable.fr <mailto:mohamed@unpredictable.fr>
>>      <mailto:mohamed@unpredictable.fr <mailto:mohamed@unpredictable.fr>>>
>>      wrote:
>>       >
>>       >
>>       >      > On 26. Mar 2026, at 17:00, Kostiantyn Kostiuk
>>       >     <kkostiuk@redhat.com <mailto:kkostiuk@redhat.com>
>>      <mailto:kkostiuk@redhat.com <mailto:kkostiuk@redhat.com>>> 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
>>       >
>>
>>      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!
> 
>>
>>      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?
>

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/

>>
>>       >
>>       >     Is it more of a packaging issue with distributions?
>>       >
>>       >     Thank you,
>>       >     -Mohamed
>>       >
>>       >
>>
> 


Re: [PATCH 0/7] Misc changes to allow building with Windows Clang
Posted by Mohamed Mediouni 1 week ago

> On 26. Mar 2026, at 18:44, Pierrick Bouvier <pierrick.bouvier@linaro.org> wrote:
> 
> On 3/26/26 10:38 AM, Pierrick Bouvier wrote:
>> On 3/26/26 10:11 AM, Kostiantyn Kostiuk wrote:
>>> 
>>> 
>>> On Thu, Mar 26, 2026 at 6:48 PM Pierrick Bouvier
>>> <pierrick.bouvier@linaro.org <mailto:pierrick.bouvier@linaro.org>> wrote:
>>> 
>>>     On 3/26/26 9:43 AM, Kostiantyn Kostiuk wrote:
>>>      >
>>>      >
>>>      >
>>>      > On Thu, Mar 26, 2026 at 6:35 PM Mohamed Mediouni
>>>      > <mohamed@unpredictable.fr <mailto:mohamed@unpredictable.fr>
>>>     <mailto:mohamed@unpredictable.fr <mailto:mohamed@unpredictable.fr>>>
>>>     wrote:
>>>      >
>>>      >
>>>      >      > On 26. Mar 2026, at 17:00, Kostiantyn Kostiuk
>>>      >     <kkostiuk@redhat.com <mailto:kkostiuk@redhat.com>
>>>     <mailto:kkostiuk@redhat.com <mailto:kkostiuk@redhat.com>>> 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
>>>      >
>>> 
>>>     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!
>>> 
>>>     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?
>> 
> 
> 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
Re: [PATCH 0/7] Misc changes to allow building with Windows Clang
Posted by Mohamed Mediouni 1 week ago

> On 26. Mar 2026, at 17:34, Mohamed Mediouni <mohamed@unpredictable.fr> wrote:
> 
> 
>> On 26. Mar 2026, at 17:00, Kostiantyn Kostiuk <kkostiuk@redhat.com> 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.
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.

> 
> Is it more of a packaging issue with distributions?
> 
> Thank you,
> -Mohamed
>