mingw-w64 defines the setjmp() macro in setjmp.h via the _setjmp3() function call. Function symbol _setjmp3 is not available in crtdll.dll and msvcrt10.dll libraries. So for C setjmp() usage it is needed to have _setjmp3 symbol in import libcrtdll.a and libmsvcrt10.a import libraries.
On i386 are available two setjmp ABI functions: _setjmp - the old crtdll.dll ABI _setjmp3 - the new msvcrt20+ ABI The _setjmp() function is the old one, compatible with crtdll.dll which takes smaller jmpbuf (without Cookie, UnwindFunc and UnwindData). This function is available in all CRT libraries, since crtdll.dll up to the latest version of msvcrt.dll and UCRT. The _setjmp3() function is the new one introduced in msvcrt20.dll and is used by default since msvc compiler which introduced msvcrt20.dll library. It is still used by recent visual studio for UCRT applications too. It is used also by default in mingw-w64 (used in setjmp.h). crtdll.dll and msvcrt10.dll libraries are missing the new msvcrt20+ _setjmp3() function. They have only old _setjmp() function. As mingw-w64 setjmp.h for setjmp() macro does not use variadic arguments of _setjmp3() function, this mingw-w64 usage of _setjmp3() is mostly compatible with the crtdll.dll/msvcrt10.dll ABI of _setjmp() function. So define _setjmp3 symbol for crtdll.dll and msvcrt10.dll import libraries as an alias to the _setjmp symbol. This would work fine until mingw-w64 or gcc starts using variadic arguments of _setjmp3(). This change fixes problem that usage of C setjmp() was causing linking errors about missing _setjmp3 symbol for crtdll.dll and msvcrt10.dll builds. --- mingw-w64-crt/def-include/crt-aliases.def.in | 14 ++++++++++++++ mingw-w64-crt/lib32/crtdll.def.in | 1 + mingw-w64-crt/lib32/msvcrt10.def.in | 1 + 3 files changed, 16 insertions(+) diff --git a/mingw-w64-crt/def-include/crt-aliases.def.in b/mingw-w64-crt/def-include/crt-aliases.def.in index 99512a4fdbfe..65675ecbc1c9 100644 --- a/mingw-w64-crt/def-include/crt-aliases.def.in +++ b/mingw-w64-crt/def-include/crt-aliases.def.in @@ -339,6 +339,20 @@ strncasecmp == _strnicmp ; Some symbols in some version of CRT library were added and some other symbols were removed or renamed ; This list provides some level of backward and forward compatibility +#ifdef WITH_SETJMP3_ALIAS +; crtdll.dll and msvcrt10.dll have only old _setjmp function which does not take +; additional variadic arguments and uses smaller jmpbuf structure. +; mingw-w64 calls _setjmp3 only with zero additional arguments and because number +; of additional arguments is passed on the stack which is cleanup by the caller, +; it means that the mingw-w64 usage of _setjmp3 is ABI compatible with the old +; _setjmp function which is available also in crtdll.dll and msvcrt10.dll libs. +; It heavily depends on the mingw-w64-headers/crt/setjmp.h implementation. +; So this definition allows crtdll.dll and msvcrt10.dll applications to call +; setjmp() macro from setjmp.h, which expands to _setjmp3() function call and +; which is aliased to _setjmp symbol for crtdll.dll and msvcrt10.dll libraries. +F_I386(_setjmp3 == _setjmp) +#endif + #ifdef UCRTBASE F_NON_ARM64(_setjmp == __intrinsic_setjmp) F64(_setjmpex == __intrinsic_setjmpex) diff --git a/mingw-w64-crt/lib32/crtdll.def.in b/mingw-w64-crt/lib32/crtdll.def.in index 8a37beb6f584..8ffaa3adf385 100644 --- a/mingw-w64-crt/lib32/crtdll.def.in +++ b/mingw-w64-crt/lib32/crtdll.def.in @@ -631,4 +631,5 @@ _ultow #define NO_STRCMPI_ALIAS #define WITH_NEXTAFTER_ALIAS #define WITH_GET_PUT_WCHAR_ALIASES +#define WITH_SETJMP3_ALIAS #include "crt-aliases.def.in" diff --git a/mingw-w64-crt/lib32/msvcrt10.def.in b/mingw-w64-crt/lib32/msvcrt10.def.in index d2dd22c7e52f..9d4db9f811e7 100644 --- a/mingw-w64-crt/lib32/msvcrt10.def.in +++ b/mingw-w64-crt/lib32/msvcrt10.def.in @@ -1301,4 +1301,5 @@ wscanf #define NO_STRCMPI_ALIAS #define WITH_NEXTAFTER_ALIAS #define WITH_GET_PUT_WCHAR_ALIASES +#define WITH_SETJMP3_ALIAS #include "crt-aliases.def.in" -- 2.20.1 _______________________________________________ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public