在 2026-7-1 02:57, Pali Rohár 写道:
On Tuesday 30 June 2026 14:57:04 LIU Hao wrote:
Hi Pali,

There's a report about this linker error today:
https://github.com/mingw-w64/mingw-w64/issues/177#issuecomment-4840677432

The current setup where libmsvcrt references symbols from libmingw32 doesn't
look quite correct; in GCC default specs, CRT libraries are linked in this
order `-lmingw32 -lmingwex -lmsvcrt`. Therefore I suggest
b9ac6b67372d065a5bcd4f515b7f84118a65446b be reverted before the issue is
solved.

Hello, thank you for noticing me about this problem.

I understand this problem, variables/functions/symbols defined in
mingw-w64-crt/crt/ directory cannot be referenced in files from other
directories because /crt/ is in libmingw32.a library and that is before
other libraries in gcc specs file.

The bad thing about this issue is that it happens only sometimes. I did
not figured out when gcc/ld starts complaining about
"undefined reference" and when not. I observed that higher probability
is when the LTO is enabled.

For example on CI in tests are used those i386__beginthreadex.c
implementations and 32-bit x86 gcc on CI is happy, it always passed.
Also it passed all my local testing. So such issues can happen and we
will get info about them only once somebody hit it.


In the attachment I'm sending a proposal for fixing this issue.
Basically "copy" the implementation into both crtexe.c and
i386__beginthreadex.c files. I do not see any easy way how to "share"
that one symbol between libmingw32.a and libmsvcrt-os.a (or libmsvcrt.a).
And because now the __mingw_SEH_error_handler implementation is very
small (just wrapper around the _XcptFilter), so do not think this
copy would be an issue.

I have tested it only locally, to provide fix as fast as possible, so
maybe there could be some CI issues.

Could you please forward these patches to reporter, so could try to
verify if it works?

Note that patches are on top of my "__mingw_init_ehandler" changes:
https://sourceforge.net/p/mingw-w64/mailman/message/59348860/
but rebasing without them should be relatively easy, there should be
just context conflict in crtexe.c around "asm volatile" line.

Would you please hard-wrap those lines before submitting a patch?




--
Best regards,
LIU Hao

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature

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

Reply via email to