Skip to content

Commit

Permalink
[WiP] Weak alias __cxa_thread_atexit_impl to musl's ___cxa_atexit
Browse files Browse the repository at this point in the history
  • Loading branch information
kleisauke committed Jan 12, 2023
1 parent 888f452 commit df11456
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 4 deletions.
1 change: 1 addition & 0 deletions system/lib/libc/musl/src/exit/atexit.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,5 @@ int __atexit(void (*func)(void))
// in when EXIT_RUNTIME is set to 0.
weak_alias(__atexit, atexit);
weak_alias(___cxa_atexit, __cxa_atexit);
weak_alias(___cxa_atexit, __cxa_thread_atexit_impl);
weak_alias(___cxa_finalize, __cxa_finalize);
2 changes: 2 additions & 0 deletions system/lib/libcxx/include/__config_site
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@
#define _LIBCPP_HAS_MUSL_LIBC
#define _LIBCPP_ABI_NAMESPACE __2

// Ensure we use the thread-local destructor implementation of musl.
#define HAVE___CXA_THREAD_ATEXIT_IMPL
4 changes: 0 additions & 4 deletions system/lib/libcxxabi/src/cxa_thread_atexit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,9 @@ extern "C" {
#ifdef HAVE___CXA_THREAD_ATEXIT_IMPL
return __cxa_thread_atexit_impl(dtor, obj, dso_symbol);
#else
#ifndef __EMSCRIPTEN__
// Emscripten doesn't fully support weak undefined symbols yet
// https://github.com/emscripten-core/emscripten/issues/12819
if (__cxa_thread_atexit_impl) {
return __cxa_thread_atexit_impl(dtor, obj, dso_symbol);
} else
#endif
{
// Initialize the dtors std::__libcpp_tls_key (uses __cxa_guard_*() for
// one-time initialization and __cxa_atexit() for destruction)
Expand Down

0 comments on commit df11456

Please sign in to comment.