https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114968

--- Comment #18 from LIU Hao <lh_mouse at 126 dot com> ---
(In reply to Jakub Jelinek from comment #16)
> What is the reason behind
> /* mingw32 atexit function is safe to use in shared libraries.  Use it
>    to register C++ static destructors.  */
> #define TARGET_CXX_USE_ATEXIT_FOR_CXA_ATEXIT hook_bool_void_true
> ?
> Couldn't we just drop that?

I think so. We have a statically linked `atexit()` much like glibc [1]. However
we have added `__cxa_atexit()` a couple of years ago, so it might be preferred.
As the Windows system library does not provide `__cxa_*` routines, those
functions are also linked statically, so they ignore the DSO handle parameter.


 [1]
https://github.com/mingw-w64/mingw-w64/blob/19cf5d171f6df208b27271b40014c66d2b44e38b/mingw-w64-crt/crt/crtdll.c#L205
 [2]
https://github.com/mingw-w64/mingw-w64/blob/19cf5d171f6df208b27271b40014c66d2b44e38b/mingw-w64-crt/crt/cxa_atexit.c#L11


> while with __cxa_atexit one can just pass the destructor itself to the
> __cxa_atexit function (indeed with slightly more instructions there because
> in addition to the function pointer it needs to pass the address of the
> object and __dso_handle).
> But it is still smaller.

Can `./configure --enable-__cxa_atexit` be safely used? Documentation says it's
only available with glibc [3], but I don't see any stuff specific to glibc.

 [3] https://gcc.gnu.org/install/configure.html


> Anyway, if there is some strong reason to keep it, I think it would be
> better to avoid adding yet another GTY tree, the __cxa_throw last argument
> type is the same as __cxa_atexit/__cxa_thread_atexit.

Maybe it can be kept for backward compatibility.

Reply via email to