On Tue, 29 Mar 2022, Jeremy Drake via Mingw-w64-public wrote:
A discussion came up today on MSYS2 Discord about trying to build qemu for
Windows ARM64
(https://discord.com/channels/792780131906617355/794889490941476915/958319683902259250).
Apparently QEMU is trying to use setjmp/longjmp within
TCG-generated code, and that is failing on ARM64 with 0xc00000ff:
STATUS_BAD_FUNCTION_TABLE
QEMU has a work-around for this situation on x86_64:
#if defined(_WIN64)
/* On w64, setjmp is implemented by _setjmp which needs a second parameter.
(Technically, this isn't specific to win64, but anything-but-i386, at
least out of the currently relevant architectures.)
* If this parameter is NULL, longjump does no stack unwinding.
* That is what we need for QEMU. Passing the value of register rsp (default)
* lets longjmp try a stack unwinding which will crash with generated code. */
# undef setjmp
# define setjmp(env) _setjmp(env, NULL)
#endif
This trick doesn't work on ARM64.
Indeed, the system provided setjmp/longjmp functions strictly require
proper SEH unwinding there, contrary to x86.
After some back-and-forth, we found that __mingw_setjmp/__mingw_longjmp
do work in this case, but it is not obvious how to satisfy the
conditions in the headers to switch to that implementation without
switching the exception model, which seems like it could have some
serious side-effects.
I was wondering if it might make sense to add a check for a
user-controllable define to override the implementation (something like
USE_NO_MINGW_SETJMP_TWO_ARGS seems to be intended to do) for situations
where code is generated at runtime without SEH tables.
Yup, such a mechanism makes perfect sense to me. Either invent a new one,
or see if the existing ifdefs in the header can be fixed to work like it
seems to be intended.
// Martin
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public