On Thu, 27 Jun 2024, Pali Rohár wrote:

I think that linking with vcruntime140 should work without modifying
spec files. Just calling gcc source.c -lvcruntime140 should work as the
libucrt.a is appended by gcc at the end, and symbols from first lib
should take precedence over symbols from second lib. But mingw-w64 does
not have libvcruntime140.a import library to do easy test of this my
assumption.

If linking with LLD, then yes, this is enough. If linking with ld.bfd,
unfortunately, things are more complicated.

With ld.bfd, it searches libraries only literally in the order they are
specified. If the linker is called with e.g. "myapp.o -lvcruntime140
-lmingwex -lucrt", then object files from libmingwex won't search in
libvcruntime140.a at all, it will only look in -lucrt and following
libraries. That's why the default linking options contains many repeated
-lmsvcrt -lkernel32 and such.

Now I remember it. And reason why the list of libs has to be put between
the --start-group and --end-group LD's parameters.

Yep. It would be nice to make GCC pass --start-group --end-group around these, to be able to deduplicate the list of libraries a little, because errors do appear occasionally when we move object files around between msvcr* and mingwex, and then we have so far had to just add more duplicate libraries there. (And if GCC starts doing that, I'll update Clang to do the same.)

// Martin

_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to