[PATCH] PR78968 add configure check for __cxa_thread_atexit in libc

Jonathan Wakely jwakely@redhat.com
Wed Jan 4 15:43:00 GMT 2017


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
	* config.h.in: Regenerate.
	* configure: Likewise.
	* configure.ac: Check for __cxa_thread_atexit.
	* libsupc++/atexit_thread.cc [_GLIBCXX_HAVE___CXA_THREAD_ATEXIT]:
	Don't define __cxa_thread_atexit if libc provides it.

Tested powerpc64le-linux, committed to trunk.

-------------- next part --------------
commit 82ba7b061acc7afac92646a239991e8a84e0c6dc
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Tue Jan 3 13:31:54 2017 +0000

    PR78968 add configure check for __cxa_thread_atexit in libc
    
    	PR libstdc++/78968
    	* config.h.in: Regenerate.
    	* configure: Likewise.
    	* configure.ac: Check for __cxa_thread_atexit.
    	* libsupc++/atexit_thread.cc [_GLIBCXX_HAVE___CXA_THREAD_ATEXIT]:
    	Don't define __cxa_thread_atexit if libc provides it.

diff --git a/libstdc++-v3/configure.ac b/libstdc++-v3/configure.ac
index 3d61771..f2f6e0a 100644
--- a/libstdc++-v3/configure.ac
+++ b/libstdc++-v3/configure.ac
@@ -255,7 +255,7 @@ if $GLIBCXX_IS_NATIVE; then
   # For TLS support.
   GCC_CHECK_TLS
 
-  AC_CHECK_FUNCS(__cxa_thread_atexit_impl)
+  AC_CHECK_FUNCS(__cxa_thread_atexit_impl __cxa_thread_atexit)
   AC_CHECK_FUNCS(aligned_alloc posix_memalign memalign _aligned_malloc)
 
   # For iconv support.
diff --git a/libstdc++-v3/libsupc++/atexit_thread.cc b/libstdc++-v3/libsupc++/atexit_thread.cc
index da63368..923a070 100644
--- a/libstdc++-v3/libsupc++/atexit_thread.cc
+++ b/libstdc++-v3/libsupc++/atexit_thread.cc
@@ -30,7 +30,11 @@
 #include <windows.h>
 #endif
 
-#if _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL
+#if _GLIBCXX_HAVE___CXA_THREAD_ATEXIT
+
+// Libc provides __cxa_thread_atexit definition.
+
+#elif _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL
 
 extern "C" int __cxa_thread_atexit_impl (void (*func) (void *),
 					 void *arg, void *d);


More information about the Gcc-patches mailing list