[lto] Add test for TLS support in libstdc++-v3

Diego Novillo dnovillo@google.com
Mon Jan 26 22:22:00 GMT 2009


This patch from Ian adds tests for TLS support when building
canadian crosses.  Otherwise, libstdc++ assumes that TLS is not
available.

Patch is being tested now, will commit if it succeeds.  Ian,
could you take a quick look and make sure I didn't forget
anything from your original patch?


Thanks.  Diego.


2009-01-26  Ian Lance Taylor  <iant@google.com>

	* crossconfig.m4: Test for TLS support when using Canadian Cross.
	* configure: Regenerate.

Index: libstdc++-v3/configure
===================================================================
--- libstdc++-v3/configure	(revision 143674)
+++ libstdc++-v3/configure	(working copy)
@@ -100258,6 +100258,71 @@ _ACEOF
 
   fi
 
+
+    # If the compiler supports __thread, assume we have TLS support.
+     # Check whether --enable-tls or --disable-tls was given.
+if test "${enable_tls+set}" = set; then
+  enableval="$enable_tls"
+
+      case "$enableval" in
+       yes|no) ;;
+       *) { { echo "$as_me:$LINENO: error: Argument to enable/disable tls must be yes or no" >&5
+echo "$as_me: error: Argument to enable/disable tls must be yes or no" >&2;}
+   { (exit 1); exit 1; }; } ;;
+      esac
+
+else
+  enable_tls=yes
+fi;
+
+    echo "$as_me:$LINENO: checking whether the target supports thread-local storage" >&5
+echo $ECHO_N "checking whether the target supports thread-local storage... $ECHO_C" >&6
+if test "${have_tls+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+__thread int foo;
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"
+			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  have_tls=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+have_tls=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $have_tls" >&5
+echo "${ECHO_T}$have_tls" >&6
+    if test "$enable_tls $have_tls" = "yes yes"; then
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_TLS 1
+_ACEOF
+
+    fi
     ;;
   *-mingw32*)
     cat >>confdefs.h <<\_ACEOF
Index: libstdc++-v3/crossconfig.m4
===================================================================
--- libstdc++-v3/crossconfig.m4	(revision 143674)
+++ libstdc++-v3/crossconfig.m4	(working copy)
@@ -137,6 +137,17 @@ case "${host}" in
 
     # For iconv support.
     AM_ICONV
+
+    # If the compiler supports __thread, assume we have TLS support.
+    GCC_ENABLE(tls, yes, [], [Use thread-local storage])
+    AC_CACHE_CHECK([whether the target supports thread-local storage],
+                  have_tls,
+                  [AC_COMPILE_IFELSE([__thread int foo;], [have_tls=yes],
+                                     [have_tls=no])])
+    if test "$enable_tls $have_tls" = "yes yes"; then
+      AC_DEFINE(HAVE_TLS, 1,
+               [Define to 1 if the target supports thread-local storage.])
+    fi
     ;;
   *-mingw32*)
     AC_DEFINE(HAVE_STRTOF)



More information about the Gcc-patches mailing list