From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2140) id 05739387545E; Thu, 9 Nov 2023 01:58:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 05739387545E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1699495106; bh=eQeRq/VpjdU/KIPquSKGYU6kBMMhjBIgLKyXd2Kti/M=; h=From:To:Subject:Date:From; b=b3NYOjhmHmBq52NfqBjLqUI5EfFGq1MXH9vnDj8DIZNUV4G3agWNi8E+gMiWEqNHN +mOXZrwYx7OUa0qwXlCqJ/4GwFLp8hnWJjid8JM2wE+W+93W1c/rciO854kty/Fi3F uHsqMSImVOQ8wfmsbb4jZsZjz2BFyS+LoE8LqOcw= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Alexandre Oliva To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc(refs/users/aoliva/heads/testme)] libsupc++: try cxa_thread_atexit_impl at runtime X-Act-Checkin: gcc X-Git-Author: Alexandre Oliva X-Git-Refname: refs/users/aoliva/heads/testme X-Git-Oldrev: 5a50232e4058f48df01e1a0697d81794ab14f45b X-Git-Newrev: 9ffc2e1c2d4e214eafdb9e3a04a63485c13f01c9 Message-Id: <20231109015826.05739387545E@sourceware.org> Date: Thu, 9 Nov 2023 01:58:26 +0000 (GMT) List-Id: https://gcc.gnu.org/g:9ffc2e1c2d4e214eafdb9e3a04a63485c13f01c9 commit 9ffc2e1c2d4e214eafdb9e3a04a63485c13f01c9 Author: Alexandre Oliva Date: Wed Nov 8 20:31:23 2023 -0300 libsupc++: try cxa_thread_atexit_impl at runtime g++.dg/tls/thread_local-order2.C fails when the toolchain is built for a platform that lacks __cxa_thread_atexit_impl, even if the program is built and run using that toolchain on a (later) platform that offers __cxa_thread_atexit_impl. This patch adds runtime testing for __cxa_thread_atexit_impl on platforms that support weak symbols. for libstdc++-v3/ChangeLog * libsupc++/atexit_thread.cc [__GXX_WEAK__]: Add dynamic detection of __cxa_thread_atexit_impl. Diff: --- libstdc++-v3/libsupc++/atexit_thread.cc | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/libstdc++-v3/libsupc++/atexit_thread.cc b/libstdc++-v3/libsupc++/atexit_thread.cc index 9346d50f5da..cabd7c0a4a0 100644 --- a/libstdc++-v3/libsupc++/atexit_thread.cc +++ b/libstdc++-v3/libsupc++/atexit_thread.cc @@ -138,11 +138,24 @@ namespace { } } +#if __GXX_WEAK__ +extern "C" +int __attribute__ ((__weak__)) +__cxa_thread_atexit_impl (void (_GLIBCXX_CDTOR_CALLABI *func) (void *), + void *arg, void *d); +#endif + +// ??? We can't make it an ifunc, can we? extern "C" int __cxxabiv1::__cxa_thread_atexit (void (_GLIBCXX_CDTOR_CALLABI *dtor)(void *), - void *obj, void */*dso_handle*/) + void *obj, void *dso_handle) _GLIBCXX_NOTHROW { +#if __GXX_WEAK__ + if (__cxa_thread_atexit_impl) + return __cxa_thread_atexit_impl (dtor, obj, dso_handle); +#endif + // Do this initialization once. if (__gthread_active_p ()) {