libsupc++: Make the destructor parameter to `__cxa_thread_atexit()` use the `__thiscall` calling convention for i686-w64-mingw32
The mingw-w64 implementations of `__cxa_thread_atexit()` and `__cxa_atexit()` have been
using `__thiscall` since two years ago. Using the default calling convention (which is
`__cdecl`) causes crashes as explained in PR83562.
Calling conventions have no effect on x86_64-w64-mingw32.
Reference: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83562
Reference: https://sourceforge.net/p/mingw-w64/mingw-w64/ci/master/tree/mingw-w64-crt/crt/cxa_thread_atexit.c
Reference: f3e0fbb40c
/
Reference: https://github.com/msys2/MINGW-packages/issues/7071
Signed-off-by: Liu Hao <lh_mouse@126.com>
2020-10-08 Liu Hao <lh_mouse@126.com>
libstdc++-v3:
* libsupc++/cxxabi.h: (__cxa_atexit): mark with _GLIBCXX_CDTOR_CALLABI
(__cxa_thread_atexit): ditto
* libsupc++/atexit_thread.cc: (__cxa_atexit): mark with
_GLIBCXX_CDTOR_CALLABI
(__cxa_thread_atexit): ditto
(elt): ditto
This commit is contained in:
parent
44cab2d8fd
commit
7fc0f78c3f
|
@ -30,16 +30,21 @@
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Simplify it a little for this file.
|
||||||
|
#ifndef _GLIBCXX_CDTOR_CALLABI
|
||||||
|
# define _GLIBCXX_CDTOR_CALLABI
|
||||||
|
#endif
|
||||||
|
|
||||||
#if _GLIBCXX_HAVE___CXA_THREAD_ATEXIT
|
#if _GLIBCXX_HAVE___CXA_THREAD_ATEXIT
|
||||||
|
|
||||||
// Libc provides __cxa_thread_atexit definition.
|
// Libc provides __cxa_thread_atexit definition.
|
||||||
|
|
||||||
#elif _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL
|
#elif _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL
|
||||||
|
|
||||||
extern "C" int __cxa_thread_atexit_impl (void (*func) (void *),
|
extern "C" int __cxa_thread_atexit_impl (void (_GLIBCXX_CDTOR_CALLABI *func) (void *),
|
||||||
void *arg, void *d);
|
void *arg, void *d);
|
||||||
extern "C" int
|
extern "C" int
|
||||||
__cxxabiv1::__cxa_thread_atexit (void (*dtor)(void *),
|
__cxxabiv1::__cxa_thread_atexit (void (_GLIBCXX_CDTOR_CALLABI *dtor)(void *),
|
||||||
void *obj, void *dso_handle)
|
void *obj, void *dso_handle)
|
||||||
_GLIBCXX_NOTHROW
|
_GLIBCXX_NOTHROW
|
||||||
{
|
{
|
||||||
|
@ -52,7 +57,7 @@ namespace {
|
||||||
// One element in a singly-linked stack of cleanups.
|
// One element in a singly-linked stack of cleanups.
|
||||||
struct elt
|
struct elt
|
||||||
{
|
{
|
||||||
void (*destructor)(void *);
|
void (_GLIBCXX_CDTOR_CALLABI *destructor)(void *);
|
||||||
void *object;
|
void *object;
|
||||||
elt *next;
|
elt *next;
|
||||||
#ifdef _GLIBCXX_THREAD_ATEXIT_WIN32
|
#ifdef _GLIBCXX_THREAD_ATEXIT_WIN32
|
||||||
|
@ -116,7 +121,8 @@ namespace {
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" int
|
extern "C" int
|
||||||
__cxxabiv1::__cxa_thread_atexit (void (*dtor)(void *), void *obj, void */*dso_handle*/)
|
__cxxabiv1::__cxa_thread_atexit (void (_GLIBCXX_CDTOR_CALLABI *dtor)(void *),
|
||||||
|
void *obj, void */*dso_handle*/)
|
||||||
_GLIBCXX_NOTHROW
|
_GLIBCXX_NOTHROW
|
||||||
{
|
{
|
||||||
// Do this initialization once.
|
// Do this initialization once.
|
||||||
|
|
|
@ -125,14 +125,22 @@ namespace __cxxabiv1
|
||||||
|
|
||||||
// DSO destruction.
|
// DSO destruction.
|
||||||
int
|
int
|
||||||
|
#ifdef _GLIBCXX_CDTOR_CALLABI
|
||||||
|
__cxa_atexit(void (_GLIBCXX_CDTOR_CALLABI *)(void*), void*, void*) _GLIBCXX_NOTHROW;
|
||||||
|
#else
|
||||||
__cxa_atexit(void (*)(void*), void*, void*) _GLIBCXX_NOTHROW;
|
__cxa_atexit(void (*)(void*), void*, void*) _GLIBCXX_NOTHROW;
|
||||||
|
#endif
|
||||||
|
|
||||||
void
|
void
|
||||||
__cxa_finalize(void*);
|
__cxa_finalize(void*);
|
||||||
|
|
||||||
// TLS destruction.
|
// TLS destruction.
|
||||||
int
|
int
|
||||||
|
#ifdef _GLIBCXX_CDTOR_CALLABI
|
||||||
|
__cxa_thread_atexit(void (_GLIBCXX_CDTOR_CALLABI *)(void*), void*, void *) _GLIBCXX_NOTHROW;
|
||||||
|
#else
|
||||||
__cxa_thread_atexit(void (*)(void*), void*, void *) _GLIBCXX_NOTHROW;
|
__cxa_thread_atexit(void (*)(void*), void*, void *) _GLIBCXX_NOTHROW;
|
||||||
|
#endif
|
||||||
|
|
||||||
// Pure virtual functions.
|
// Pure virtual functions.
|
||||||
void
|
void
|
||||||
|
|
Loading…
Reference in New Issue