diff --git a/build b/build index 93685fe390..a12b3c859b 100755 --- a/build +++ b/build @@ -568,6 +568,12 @@ if [[ -n $PROVIDED_TOOLCHAIN ]] ; then i686_HOST_MINGW_PATH=$TOOLCHAINS_DIR/mingw32 x86_64_HOST_MINGW_PATH=$TOOLCHAINS_DIR/mingw64 else + # The host toolchains for sjlj exception model are no longer officially provided. + # Rather than trying to download non-existent files, tell the user to install one manually. + [[ $EXCEPTIONS_MODEL == sjlj ]] && { + die "host toolchains for sjlj exception model must be installed manually (--provided-toolchain=...). terminate." + } + echo "Using downloaded toolchain" fi diff --git a/library/config-win.sh b/library/config-win.sh index 9afae30bfe..979038c625 100644 --- a/library/config-win.sh +++ b/library/config-win.sh @@ -35,9 +35,9 @@ # ************************************************************************** -readonly HOST_MINGW_VERSION=12.2.0 -readonly HOST_MINGW_RT_VERSION=10 -readonly HOST_MINGW_BUILD_REV=2 +readonly HOST_MINGW_VERSION=14.2.0 +readonly HOST_MINGW_RT_VERSION=12 +readonly HOST_MINGW_BUILD_REV=0 readonly i686_HOST_MINGW_PATH_URL="https://github.com/niXman/mingw-builds-binaries/releases/download/$HOST_MINGW_VERSION-rt_v$HOST_MINGW_RT_VERSION-rev$HOST_MINGW_BUILD_REV/i686-$HOST_MINGW_VERSION-release-posix-{exceptions}-{msvcrt}-rt_v$HOST_MINGW_RT_VERSION-rev$HOST_MINGW_BUILD_REV.7z" readonly x86_64_HOST_MINGW_PATH_URL="https://github.com/niXman/mingw-builds-binaries/releases/download/$HOST_MINGW_VERSION-rt_v$HOST_MINGW_RT_VERSION-rev$HOST_MINGW_BUILD_REV/x86_64-$HOST_MINGW_VERSION-release-posix-{exceptions}-{msvcrt}-rt_v$HOST_MINGW_RT_VERSION-rev$HOST_MINGW_BUILD_REV.7z" diff --git a/patches/mingw-w64/9001-crt-Mark-atexit-as-DATA-because-it-s-always-overridd.patch b/patches/mingw-w64/9001-v11-crt-Mark-atexit-as-DATA-because-it-s-always-overridd.patch similarity index 100% rename from patches/mingw-w64/9001-crt-Mark-atexit-as-DATA-because-it-s-always-overridd.patch rename to patches/mingw-w64/9001-v11-crt-Mark-atexit-as-DATA-because-it-s-always-overridd.patch diff --git a/patches/mingw-w64/9001-v13-crt-Mark-atexit-as-DATA-because-it-s-always-overridd.patch b/patches/mingw-w64/9001-v13-crt-Mark-atexit-as-DATA-because-it-s-always-overridd.patch new file mode 100644 index 0000000000..5826f9b632 --- /dev/null +++ b/patches/mingw-w64/9001-v13-crt-Mark-atexit-as-DATA-because-it-s-always-overridd.patch @@ -0,0 +1,247 @@ +diff --git a/mingw-w64-crt/lib-common/msvcr120_app.def.in b/mingw-w64-crt/lib-common/msvcr120_app.def.in +index 67f8f8a57..1788601f4 100644 +--- a/mingw-w64-crt/lib-common/msvcr120_app.def.in ++++ b/mingw-w64-crt/lib-common/msvcr120_app.def.in +@@ -1870,7 +1870,7 @@ F_NON_I386(atanf) + atanh + atanhf + F_ARM32(atanhl) ; Can't use long double functions from the CRT on x86 +-atexit ++atexit DATA + atof + atoi + atol +diff --git a/mingw-w64-crt/lib32/msvcr120.def.in b/mingw-w64-crt/lib32/msvcr120.def.in +index f45289898..24c3126ae 100644 +--- a/mingw-w64-crt/lib32/msvcr120.def.in ++++ b/mingw-w64-crt/lib32/msvcr120.def.in +@@ -1846,7 +1846,7 @@ atan2 + atanh + atanhf + ; atanhl ; Can't use long double functions from the CRT on x86 +-atexit ++atexit DATA + atof + atoi + atol +diff --git a/mingw-w64-crt/lib32/msvcr120d.def.in b/mingw-w64-crt/lib32/msvcr120d.def.in +index f30ae72e1..8b46a9725 100644 +--- a/mingw-w64-crt/lib32/msvcr120d.def.in ++++ b/mingw-w64-crt/lib32/msvcr120d.def.in +@@ -1913,7 +1913,7 @@ atan2 + atanh + atanhf + ; atanhl ; Can't use long double functions from the CRT on x86 +-atexit ++atexit DATA + atof + atoi + atol +diff --git a/mingw-w64-crt/lib32/msvcr40d.def.in b/mingw-w64-crt/lib32/msvcr40d.def.in +index 2d0af6c7d..278aa7740 100644 +--- a/mingw-w64-crt/lib32/msvcr40d.def.in ++++ b/mingw-w64-crt/lib32/msvcr40d.def.in +@@ -1461,7 +1461,7 @@ asctime + asin + atan + atan2 +-atexit ++atexit DATA + atof + atoi + atol +diff --git a/mingw-w64-crt/lib32/msvcr70.def.in b/mingw-w64-crt/lib32/msvcr70.def.in +index c167523e7..6a302611f 100644 +--- a/mingw-w64-crt/lib32/msvcr70.def.in ++++ b/mingw-w64-crt/lib32/msvcr70.def.in +@@ -711,7 +711,7 @@ asctime + asin + atan + atan2 +-atexit ++atexit DATA + atof + atoi + atol +diff --git a/mingw-w64-crt/lib32/msvcr70d.def.in b/mingw-w64-crt/lib32/msvcr70d.def.in +index bc5a32b6a..eb10ee400 100644 +--- a/mingw-w64-crt/lib32/msvcr70d.def.in ++++ b/mingw-w64-crt/lib32/msvcr70d.def.in +@@ -755,7 +755,7 @@ asctime + asin + atan + atan2 +-atexit ++atexit DATA + atof + atoi + atol +diff --git a/mingw-w64-crt/lib32/msvcr71.def.in b/mingw-w64-crt/lib32/msvcr71.def.in +index c1b7ce2d1..63e63bf06 100644 +--- a/mingw-w64-crt/lib32/msvcr71.def.in ++++ b/mingw-w64-crt/lib32/msvcr71.def.in +@@ -705,7 +705,7 @@ asctime + asin + atan + atan2 +-atexit ++atexit DATA + atof + atoi + atol +diff --git a/mingw-w64-crt/lib32/msvcr71d.def.in b/mingw-w64-crt/lib32/msvcr71d.def.in +index 806602207..c6b60f98b 100644 +--- a/mingw-w64-crt/lib32/msvcr71d.def.in ++++ b/mingw-w64-crt/lib32/msvcr71d.def.in +@@ -749,7 +749,7 @@ asctime + asin + atan + atan2 +-atexit ++atexit DATA + atof + atoi + atol +diff --git a/mingw-w64-crt/lib32/msvcrt10.def.in b/mingw-w64-crt/lib32/msvcrt10.def.in +index 66cb07c15..f5e58a273 100644 +--- a/mingw-w64-crt/lib32/msvcrt10.def.in ++++ b/mingw-w64-crt/lib32/msvcrt10.def.in +@@ -1112,7 +1112,7 @@ asctime + asin + atan + atan2 +-atexit ++atexit DATA + atof + atoi + atol +diff --git a/mingw-w64-crt/lib32/msvcrt20.def.in b/mingw-w64-crt/lib32/msvcrt20.def.in +index 7330274d6..df69e69ca 100644 +--- a/mingw-w64-crt/lib32/msvcrt20.def.in ++++ b/mingw-w64-crt/lib32/msvcrt20.def.in +@@ -1329,7 +1329,7 @@ asctime + asin + atan + atan2 +-atexit ++atexit DATA + atof + atoi + atol +diff --git a/mingw-w64-crt/lib32/msvcrt40.def.in b/mingw-w64-crt/lib32/msvcrt40.def.in +index 26a7453cc..98dc2015e 100644 +--- a/mingw-w64-crt/lib32/msvcrt40.def.in ++++ b/mingw-w64-crt/lib32/msvcrt40.def.in +@@ -1429,7 +1429,7 @@ asctime + asin + atan + atan2 +-atexit ++atexit DATA + atof + atoi + atol +diff --git a/mingw-w64-crt/lib32/msvcrtd.def.in b/mingw-w64-crt/lib32/msvcrtd.def.in +index ee6670030..a0823f422 100644 +--- a/mingw-w64-crt/lib32/msvcrtd.def.in ++++ b/mingw-w64-crt/lib32/msvcrtd.def.in +@@ -655,7 +655,7 @@ asctime + asin + atan + atan2 +-atexit ++atexit DATA + atof + atoi + atol +diff --git a/mingw-w64-crt/lib64/msvcr120.def.in b/mingw-w64-crt/lib64/msvcr120.def.in +index 65637518b..ab4912db4 100644 +--- a/mingw-w64-crt/lib64/msvcr120.def.in ++++ b/mingw-w64-crt/lib64/msvcr120.def.in +@@ -1788,7 +1788,7 @@ atanf + atanh + atanhf + ; atanhl ; Can't use long double functions from the CRT on x86 +-atexit ++atexit DATA + atof + atoi + atol +diff --git a/mingw-w64-crt/lib64/msvcr120d.def.in b/mingw-w64-crt/lib64/msvcr120d.def.in +index 5d975164d..f61eb41f6 100644 +--- a/mingw-w64-crt/lib64/msvcr120d.def.in ++++ b/mingw-w64-crt/lib64/msvcr120d.def.in +@@ -1853,7 +1853,7 @@ atanf + atanh + atanhf + ; atanhl ; Can't use long double functions from the CRT on x86 +-atexit ++atexit DATA + atof + atoi + atol +diff --git a/mingw-w64-crt/libarm32/kernelbase.def b/mingw-w64-crt/libarm32/kernelbase.def +index 954ea2dc1..d6a487db1 100644 +--- a/mingw-w64-crt/libarm32/kernelbase.def ++++ b/mingw-w64-crt/libarm32/kernelbase.def +@@ -1889,7 +1889,7 @@ _invalid_parameter + _onexit + _purecall + _time64 +-atexit ++atexit DATA + exit + hgets + hwprintf +diff --git a/mingw-w64-crt/libarm32/msvcr110.def.in b/mingw-w64-crt/libarm32/msvcr110.def.in +index 8f30767a8..84f46eca3 100644 +--- a/mingw-w64-crt/libarm32/msvcr110.def.in ++++ b/mingw-w64-crt/libarm32/msvcr110.def.in +@@ -1716,7 +1716,7 @@ atan + atan2 + atan2f + atanf +-atexit ++atexit DATA + atof + atoi + atol +diff --git a/mingw-w64-crt/libarm32/msvcr110d.def.in b/mingw-w64-crt/libarm32/msvcr110d.def.in +index 5a809682d..a7aebdad6 100644 +--- a/mingw-w64-crt/libarm32/msvcr110d.def.in ++++ b/mingw-w64-crt/libarm32/msvcr110d.def.in +@@ -1781,7 +1781,7 @@ atan + atan2 + atan2f + atanf +-atexit ++atexit DATA + atof + atoi + atol +diff --git a/mingw-w64-crt/libarm32/msvcr120.def.in b/mingw-w64-crt/libarm32/msvcr120.def.in +index 4483a2093..f94ac44f3 100644 +--- a/mingw-w64-crt/libarm32/msvcr120.def.in ++++ b/mingw-w64-crt/libarm32/msvcr120.def.in +@@ -1753,7 +1753,7 @@ atanf + atanh + atanhf + atanhl +-atexit ++atexit DATA + atof + atoi + atol +diff --git a/mingw-w64-crt/libarm32/msvcr120d.def.in b/mingw-w64-crt/libarm32/msvcr120d.def.in +index 90374f7e9..9d4cec588 100644 +--- a/mingw-w64-crt/libarm32/msvcr120d.def.in ++++ b/mingw-w64-crt/libarm32/msvcr120d.def.in +@@ -1818,7 +1818,7 @@ atanf + atanh + atanhf + atanhl +-atexit ++atexit DATA + atof + atoi + atol diff --git a/patches/mingw-w64/9002-crt-Provide-wrappers-for-exit-in-libmingwex.patch b/patches/mingw-w64/9002-v12-crt-Provide-wrappers-for-exit-in-libmingwex.patch similarity index 100% rename from patches/mingw-w64/9002-crt-Provide-wrappers-for-exit-in-libmingwex.patch rename to patches/mingw-w64/9002-v12-crt-Provide-wrappers-for-exit-in-libmingwex.patch diff --git a/patches/mingw-w64/9002-v13-crt-Provide-wrappers-for-exit-in-libmingwex.patch b/patches/mingw-w64/9002-v13-crt-Provide-wrappers-for-exit-in-libmingwex.patch new file mode 100644 index 0000000000..1230f0f78b --- /dev/null +++ b/patches/mingw-w64/9002-v13-crt-Provide-wrappers-for-exit-in-libmingwex.patch @@ -0,0 +1,988 @@ +diff --git a/mingw-w64-crt/Makefile.am b/mingw-w64-crt/Makefile.am +index d497fa76b..a0bd0c7ee 100644 +--- a/mingw-w64-crt/Makefile.am ++++ b/mingw-w64-crt/Makefile.am +@@ -117,7 +117,7 @@ src_libmingw32=include/oscalls.h include/internal.h include/sect_attribs.h \ + crt/usermatherr.c \ + crt/xtxtmode.c crt/crt_handler.c \ + crt/tlsthrd.c crt/tlsmthread.c crt/tlsmcrt.c \ +- crt/cxa_atexit.c crt/cxa_thread_atexit.c crt/tls_atexit.c ++ crt/cxa_atexit.c crt/cxa_thread_atexit.c crt/tls_atexit.c crt/exit_wrappers.c crt/ucrt_exit_wrappers.c + + src_libscrnsave=libsrc/scrnsave.c + src_libscrnsavw=libsrc/scrnsave.c +diff --git a/mingw-w64-crt/crt/exit_wrappers.c b/mingw-w64-crt/crt/exit_wrappers.c +new file mode 100644 +index 000000000..256c26d07 +--- /dev/null ++++ b/mingw-w64-crt/crt/exit_wrappers.c +@@ -0,0 +1,25 @@ ++/** ++ * This file has no copyright assigned and is placed in the Public Domain. ++ * This file is part of the mingw-w64 runtime package. ++ * No warranty is given; refer to the file DISCLAIMER.PD within this package. ++ */ ++ ++#include <_mingw.h> ++ ++/* `exit()`, C89 */ ++void exit(int status) __attribute__((__noreturn__)); ++extern void (*__MINGW_IMP_SYMBOL(exit))(int) __attribute__((__noreturn__)); ++ ++void exit(int status) ++{ ++ (*__MINGW_IMP_SYMBOL(exit))(status); ++} ++ ++/* `_exit()`, POSIX */ ++void _exit(int status) __attribute__((__noreturn__)); ++extern void (*__MINGW_IMP_SYMBOL(_exit))(int) __attribute__((__noreturn__)); ++ ++void _exit(int status) ++{ ++ (*__MINGW_IMP_SYMBOL(_exit))(status); ++} +diff --git a/mingw-w64-crt/crt/ucrt_exit_wrappers.c b/mingw-w64-crt/crt/ucrt_exit_wrappers.c +new file mode 100644 +index 000000000..112d8e3c7 +--- /dev/null ++++ b/mingw-w64-crt/crt/ucrt_exit_wrappers.c +@@ -0,0 +1,27 @@ ++/** ++ * This file has no copyright assigned and is placed in the Public Domain. ++ * This file is part of the mingw-w64 runtime package. ++ * No warranty is given; refer to the file DISCLAIMER.PD within this package. ++ */ ++ ++#undef __MSVCRT_VERSION__ ++#define _UCRT ++#include <_mingw.h> ++ ++/* `quick_exit()`, C99 */ ++void quick_exit(int status) __attribute__((__noreturn__)); ++extern void (*__MINGW_IMP_SYMBOL(quick_exit))(int) __attribute__((__noreturn__)); ++ ++void quick_exit(int status) ++{ ++ (*__MINGW_IMP_SYMBOL(quick_exit))(status); ++} ++ ++/* `_Exit()`, C99 */ ++void _Exit(int status) __attribute__((__noreturn__)); ++extern void (*__MINGW_IMP_SYMBOL(_Exit))(int) __attribute__((__noreturn__)); ++ ++void _Exit(int status) ++{ ++ (*__MINGW_IMP_SYMBOL(_Exit))(status); ++} +diff --git a/mingw-w64-crt/lib-common/api-ms-win-crt-runtime-l1-1-0.def.in b/mingw-w64-crt/lib-common/api-ms-win-crt-runtime-l1-1-0.def.in +index ea310d426..33e4f5504 100644 +--- a/mingw-w64-crt/lib-common/api-ms-win-crt-runtime-l1-1-0.def.in ++++ b/mingw-w64-crt/lib-common/api-ms-win-crt-runtime-l1-1-0.def.in +@@ -4,7 +4,7 @@ EXPORTS + + #include "func.def.in" + +-_Exit ++_Exit DATA + F_I386(__control87_2) + __doserrno + __fpe_flt_rounds +@@ -42,7 +42,7 @@ _endthread + _endthreadex + _errno + _execute_onexit_table +-_exit ++_exit DATA + F_NON_I386(_fpieee_flt) + ; DATA added manually + _fpreset DATA +@@ -96,7 +96,7 @@ _wcserror_s + _wperror + _wsystem + abort +-exit ++exit DATA + ; Don't use the float env functions from UCRT; fesetround doesn't seem to have + ; any effect on the FPU control word as required by other libmingwex math + ; routines. +@@ -110,7 +110,7 @@ fesetexceptflag DATA + fesetround DATA + fetestexcept DATA + perror +-quick_exit ++quick_exit DATA + raise + set_terminate + signal +diff --git a/mingw-w64-crt/lib-common/msvcr120_app.def.in b/mingw-w64-crt/lib-common/msvcr120_app.def.in +index 1788601f4..95b4bdcd0 100644 +--- a/mingw-w64-crt/lib-common/msvcr120_app.def.in ++++ b/mingw-w64-crt/lib-common/msvcr120_app.def.in +@@ -1243,7 +1243,7 @@ F_I386(_except1) + F_I386(_except_handler2) + F_I386(_except_handler3) + F_I386(_except_handler4_common) +-_exit ++_exit DATA + _exit_app + _expand + _fclose_nolock +@@ -1970,7 +1970,7 @@ erfcf + F_ARM32(erfcl) ; Can't use long double functions from the CRT on x86 + erff + F_ARM32(erfl) ; Can't use long double functions from the CRT on x86 +-exit ++exit DATA + exp + exp2 + exp2f +diff --git a/mingw-w64-crt/lib-common/msvcrt.def.in b/mingw-w64-crt/lib-common/msvcrt.def.in +index 64e978088..aba98b197 100644 +--- a/mingw-w64-crt/lib-common/msvcrt.def.in ++++ b/mingw-w64-crt/lib-common/msvcrt.def.in +@@ -578,7 +578,7 @@ _execv + _execve + _execvp + _execvpe +-_exit ++_exit DATA + _expand + _fcloseall + _fcvt +@@ -951,7 +951,7 @@ cosh + ctime + difftime + div +-exit ++exit DATA + exp F_X86_ANY(DATA) + fabs DATA + fclose +diff --git a/mingw-w64-crt/lib-common/ucrtbase-common.def.in b/mingw-w64-crt/lib-common/ucrtbase-common.def.in +index 4e1c87da6..bdfdb1579 100644 +--- a/mingw-w64-crt/lib-common/ucrtbase-common.def.in ++++ b/mingw-w64-crt/lib-common/ucrtbase-common.def.in +@@ -60,7 +60,7 @@ F_DEBUG(_CrtSetReportMode) + F_I386(_CxxThrowException@8) + F_NON_I386(_CxxThrowException) + F_I386(_EH_prolog) +-_Exit ++_Exit DATA + _FCbuild + _FCmulcc + _FCmulcr +@@ -345,7 +345,7 @@ _execv + _execve + _execvp + _execvpe +-_exit ++_exit DATA + _expand + F_DEBUG(_expand_dbg) + _fclose_nolock +@@ -2328,7 +2328,7 @@ erfcf + F_ARM_ANY(erfcl) ; Can't use long double functions from the CRT on x86 + erff + F_ARM_ANY(erfl) ; Can't use long double functions from the CRT on x86 +-exit ++exit DATA + exp + exp2 + exp2f +@@ -2518,7 +2518,7 @@ putwc + putwchar + qsort + qsort_s +-quick_exit ++quick_exit DATA + raise + rand + rand_s +diff --git a/mingw-w64-crt/lib32/crtdll.def.in b/mingw-w64-crt/lib32/crtdll.def.in +index e0626d58d..47242831f 100644 +--- a/mingw-w64-crt/lib32/crtdll.def.in ++++ b/mingw-w64-crt/lib32/crtdll.def.in +@@ -167,7 +167,7 @@ _execv + _execve + _execvp + _execvpe +-_exit ++_exit DATA + _expand + _fcloseall + _fcvt +@@ -447,7 +447,7 @@ cosh + ctime + difftime + div +-exit ++exit DATA + exp DATA + fabs DATA + fclose +diff --git a/mingw-w64-crt/lib32/msvcr100.def.in b/mingw-w64-crt/lib32/msvcr100.def.in +index fda12255a..54347de02 100644 +--- a/mingw-w64-crt/lib32/msvcr100.def.in ++++ b/mingw-w64-crt/lib32/msvcr100.def.in +@@ -830,7 +830,7 @@ _execv + _execve + _execvp + _execvpe +-_exit ++_exit DATA + _expand + _fclose_nolock + _fcloseall +@@ -1672,7 +1672,7 @@ cos DATA + ; If we implement cosh too, we can set it to DATA only. + cosh + div +-exit ++exit DATA + exp DATA + fabs DATA + fclose +diff --git a/mingw-w64-crt/lib32/msvcr100d.def.in b/mingw-w64-crt/lib32/msvcr100d.def.in +index c7616a8f0..8a8c8f5fe 100644 +--- a/mingw-w64-crt/lib32/msvcr100d.def.in ++++ b/mingw-w64-crt/lib32/msvcr100d.def.in +@@ -883,7 +883,7 @@ _execv + _execve + _execvp + _execvpe +-_exit ++_exit DATA + _expand + _expand_dbg + _fclose_nolock +@@ -1738,7 +1738,7 @@ clock + cos DATA ; overwritten + cosh + div +-exit ++exit DATA + exp DATA ; overwritten + fabs DATA ; overwritten + fclose +diff --git a/mingw-w64-crt/lib32/msvcr110.def.in b/mingw-w64-crt/lib32/msvcr110.def.in +index eb45326d5..0bb096397 100644 +--- a/mingw-w64-crt/lib32/msvcr110.def.in ++++ b/mingw-w64-crt/lib32/msvcr110.def.in +@@ -953,7 +953,7 @@ _execv + _execve + _execvp + _execvpe +-_exit ++_exit DATA + _expand + _fclose_nolock + _fcloseall +@@ -1804,7 +1804,7 @@ clock + cos DATA + cosh ; If we implement cosh, we can set it to DATA only. + div +-exit ++exit DATA + exp DATA + fabs DATA + fclose +diff --git a/mingw-w64-crt/lib32/msvcr110d.def.in b/mingw-w64-crt/lib32/msvcr110d.def.in +index 2dcd3b371..7944e7805 100644 +--- a/mingw-w64-crt/lib32/msvcr110d.def.in ++++ b/mingw-w64-crt/lib32/msvcr110d.def.in +@@ -1006,7 +1006,7 @@ _execv + _execve + _execvp + _execvpe +-_exit ++_exit DATA + _expand + _expand_dbg + _fclose_nolock +@@ -1871,7 +1871,7 @@ clock + cos DATA ; overwritten + cosh + div +-exit ++exit DATA + exp DATA ; overwritten + fabs DATA ; overwritten + fclose +diff --git a/mingw-w64-crt/lib32/msvcr120.def.in b/mingw-w64-crt/lib32/msvcr120.def.in +index 24c3126ae..b54c7f528 100644 +--- a/mingw-w64-crt/lib32/msvcr120.def.in ++++ b/mingw-w64-crt/lib32/msvcr120.def.in +@@ -972,7 +972,7 @@ _execv + _execve + _execvp + _execvpe +-_exit ++_exit DATA + _expand + _fclose_nolock + _fcloseall +@@ -1943,7 +1943,7 @@ erfcf + ; erfcl ; Can't use long double functions from the CRT on x86 + erff + ; erfl ; Can't use long double functions from the CRT on x86 +-exit ++exit DATA + exp + exp2 + exp2f +diff --git a/mingw-w64-crt/lib32/msvcr120d.def.in b/mingw-w64-crt/lib32/msvcr120d.def.in +index 8b46a9725..22cb85bf6 100644 +--- a/mingw-w64-crt/lib32/msvcr120d.def.in ++++ b/mingw-w64-crt/lib32/msvcr120d.def.in +@@ -1025,7 +1025,7 @@ _execv + _execve + _execvp + _execvpe +-_exit ++_exit DATA + _expand + _expand_dbg + _fclose_nolock +@@ -2010,7 +2010,7 @@ erfcf + ; erfcl ; Can't use long double functions from the CRT on x86 + erff + ; erfl ; Can't use long double functions from the CRT on x86 +-exit ++exit DATA + exp + exp2 + exp2f +diff --git a/mingw-w64-crt/lib32/msvcr40d.def.in b/mingw-w64-crt/lib32/msvcr40d.def.in +index 278aa7740..6f6b92a31 100644 +--- a/mingw-w64-crt/lib32/msvcr40d.def.in ++++ b/mingw-w64-crt/lib32/msvcr40d.def.in +@@ -1126,7 +1126,7 @@ _execv + _execve + _execvp + _execvpe +-_exit ++_exit DATA + _expand + _expand_dbg + _fcloseall +@@ -1475,7 +1475,7 @@ cosh + ctime + difftime + div +-exit ++exit DATA + exp + fabs + fclose +diff --git a/mingw-w64-crt/lib32/msvcr70.def.in b/mingw-w64-crt/lib32/msvcr70.def.in +index 6a302611f..33999a74e 100644 +--- a/mingw-w64-crt/lib32/msvcr70.def.in ++++ b/mingw-w64-crt/lib32/msvcr70.def.in +@@ -314,7 +314,7 @@ _execv + _execve + _execvp + _execvpe +-_exit ++_exit DATA + _expand + _fcloseall + _fcvt +@@ -725,7 +725,7 @@ cosh + ctime + difftime + div +-exit ++exit DATA + exp + fabs + fclose +diff --git a/mingw-w64-crt/lib32/msvcr70d.def.in b/mingw-w64-crt/lib32/msvcr70d.def.in +index eb10ee400..ec92a89fd 100644 +--- a/mingw-w64-crt/lib32/msvcr70d.def.in ++++ b/mingw-w64-crt/lib32/msvcr70d.def.in +@@ -353,7 +353,7 @@ _execv + _execve + _execvp + _execvpe +-_exit ++_exit DATA + _expand + _expand_dbg + _fcloseall +@@ -769,7 +769,7 @@ cosh + ctime + difftime + div +-exit ++exit DATA + exp + fabs + fclose +diff --git a/mingw-w64-crt/lib32/msvcr71.def.in b/mingw-w64-crt/lib32/msvcr71.def.in +index 63e63bf06..7b2d7b72e 100644 +--- a/mingw-w64-crt/lib32/msvcr71.def.in ++++ b/mingw-w64-crt/lib32/msvcr71.def.in +@@ -306,7 +306,7 @@ _execv + _execve + _execvp + _execvpe +-_exit ++_exit DATA + _expand + _fcloseall + _fcvt +@@ -719,7 +719,7 @@ cosh + ctime + difftime + div +-exit ++exit DATA + exp + fabs + fclose +diff --git a/mingw-w64-crt/lib32/msvcr71d.def.in b/mingw-w64-crt/lib32/msvcr71d.def.in +index c6b60f98b..5a457be81 100644 +--- a/mingw-w64-crt/lib32/msvcr71d.def.in ++++ b/mingw-w64-crt/lib32/msvcr71d.def.in +@@ -345,7 +345,7 @@ _execv + _execve + _execvp + _execvpe +-_exit ++_exit DATA + _expand + _expand_dbg + _fcloseall +@@ -763,7 +763,7 @@ cosh + ctime + difftime + div +-exit ++exit DATA + exp + fabs + fclose +diff --git a/mingw-w64-crt/lib32/msvcr80.def.in b/mingw-w64-crt/lib32/msvcr80.def.in +index 107356849..e90a5f3f9 100644 +--- a/mingw-w64-crt/lib32/msvcr80.def.in ++++ b/mingw-w64-crt/lib32/msvcr80.def.in +@@ -457,7 +457,7 @@ _execv + _execve + _execvp + _execvpe +-_exit ++_exit DATA + _expand + _fclose_nolock + _fcloseall +@@ -1312,7 +1312,7 @@ clock + cos DATA + cosh ; If we implement cosh, we can set it to DATA only. + div +-exit ++exit DATA + exp DATA + fabs DATA + fclose +diff --git a/mingw-w64-crt/lib32/msvcr80d.def.in b/mingw-w64-crt/lib32/msvcr80d.def.in +index 1e461af4d..100c93332 100644 +--- a/mingw-w64-crt/lib32/msvcr80d.def.in ++++ b/mingw-w64-crt/lib32/msvcr80d.def.in +@@ -524,7 +524,7 @@ _execv + _execve + _execvp + _execvpe +-_exit ++_exit DATA + _expand + _expand_dbg + _fclose_nolock +@@ -1395,7 +1395,7 @@ clock + cos DATA ; overwritten + cosh + div +-exit ++exit DATA + exp DATA ; overwritten + fabs DATA ; overwritten + fclose +diff --git a/mingw-w64-crt/lib32/msvcr90.def.in b/mingw-w64-crt/lib32/msvcr90.def.in +index c8ae0be94..017d974c8 100644 +--- a/mingw-w64-crt/lib32/msvcr90.def.in ++++ b/mingw-w64-crt/lib32/msvcr90.def.in +@@ -457,7 +457,7 @@ _execv + _execve + _execvp + _execvpe +-_exit ++_exit DATA + _expand + _fclose_nolock + _fcloseall +@@ -1306,7 +1306,7 @@ cos DATA + ; If we have cosh implementation, we can set it to DATA only. + cosh + div +-exit ++exit DATA + exp DATA + fabs DATA + fclose +diff --git a/mingw-w64-crt/lib32/msvcr90d.def.in b/mingw-w64-crt/lib32/msvcr90d.def.in +index 1e88f7175..df5da0b4c 100644 +--- a/mingw-w64-crt/lib32/msvcr90d.def.in ++++ b/mingw-w64-crt/lib32/msvcr90d.def.in +@@ -514,7 +514,7 @@ _execv + _execve + _execvp + _execvpe +-_exit ++_exit DATA + _expand + _expand_dbg + _fclose_nolock +@@ -1378,7 +1378,7 @@ cos DATA + ; If we implement cosh too, we can set it to DATA only. + cosh + div +-exit ++exit DATA + exp DATA + fabs DATA + fclose +diff --git a/mingw-w64-crt/lib32/msvcrt10.def.in b/mingw-w64-crt/lib32/msvcrt10.def.in +index f5e58a273..19508773e 100644 +--- a/mingw-w64-crt/lib32/msvcrt10.def.in ++++ b/mingw-w64-crt/lib32/msvcrt10.def.in +@@ -943,7 +943,7 @@ _execv + _execve + _execvp + _execvpe +-_exit ++_exit DATA + _expand + _fcloseall + _fcvt +@@ -1126,7 +1126,7 @@ cosh + ctime + difftime + div +-exit ++exit DATA + exp + fabs + fclose +diff --git a/mingw-w64-crt/lib32/msvcrt20.def.in b/mingw-w64-crt/lib32/msvcrt20.def.in +index df69e69ca..c10977696 100644 +--- a/mingw-w64-crt/lib32/msvcrt20.def.in ++++ b/mingw-w64-crt/lib32/msvcrt20.def.in +@@ -981,7 +981,7 @@ _execv + _execve + _execvp + _execvpe +-_exit ++_exit DATA + _expand + _fcloseall + _fcvt +@@ -1343,7 +1343,7 @@ cosh + ctime + difftime + div +-exit ++exit DATA + exp + fabs + fclose +diff --git a/mingw-w64-crt/lib32/msvcrt40.def.in b/mingw-w64-crt/lib32/msvcrt40.def.in +index 98dc2015e..d276f910c 100644 +--- a/mingw-w64-crt/lib32/msvcrt40.def.in ++++ b/mingw-w64-crt/lib32/msvcrt40.def.in +@@ -1099,7 +1099,7 @@ _execv + _execve + _execvp + _execvpe +-_exit ++_exit DATA + _expand + _fcloseall + _fcvt +@@ -1443,7 +1443,7 @@ cosh + ctime + difftime + div +-exit ++exit DATA + exp + fabs + fclose +diff --git a/mingw-w64-crt/lib32/msvcrtd.def.in b/mingw-w64-crt/lib32/msvcrtd.def.in +index a0823f422..897fd8d64 100644 +--- a/mingw-w64-crt/lib32/msvcrtd.def.in ++++ b/mingw-w64-crt/lib32/msvcrtd.def.in +@@ -291,7 +291,7 @@ _execv + _execve + _execvp + _execvpe +-_exit ++_exit DATA + _expand + _expand_dbg + _fcloseall +@@ -669,7 +669,7 @@ cosh + ctime + difftime + div +-exit ++exit DATA + exp + fabs + fclose +diff --git a/mingw-w64-crt/lib64/msvcr100.def.in b/mingw-w64-crt/lib64/msvcr100.def.in +index 8b8ba49c6..b4b57c2f1 100644 +--- a/mingw-w64-crt/lib64/msvcr100.def.in ++++ b/mingw-w64-crt/lib64/msvcr100.def.in +@@ -784,7 +784,7 @@ _execv + _execve + _execvp + _execvpe +-_exit ++_exit DATA + _expand + _fclose_nolock + _fcloseall +@@ -1624,7 +1624,7 @@ cosf DATA + cosh + coshf DATA + div +-exit ++exit DATA + exp DATA + expf DATA + fabs DATA +diff --git a/mingw-w64-crt/lib64/msvcr100d.def.in b/mingw-w64-crt/lib64/msvcr100d.def.in +index b07bd4c95..7a0877d32 100644 +--- a/mingw-w64-crt/lib64/msvcr100d.def.in ++++ b/mingw-w64-crt/lib64/msvcr100d.def.in +@@ -835,7 +835,7 @@ _execv + _execve + _execvp + _execvpe +-_exit ++_exit DATA + _expand + _expand_dbg + _fclose_nolock +@@ -1689,7 +1689,7 @@ cosf DATA ; overwritten + cosh + coshf DATA ; overwritten + div +-exit ++exit DATA + exp DATA ; overwritten + expf DATA ; overwritten + fabs DATA ; overwritten +diff --git a/mingw-w64-crt/lib64/msvcr110.def.in b/mingw-w64-crt/lib64/msvcr110.def.in +index 2c2c9fbb9..f98039bb3 100644 +--- a/mingw-w64-crt/lib64/msvcr110.def.in ++++ b/mingw-w64-crt/lib64/msvcr110.def.in +@@ -909,7 +909,7 @@ _execv + _execve + _execvp + _execvpe +-_exit ++_exit DATA + _expand + _fclose_nolock + _fcloseall +@@ -1748,7 +1748,7 @@ cosf + cosh + coshf + div +-exit ++exit DATA + exp + expf + fabs +diff --git a/mingw-w64-crt/lib64/msvcr110d.def.in b/mingw-w64-crt/lib64/msvcr110d.def.in +index 9f7bcf988..4ae550ebe 100644 +--- a/mingw-w64-crt/lib64/msvcr110d.def.in ++++ b/mingw-w64-crt/lib64/msvcr110d.def.in +@@ -960,7 +960,7 @@ _execv + _execve + _execvp + _execvpe +-_exit ++_exit DATA + _expand + _expand_dbg + _fclose_nolock +@@ -1813,7 +1813,7 @@ cosf + cosh + coshf + div +-exit ++exit DATA + exp + expf + fabs +diff --git a/mingw-w64-crt/lib64/msvcr120.def.in b/mingw-w64-crt/lib64/msvcr120.def.in +index ab4912db4..bf5aaf731 100644 +--- a/mingw-w64-crt/lib64/msvcr120.def.in ++++ b/mingw-w64-crt/lib64/msvcr120.def.in +@@ -926,7 +926,7 @@ _execv + _execve + _execvp + _execvpe +-_exit ++_exit DATA + _expand + _fclose_nolock + _fcloseall +@@ -1888,7 +1888,7 @@ erfcf + ; erfcl ; Can't use long double functions from the CRT on x86 + erff + ; erfl ; Can't use long double functions from the CRT on x86 +-exit ++exit DATA + exp + exp2 + exp2f +diff --git a/mingw-w64-crt/lib64/msvcr120d.def.in b/mingw-w64-crt/lib64/msvcr120d.def.in +index f61eb41f6..fbc961018 100644 +--- a/mingw-w64-crt/lib64/msvcr120d.def.in ++++ b/mingw-w64-crt/lib64/msvcr120d.def.in +@@ -977,7 +977,7 @@ _execv + _execve + _execvp + _execvpe +-_exit ++_exit DATA + _expand + _expand_dbg + _fclose_nolock +@@ -1953,7 +1953,7 @@ erfcf + ; erfcl ; Can't use long double functions from the CRT on x86 + erff + ; erfl ; Can't use long double functions from the CRT on x86 +-exit ++exit DATA + exp + exp2 + exp2f +diff --git a/mingw-w64-crt/lib64/msvcr80.def.in b/mingw-w64-crt/lib64/msvcr80.def.in +index 3c15764a6..75f2f3033 100644 +--- a/mingw-w64-crt/lib64/msvcr80.def.in ++++ b/mingw-w64-crt/lib64/msvcr80.def.in +@@ -397,7 +397,7 @@ _execv + _execve + _execvp + _execvpe +-_exit ++_exit DATA + _expand + _fclose_nolock + _fcloseall +@@ -1247,7 +1247,7 @@ cosf + cosh + coshf + div +-exit ++exit DATA + exp DATA + expf DATA + fabs +diff --git a/mingw-w64-crt/lib64/msvcr80d.def.in b/mingw-w64-crt/lib64/msvcr80d.def.in +index 00d217352..a4a95bad5 100644 +--- a/mingw-w64-crt/lib64/msvcr80d.def.in ++++ b/mingw-w64-crt/lib64/msvcr80d.def.in +@@ -458,7 +458,7 @@ _execv + _execve + _execvp + _execvpe +-_exit ++_exit DATA + _expand + _expand_dbg + _fclose_nolock +@@ -1324,7 +1324,7 @@ cosf + cosh + coshf + div +-exit ++exit DATA + exp DATA ; overwritten + expf DATA ; overwritten + fabs +diff --git a/mingw-w64-crt/lib64/msvcr90.def.in b/mingw-w64-crt/lib64/msvcr90.def.in +index 4e4c57351..dcb27400f 100644 +--- a/mingw-w64-crt/lib64/msvcr90.def.in ++++ b/mingw-w64-crt/lib64/msvcr90.def.in +@@ -401,7 +401,7 @@ _execv + _execve + _execvp + _execvpe +-_exit ++_exit DATA + _expand + _fclose_nolock + _fcloseall +@@ -1244,7 +1244,7 @@ cosf DATA + cosh + coshf DATA + div +-exit ++exit DATA + exp DATA + expf DATA + fabs DATA +diff --git a/mingw-w64-crt/lib64/msvcr90d.def.in b/mingw-w64-crt/lib64/msvcr90d.def.in +index ef03d6ac0..bffa03196 100644 +--- a/mingw-w64-crt/lib64/msvcr90d.def.in ++++ b/mingw-w64-crt/lib64/msvcr90d.def.in +@@ -452,7 +452,7 @@ _execv + _execve + _execvp + _execvpe +-_exit ++_exit DATA + _expand + _expand_dbg + _fclose_nolock +@@ -1310,7 +1310,7 @@ cosf + cosh + coshf + div +-exit ++exit DATA + exp DATA + expf DATA + fabs +diff --git a/mingw-w64-crt/libarm32/kernelbase.def b/mingw-w64-crt/libarm32/kernelbase.def +index d6a487db1..f6626c5df 100644 +--- a/mingw-w64-crt/libarm32/kernelbase.def ++++ b/mingw-w64-crt/libarm32/kernelbase.def +@@ -1882,7 +1882,7 @@ __wgetmainargs + _amsg_exit + _c_exit + _cexit +-_exit ++_exit DATA + _initterm + _initterm_e + _invalid_parameter +@@ -1890,7 +1890,7 @@ _onexit + _purecall + _time64 + atexit DATA +-exit ++exit DATA + hgets + hwprintf + lstrcmp +diff --git a/mingw-w64-crt/libarm32/msvcr110.def.in b/mingw-w64-crt/libarm32/msvcr110.def.in +index 84f46eca3..3ed9360e3 100644 +--- a/mingw-w64-crt/libarm32/msvcr110.def.in ++++ b/mingw-w64-crt/libarm32/msvcr110.def.in +@@ -901,7 +901,7 @@ _execv + _execve + _execvp + _execvpe +-_exit ++_exit DATA + _expand + _fclose_nolock + _fcloseall +@@ -1734,7 +1734,7 @@ cosf + cosh + coshf + div +-exit ++exit DATA + exp + expf + fabs +diff --git a/mingw-w64-crt/libarm32/msvcr110d.def.in b/mingw-w64-crt/libarm32/msvcr110d.def.in +index a7aebdad6..c3b7490cd 100644 +--- a/mingw-w64-crt/libarm32/msvcr110d.def.in ++++ b/mingw-w64-crt/libarm32/msvcr110d.def.in +@@ -952,7 +952,7 @@ _execv + _execve + _execvp + _execvpe +-_exit ++_exit DATA + _expand + _expand_dbg + _fclose_nolock +@@ -1799,7 +1799,7 @@ cosf + cosh + coshf + div +-exit ++exit DATA + exp + expf + fabs +diff --git a/mingw-w64-crt/libarm32/msvcr120.def.in b/mingw-w64-crt/libarm32/msvcr120.def.in +index f94ac44f3..57f5a898a 100644 +--- a/mingw-w64-crt/libarm32/msvcr120.def.in ++++ b/mingw-w64-crt/libarm32/msvcr120.def.in +@@ -900,7 +900,7 @@ _execv + _execve + _execvp + _execvpe +-_exit ++_exit DATA + _expand + _fclose_nolock + _fcloseall +@@ -1853,7 +1853,7 @@ erfcf + erfcl + erff + erfl +-exit ++exit DATA + exp + exp2 + exp2f +diff --git a/mingw-w64-crt/libarm32/msvcr120d.def.in b/mingw-w64-crt/libarm32/msvcr120d.def.in +index 9d4cec588..a720c23dc 100644 +--- a/mingw-w64-crt/libarm32/msvcr120d.def.in ++++ b/mingw-w64-crt/libarm32/msvcr120d.def.in +@@ -951,7 +951,7 @@ _execv + _execve + _execvp + _execvpe +-_exit ++_exit DATA + _expand + _expand_dbg + _fclose_nolock +@@ -1918,7 +1918,7 @@ erfcf + erfcl + erff + erfl +-exit ++exit DATA + exp + exp2 + exp2f +diff --git a/mingw-w64-crt/misc/ucrt_compat.c b/mingw-w64-crt/misc/ucrt_compat.c +index 7fefae11e..446b5b06d 100644 +--- a/mingw-w64-crt/misc/ucrt_compat.c ++++ b/mingw-w64-crt/misc/ucrt_compat.c +@@ -34,10 +34,11 @@ unsigned int __cdecl _get_output_format(void); + + int __cdecl __ms_fwprintf(FILE *, const wchar_t *, ...); + ++extern void (*__MINGW_IMP_SYMBOL(_exit))(int) __attribute__((__noreturn__)); + + void __cdecl __MINGW_ATTRIB_NORETURN _amsg_exit(int ret) { + fprintf(stderr, "runtime error %d\n", ret); +- _exit(255); ++ (*__MINGW_IMP_SYMBOL(_exit))(255); + } + + unsigned int __cdecl _get_output_format(void) diff --git a/patches/mingw-w64/9003-crt-Implement-standard-conforming-termination-suppor.patch b/patches/mingw-w64/9003-v11-crt-Implement-standard-conforming-termination-support.patch similarity index 96% rename from patches/mingw-w64/9003-crt-Implement-standard-conforming-termination-suppor.patch rename to patches/mingw-w64/9003-v11-crt-Implement-standard-conforming-termination-support.patch index 41dfe265ac..76cb17d582 100644 --- a/patches/mingw-w64/9003-crt-Implement-standard-conforming-termination-suppor.patch +++ b/patches/mingw-w64/9003-v11-crt-Implement-standard-conforming-termination-support.patch @@ -267,11 +267,21 @@ index 0412fa4ba..ed36b935c 100644 + +#endif /* __USING_MCFGTHREAD__ */ diff --git a/mingw-w64-crt/crt/ucrt_exit_wrappers.c b/mingw-w64-crt/crt/ucrt_exit_wrappers.c -index 112d8e3c7..4ef52a687 100644 +index 112d8e3c7..10611ac88 100644 --- a/mingw-w64-crt/crt/ucrt_exit_wrappers.c +++ b/mingw-w64-crt/crt/ucrt_exit_wrappers.c -@@ -14,7 +14,11 @@ extern void (*__MINGW_IMP_SYMBOL(quick_exit))(int) __attribute__((__noreturn__)) - +@@ -7,6 +7,9 @@ + #undef __MSVCRT_VERSION__ + #define _UCRT + #include <_mingw.h> ++#ifdef __USING_MCFGTHREAD__ ++#include ++#endif + + /* `quick_exit()`, C99 */ + void quick_exit(int status) __attribute__((__noreturn__)); +@@ -14,7 +17,11 @@ extern void (*__MINGW_IMP_SYMBOL(quick_exit))(int) __attribute__((__noreturn__)) + void quick_exit(int status) { +#ifdef __USING_MCFGTHREAD__ @@ -280,10 +290,10 @@ index 112d8e3c7..4ef52a687 100644 (*__MINGW_IMP_SYMBOL(quick_exit))(status); +#endif } - + /* `_Exit()`, C99 */ -@@ -23,5 +27,9 @@ extern void (*__MINGW_IMP_SYMBOL(_Exit))(int) __attribute__((__noreturn__)); - +@@ -23,5 +30,9 @@ extern void (*__MINGW_IMP_SYMBOL(_Exit))(int) __attribute__((__noreturn__)); + void _Exit(int status) { +#ifdef __USING_MCFGTHREAD__ diff --git a/patches/mingw-w64/9003-v13-crt-Implement-standard-conforming-termination-support.patch b/patches/mingw-w64/9003-v13-crt-Implement-standard-conforming-termination-support.patch new file mode 100644 index 0000000000..ef4a8c185c --- /dev/null +++ b/patches/mingw-w64/9003-v13-crt-Implement-standard-conforming-termination-support.patch @@ -0,0 +1,273 @@ +diff --git a/mingw-w64-crt/crt/crtdll.c b/mingw-w64-crt/crt/crtdll.c +index 88450ce9f..2f00ddacf 100644 +--- a/mingw-w64-crt/crt/crtdll.c ++++ b/mingw-w64-crt/crt/crtdll.c +@@ -31,6 +31,12 @@ + #endif + #include + #include ++#include ++#ifdef __USING_MCFGTHREAD__ ++#include ++#endif ++ ++extern HANDLE __dso_handle; + + extern void __cdecl _initterm(_PVFV *,_PVFV *); + extern void __main (); +@@ -182,7 +188,14 @@ __DllMainCRTStartup (HANDLE hDllHandle, DWORD dwReason, LPVOID lpreserved) + } + } + if (dwReason == DLL_PROCESS_ATTACH) +- __main (); ++ { ++#ifdef __USING_MCFGTHREAD__ ++ /* Register `fflush(NULL)` before user-defined constructors, so ++ * it will be executed after all user-defined destructors. */ ++ __MCF_cxa_atexit ((__MCF_cxa_dtor_cdecl*)(intptr_t) fflush, NULL, &__dso_handle); ++#endif ++ __main (); ++ } + retcode = DllMain(hDllHandle,dwReason,lpreserved); + if (dwReason == DLL_PROCESS_ATTACH && ! retcode) + { +@@ -196,6 +209,16 @@ __DllMainCRTStartup (HANDLE hDllHandle, DWORD dwReason, LPVOID lpreserved) + if (_CRT_INIT (hDllHandle, dwReason, lpreserved) == FALSE) + retcode = FALSE; + } ++#ifdef __USING_MCFGTHREAD__ ++ if (dwReason == DLL_PROCESS_DETACH && lpreserved == NULL) ++ { ++ /* Call `__cxa_finalize(dso_handle)` if the library is unloaded ++ * dynamically. This conforms to the Itanium C++ ABI. Note it is ++ * not called in case of process termination, where a call to ++ * `__cxa_finalize(NULL)` shall have been made instead. */ ++ __MCF_cxa_finalize (&__dso_handle); ++ } ++#endif + i__leave: + __native_dllmain_reason = UINT_MAX; + return retcode ; +@@ -204,7 +227,11 @@ i__leave: + + int __cdecl atexit (_PVFV func) + { ++#ifdef __USING_MCFGTHREAD__ ++ return __MCF_cxa_atexit ((__MCF_cxa_dtor_cdecl*)(intptr_t) func, NULL, &__dso_handle); ++#else + return _register_onexit_function(&atexit_table, (_onexit_t)func); ++#endif + } + + char __mingw_module_is_dll = 1; +diff --git a/mingw-w64-crt/crt/crtexe.c b/mingw-w64-crt/crt/crtexe.c +index 2e45bf423..511636354 100644 +--- a/mingw-w64-crt/crt/crtexe.c ++++ b/mingw-w64-crt/crt/crtexe.c +@@ -20,6 +20,10 @@ + #include + #include + #include ++#include ++#ifdef __USING_MCFGTHREAD__ ++#include ++#endif + + #if defined(__SEH__) && (!defined(__clang__) || __clang_major__ >= 7) + #define SEH_INLINE_ASM +@@ -36,6 +40,7 @@ extern int _fmode; + #undef _commode + extern int _commode; + extern int _dowildcard; ++extern HANDLE __dso_handle; + + extern _CRTIMP void __cdecl _initterm(_PVFV *, _PVFV *); + +@@ -249,6 +254,11 @@ __tmainCRTStartup (void) + _fpreset (); + + duplicate_ppstrings (argc, &argv); ++#ifdef __USING_MCFGTHREAD__ ++ /* Register `fflush(NULL)` before user-defined constructors, so ++ * it will be executed after all user-defined destructors. */ ++ __MCF_cxa_atexit ((__MCF_cxa_dtor_cdecl*)(intptr_t) fflush, NULL, &__dso_handle); ++#endif + __main (); /* C++ initialization. */ + #ifdef _UNICODE + __winitenv = envp; +@@ -325,7 +335,11 @@ static void duplicate_ppstrings (int ac, _TCHAR ***av) + + int __cdecl atexit (_PVFV func) + { ++#ifdef __USING_MCFGTHREAD__ ++ return __MCF_cxa_atexit ((__MCF_cxa_dtor_cdecl*)(intptr_t) func, NULL, &__dso_handle); ++#else + return _onexit((_onexit_t)func) ? 0 : -1; ++#endif + } + + char __mingw_module_is_dll = 0; +diff --git a/mingw-w64-crt/crt/exit_wrappers.c b/mingw-w64-crt/crt/exit_wrappers.c +index 256c26d07..ab6896f96 100644 +--- a/mingw-w64-crt/crt/exit_wrappers.c ++++ b/mingw-w64-crt/crt/exit_wrappers.c +@@ -5,6 +5,10 @@ + */ + + #include <_mingw.h> ++#ifdef __USING_MCFGTHREAD__ ++#include ++#include ++#endif + + /* `exit()`, C89 */ + void exit(int status) __attribute__((__noreturn__)); +@@ -12,7 +16,11 @@ extern void (*__MINGW_IMP_SYMBOL(exit))(int) __attribute__((__noreturn__)); + + void exit(int status) + { ++#ifdef __USING_MCFGTHREAD__ ++ __MCF_exit(status); ++#else + (*__MINGW_IMP_SYMBOL(exit))(status); ++#endif + } + + /* `_exit()`, POSIX */ +@@ -21,5 +29,23 @@ extern void (*__MINGW_IMP_SYMBOL(_exit))(int) __attribute__((__noreturn__)); + + void _exit(int status) + { ++#ifdef __USING_MCFGTHREAD__ ++ __MCF__Exit(status); ++#else + (*__MINGW_IMP_SYMBOL(_exit))(status); ++#endif + } ++ ++#ifdef __USING_MCFGTHREAD__ ++/* `at_quick_exit()`, C99 */ ++typedef void (__cdecl *_PVFV)(void); ++int at_quick_exit(_PVFV func); ++ ++typedef void* HANDLE; ++extern HANDLE __dso_handle; ++ ++int at_quick_exit(_PVFV func) ++{ ++ return __MCF_cxa_at_quick_exit ((__MCF_cxa_dtor_cdecl*)(intptr_t) func, NULL, &__dso_handle); ++} ++#endif /* __USING_MCFGTHREAD__ */ +diff --git a/mingw-w64-crt/crt/tls_atexit.c b/mingw-w64-crt/crt/tls_atexit.c +index 0412fa4ba..ed36b935c 100644 +--- a/mingw-w64-crt/crt/tls_atexit.c ++++ b/mingw-w64-crt/crt/tls_atexit.c +@@ -4,6 +4,29 @@ + * No warranty is given; refer to the file DISCLAIMER.PD within this package. + */ + ++typedef void (__thiscall * dtor_fn)(void*); ++int __mingw_cxa_atexit(dtor_fn dtor, void *obj, void *dso); ++int __mingw_cxa_thread_atexit(dtor_fn dtor, void *obj, void *dso); ++ ++/* This is the per-module DSO handle as required by Itanium ABI. */ ++void* __dso_handle; ++ ++#ifdef __USING_MCFGTHREAD__ ++ ++#include ++ ++int __mingw_cxa_atexit(dtor_fn dtor, void *obj, void *dso) ++{ ++ return __MCF_cxa_atexit(dtor, obj, dso); ++} ++ ++int __mingw_cxa_thread_atexit(dtor_fn dtor, void *obj, void *dso) ++{ ++ return __MCF_cxa_thread_atexit(dtor, obj, dso); ++} ++ ++#else /* __USING_MCFGTHREAD__ */ ++ + #include + + #ifndef WIN32_LEAN_AND_MEAN +@@ -18,10 +41,6 @@ + #include + + +-typedef void (__thiscall * dtor_fn)(void*); +-int __mingw_cxa_atexit(dtor_fn dtor, void *obj, void *dso); +-int __mingw_cxa_thread_atexit(dtor_fn dtor, void *obj, void *dso); +- + typedef struct dtor_obj dtor_obj; + struct dtor_obj { + dtor_fn dtor; +@@ -29,7 +48,6 @@ struct dtor_obj { + dtor_obj *next; + }; + +-HANDLE __dso_handle; + extern char __mingw_module_is_dll; + + static CRITICAL_SECTION lock; +@@ -170,3 +188,5 @@ static void WINAPI tls_callback(HANDLE hDllHandle, DWORD dwReason, LPVOID __UNUS + } + + _CRTALLOC(".CRT$XLB") PIMAGE_TLS_CALLBACK __xl_b = (PIMAGE_TLS_CALLBACK) tls_callback; ++ ++#endif /* __USING_MCFGTHREAD__ */ +diff --git a/mingw-w64-crt/crt/ucrt_exit_wrappers.c b/mingw-w64-crt/crt/ucrt_exit_wrappers.c +index 112d8e3c7..10611ac88 100644 +--- a/mingw-w64-crt/crt/ucrt_exit_wrappers.c ++++ b/mingw-w64-crt/crt/ucrt_exit_wrappers.c +@@ -7,6 +7,9 @@ + #undef __MSVCRT_VERSION__ + #define _UCRT + #include <_mingw.h> ++#ifdef __USING_MCFGTHREAD__ ++#include ++#endif + + /* `quick_exit()`, C99 */ + void quick_exit(int status) __attribute__((__noreturn__)); +@@ -14,7 +17,11 @@ extern void (*__MINGW_IMP_SYMBOL(quick_exit))(int) __attribute__((__noreturn__)) + + void quick_exit(int status) + { ++#ifdef __USING_MCFGTHREAD__ ++ __MCF_quick_exit(status); ++#else + (*__MINGW_IMP_SYMBOL(quick_exit))(status); ++#endif + } + + /* `_Exit()`, C99 */ +@@ -23,5 +30,9 @@ extern void (*__MINGW_IMP_SYMBOL(_Exit))(int) __attribute__((__noreturn__)); + + void _Exit(int status) + { ++#ifdef __USING_MCFGTHREAD__ ++ __MCF__Exit(status); ++#else + (*__MINGW_IMP_SYMBOL(_Exit))(status); ++#endif + } +diff --git a/mingw-w64-crt/misc/ucrt_at_quick_exit.c b/mingw-w64-crt/misc/ucrt_at_quick_exit.c +index 5999552a0..2e25a1226 100644 +--- a/mingw-w64-crt/misc/ucrt_at_quick_exit.c ++++ b/mingw-w64-crt/misc/ucrt_at_quick_exit.c +@@ -10,6 +10,8 @@ + #include + #include + ++// When using mcfgthread, `at_quick_exit()` is provided in 'exit_wrappers.c'. ++#ifndef __USING_MCFGTHREAD__ + extern char __mingw_module_is_dll; + + int __cdecl at_quick_exit(void (__cdecl *func)(void)) +@@ -22,3 +24,4 @@ int __cdecl at_quick_exit(void (__cdecl *func)(void)) + return _crt_at_quick_exit(func); + } + int __cdecl (*__MINGW_IMP_SYMBOL(at_quick_exit))(void (__cdecl *)(void)) = at_quick_exit; ++#endif // __USING_MCFGTHREAD__ diff --git a/scripts/mingw-w64-crt.sh b/scripts/mingw-w64-crt.sh index 4b8eaca30e..20a04cd048 100644 --- a/scripts/mingw-w64-crt.sh +++ b/scripts/mingw-w64-crt.sh @@ -50,19 +50,31 @@ PKG_PRIORITY=runtime PKG_PATCHES=( $( [[ $RUNTIME_VERSION == v10.0.0 ]] && \ - [[ $MSVCRT_VERSION == ucrt ]] && { - echo "mingw-w64/89bacd2be60fa92dd74d3b5f2074b06a32d8c784.patch" - echo "mingw-w64/bceadc54d8f32b3f14c69074892e2718eac08e3b.patch" + [[ $MSVCRT_VERSION == ucrt ]] && { + echo "mingw-w64/89bacd2be60fa92dd74d3b5f2074b06a32d8c784.patch" + echo "mingw-w64/bceadc54d8f32b3f14c69074892e2718eac08e3b.patch" } ) $( [[ $RUNTIME_MAJOR_VERSION -ge 11 ]] && { - echo "mingw-w64/9001-crt-Mark-atexit-as-DATA-because-it-s-always-overridd.patch" - [[ $RUNTIME_MAJOR_VERSION -ge 12 ]] && { - echo "mingw-w64/9002-crt-Provide-wrappers-for-exit-in-libmingwex.patch" + [[ $RUNTIME_MAJOR_VERSION -ge 13 ]] && { + echo "mingw-w64/9001-v13-crt-Mark-atexit-as-DATA-because-it-s-always-overridd.patch" } || { - echo "mingw-w64/9002-v11-crt-Provide-wrappers-for-exit-in-libmingwex.patch" + echo "mingw-w64/9001-v11-crt-Mark-atexit-as-DATA-because-it-s-always-overridd.patch" + } + [[ $RUNTIME_MAJOR_VERSION -ge 13 ]] && { + echo "mingw-w64/9002-v13-crt-Provide-wrappers-for-exit-in-libmingwex.patch" + } || { + [[ $RUNTIME_MAJOR_VERSION -ge 12 ]] && { + echo "mingw-w64/9002-v12-crt-Provide-wrappers-for-exit-in-libmingwex.patch" + } || { + echo "mingw-w64/9002-v11-crt-Provide-wrappers-for-exit-in-libmingwex.patch" + } + } + [[ $RUNTIME_MAJOR_VERSION -ge 13 ]] && { + echo "mingw-w64/9003-v13-crt-Implement-standard-conforming-termination-support.patch" + } || { + echo "mingw-w64/9003-v11-crt-Implement-standard-conforming-termination-support.patch" } - echo "mingw-w64/9003-crt-Implement-standard-conforming-termination-suppor.patch" }) )