On Wed, 26 Jun 2024, Pali Rohár wrote:
I compiled and linked very simple memcmp() example with mingw-w64
runtime and with latest ms runtime (both 32-bit). Tested example is:
__declspec(dllimport) int memcmp(const void *a, const void *b, unsigned s);
int main(int argc, char *argv[]) { return memcmp(argv[0], "abc", 3); }
ms tools created executable which imports memcmp symbol from
VCRUNTIME140.dll library. But mingw-w64 imports memcmp symbol from
api-ms-win-crt-private-l1-1-0.dll library.
I looked at VCRUNTIME140.dll and api-ms-win-crt-private-l1-1-0.dll and
seems that both libraries provide similar set of symbols.
It is correct that mingw-w54 links with api-ms-win-crt-private-l1-1-0.dll?
Should not it do same thing as ms vc, so link with VCRUNTIME140.dll?
Meaning that api-ms-win-crt-private-l1-1-0.def would be replaced by
vcruntime140.def when creating libucrt.a archive?
No, this aspect is working quite intentionally this way.
The big difference is that api-ms-win-crt-private-l1-1-0.dll is a system
component, this is available out of the box on modern Windows (as long as
UCRT is installed/available). Vcruntime140.dll is not a system component,
but you're supposed to ship it along with your executable. And we don't
have it - but you'd need to get this binary from MSVC somehow.
Yes, this is a binary where redistribution is allowed, but we prefer to
not need to ship extra opaque binaries with our executables (where those
binaries may have extra specifications on how/where you're allowed to
redistribute them).
Note that there is also vcruntime140_app.dll. Where is this used?
Normally, it's not used. But if you redistribute e.g. a WinStore/UWP app,
which is mostly built/packaged with MSVC, and thus already is shipped with
vcruntime140_app.dll, then you may want to link against this library. (To
do this, one probably has to mess with custom spec files for gcc.)
Also note that we provide libucrtapp.a, too. This library is regular UCRT,
mostly like libucrt.a, but without linking against the private DLL. In
this case, we instead provide trivial reimplementations (or in the case of
__C_specific_handler, a stub) of the functions that we normally use from
the private DLL. (It doesn't contain all functions, but the ones that
commonly are used.)
If you wanted to add a def file for vcruntime140.dll, I guess that's fine,
but it wouldn't be the common thing to use. If a user would link with
-lvcruntime140 -lucrt, then it should prefer picking functions from
vcruntime140 and probably not link anything from the private DLL either.
// Martin
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public