On Sun, 6 Feb 2022, Pali Rohár wrote:
Import library libcrtdll.a (for crtdll.dll runtime library) compiled during
mingw-w64 build process is currently broken and cannot be used for linking
executable applications.
Trying to do it results in following linker errors:
/usr/bin/i686-w64-mingw32-ld: .../i686-w64-mingw32/lib/crt2.o: in function
`pre_c_init':
.../mingw-w64-crt/crt/crtexe.c:142: undefined reference to `__set_app_type'
/usr/bin/i686-w64-mingw32-ld: .../mingw-w64-crt/crt/crtexe.c:146: undefined
reference to `__p__fmode'
/usr/bin/i686-w64-mingw32-ld: .../mingw-w64-crt/crt/crtexe.c:144: undefined
reference to `__set_app_type'
/usr/bin/i686-w64-mingw32-ld: .../i686-w64-mingw32/lib/crt2.o: in function
`pre_cpp_init':
.../mingw-w64-crt/crt/crtexe.c:173: undefined reference to `__getmainargs'
/usr/bin/i686-w64-mingw32-ld: .../i686-w64-mingw32/lib/crt2.o: in function
`_tmainCRTStartup':
.../mingw-w64-crt/crt/crtexe.c:290: undefined reference to
`_set_invalid_parameter_handler'
/usr/bin/i686-w64-mingw32-ld: .../mingw-w64-crt/crt/crtexe.c:299: undefined
reference to `__p__acmdln'
/usr/bin/i686-w64-mingw32-ld: .../mingw-w64-crt/crt/crtexe.c:337: undefined
reference to `_imp____initenv'
/usr/bin/i686-w64-mingw32-ld:
.../i686-w64-mingw32/lib/libmingw32.a(lib32_libmingw32_a-charmax.o): in
function `my_lconv_init':
.../mingw-w64-crt/crt/charmax.c:19: undefined reference to `_imp____lconv_init'
/usr/bin/i686-w64-mingw32-ld:
.../i686-w64-mingw32/lib/libmingw32.a(lib32_libmingw32_a-merr.o): in function
`_mingw_setusermatherr':
.../mingw-w64-crt/crt/merr.c:33: undefined reference to `__setusermatherr'
/usr/bin/i686-w64-mingw32-ld:
.../i686-w64-mingw32/lib/libmingwex.a(lib32_libmingwex_a-getopt.o): in function
`vwarnx':
.../mingw-w64-crt/misc/getopt.c:119: undefined reference to `__p___argv'
Reason is that this crtdll.dll library has some symbols with _dll suffix as
opposite of the msvcrt.dll library which has it without any suffix.
mingw-w64 startup code expects that these symbols are without any suffix
too. And some symbols are not present in crtdll.dll at all.
Most required functions are already provided by mingw-w64 in misc/
subdirectory and they are already linked into msvcrt import library.
But they are compiled into into crtdll import library yet.
This patch fixes all these issues. Add required misc/ files into import
library and adds a new helper file crtdll_compat.c with remaining missing
functions for mingw-w64 startup and links it into libcrtdll.a import
library. Missing symbols which exists with _dll suffix are defined in
crtdll.def file as aliases.
This allows to produce working 32-bit executable binaries by
i686-w64-mingw32-gcc compiler and mingw-w64 toolchain which will use
crtdll.dll runtime library.
---
Changes in v2:
* Define aliases in crtdll.def file instead in source code
---
mingw-w64-crt/Makefile.am | 18 +++++++++++++++--
mingw-w64-crt/crt/crtdll_compat.c | 32 +++++++++++++++++++++++++++++++
mingw-w64-crt/lib32/crtdll.def | 20 +++++++++++++++++++
mingw-w64-crt/lib32/crtdll.mri | 1 +
4 files changed, 69 insertions(+), 2 deletions(-)
create mode 100644 mingw-w64-crt/crt/crtdll_compat.c
This looks ok to me too - pushed.
// Martin
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public