Hi all,
Recent mingw-w64 changed quite a lot its crt to be able to support different runtime DLLs (most notably both msvcrt.dll and ucrtbase.dll at the same time). This requires some compat code to be used depending on which DLL is used. Compat code lives in the same libraries as are used as importlibs (like libmsvcrt.a). Wine doesn't use this library and generates its own import library instead. This library misses compat code required by mingw startup code. Commit 32bac734632cf082da40a82de7f3135262688351 worked around the build problem by exporting more functions from our msvcrt. The problem is that those functions are not exported on Windows, so Wine DLLs compiled this way will fail to load on Windows.
The attached patch adds required compat code from mingw-w64 (it's mostly just a copy of its code). It's just a proof of concept - if we want that, we'd need to make sure it builds with old mingw-w64 first. The solution has its problems: for example we may need to extend that in the future if more such changes will happen to be needed on mingw-w64 side. Also __acrt_iob_func situation is even more tricky than onexit table functions. It's pulled by code that is so late in linker order, that linker will not pull it from our lib. It happens to work because it's in the same object file as other onexit table functions which are pulled earlier in the process (so using GC sections could break it).
It's not really nice, but it looks like a maintainable solution. Comments or better ideas are welcomed.
Jacek
--- libs/port/Makefile.in | 1 + libs/port/ucrt.c | 90 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 91 insertions(+) create mode 100644 libs/port/ucrt.c