This is the mail archive of the mailing list for the libstdc++ project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] PR78968 add configure check for __cxa_thread_atexit in libc

On 06/01/17 17:06 +0000, Jonathan Wakely wrote:
On 04/01/17 15:42 +0000, Jonathan Wakely wrote:
FreeBSD 11 adds __cxa_thread_atexit to libc, so we should use that
instead of defining our own inferior version. This also avoids
multiple definitions of the symbol.

	PR libstdc++/78968
	* Regenerate.
	* configure: Likewise.
	* Check for __cxa_thread_atexit.
	Don't define __cxa_thread_atexit if libc provides it.

Tested powerpc64le-linux, committed to trunk.

This adds the check for freebsd cross-compilers. Tested by building
x86_64-unknown-freebsd11.0 on x86_64-uknown-linux-gnu.

Committed to trunk.

And this adjusts the testsuite so that the test which depends on
correct thread_local destruction order runs for FreeBSD.

Tested x86_64-linux and x86_64-freebsd11. Committed to trunk.

commit 9d592302e39c785eb27beb982768816ad60d6bc8
Author: Jonathan Wakely <>
Date:   Mon Jan 9 11:42:21 2017 +0000

    Define testsuite macro for correct thread_local destructors
    	* testsuite/30_threads/condition_variable/members/ Use new macro
    	to detect correct thread_local destructors.
    	* testsuite/util/testsuite_hooks.h (CORRECT_THREAD_LOCAL_DTORS):

diff --git a/libstdc++-v3/testsuite/30_threads/condition_variable/members/ b/libstdc++-v3/testsuite/30_threads/condition_variable/members/
index 3f6885d..cedb2ab 100644
--- a/libstdc++-v3/testsuite/30_threads/condition_variable/members/
+++ b/libstdc++-v3/testsuite/30_threads/condition_variable/members/
@@ -24,6 +24,7 @@
 #include <condition_variable>
 #include <thread>
 #include <mutex>
+#include <testsuite_hooks.h>
 std::mutex mx;
 std::condition_variable cv;
@@ -40,12 +41,12 @@ void func()
   std::unique_lock<std::mutex> lock{mx};
   std::notify_all_at_thread_exit(cv, std::move(lock));
   // Correct order of thread_local destruction needs __cxa_thread_atexit_impl
-  static thread_local Inc inc;
-  Inc inc;
+  // or similar support from libc.
+  static thread_local
+  Inc inc;
 int main()
diff --git a/libstdc++-v3/testsuite/util/testsuite_hooks.h b/libstdc++-v3/testsuite/util/testsuite_hooks.h
index 6baff15..6f064a4 100644
--- a/libstdc++-v3/testsuite/util/testsuite_hooks.h
+++ b/libstdc++-v3/testsuite/util/testsuite_hooks.h
@@ -81,6 +81,12 @@
 # define THROW(X) noexcept(false)
+// Correct order of thread_local destruction needs __cxa_thread_atexit_impl
+// or similar support from libc.
 namespace __gnu_test
   // All macros are defined in GLIBCXX_CONFIGURE_TESTSUITE and imported

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]