Pali told me that clang recognizes some special -l values (like you mentioned,
-l{crtdll|msvcr*|ucrt*}). It is good to know that clang also handles
-lwindowsapp. However, it seems that clang's -lwindowsapp handling works only
with lld. I tried linking a simple executable with `clang -lwindowsapp`
(installed from Msys2/UCRT64, which uses GNU ld unless -fuse-ld=lld is used)
and I got undefined references to Windows API functions.
AFAIK, lld unlike GNU ld can resolve references to libraries that have been
passed earlier on the command line, I think it has to do with -lwindowsapp not
following mingw-w64's -l flags when clang invokes ld.
If I understood correctly, Pali wants to propose a new option to gcc,
-msysdll=, which would allow to replace library that follows mingw-w64's -l
flags. This would not only allow using -lwindowsapp in that place, but also
import libraries like -lonecore.
- Kirill Makurin
________________________________
From: Martin Storsj? <[email protected]>
Sent: Monday, November 24, 2025 3:24 AM
To: [email protected]
<[email protected]>
Subject: Re: [Mingw-w64-public] A few questions about UWP apps and
winstorecompat
On Sun, 23 Nov 2025, Kirill Makurin wrote:
> If you look at gcc spec, you will see -lkernel32 following mingw-w64's
> -l flags. The issue is that this will cause mingw-w64's static code
> directly reference symbols from kernel32.dll, and not api sets linked
> with -lwindowsapp. Perfectly, we would want to replace this -lkernel32
> with -lwindowsappcompat -lwindowsapp. However, there seems to be no
> simple way to achieve this.
>
> One way this can be achieved is by getting the specs with `gcc
> -dumpspecs`, modifying them (with sed, for example) and passing modified
> specs to gcc with -specs=. I see no simple way how this can be done with
> build systems like meson or cmake. This also would not work for clang.
Yes, this is exactly how VLC did it, when building with GCC - they run
-dumpspecs, then edit the spec file and pass -specs= when compiling:
https://code.videolan.org/videolan/vlc/-/blob/3.0.21/extras/package/win32/build.sh?ref_type=tags#L227-239
In Clang, we check if the user specified -lwindowsapp - in that case, it
omits the built-in -lkernel32 and similar:
https://github.com/llvm/llvm-project/blob/llvmorg-21.1.6/clang/lib/Driver/ToolChains/MinGW.cpp#L284-L290
and
https://github.com/llvm/llvm-project/blob/llvmorg-21.1.6/clang/lib/Driver/ToolChains/MinGW.cpp#L350-L362
(Similarly, in Clang, if you pass -lmsvcr*, -lucrt* or -lcrtdll, it omits
the default -lmsvcrt.)
// Martin
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public