summaryrefslogtreecommitdiff
path: root/config/tls.m4
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2009-07-16 23:21:15 +0000
committerJoseph Myers <joseph@codesourcery.com>2009-07-16 23:21:15 +0000
commita0b0f93b04d2c7b1d3d1f591fcf7610cf1b2ed0c (patch)
tree318c6101bfae8df71f36549407b2406c3b63fe93 /config/tls.m4
parentafeb3d7fac9407747a42b0f90f3330ecb6f9754f (diff)
downloadbinutils-a0b0f93b04d2c7b1d3d1f591fcf7610cf1b2ed0c.tar.gz
binutils-a0b0f93b04d2c7b1d3d1f591fcf7610cf1b2ed0c.tar.bz2
binutils-a0b0f93b04d2c7b1d3d1f591fcf7610cf1b2ed0c.zip
* tls.m4 (GCC_CHECK_TLS): Also test TLS in a shared library when
cross-compiling.
Diffstat (limited to 'config/tls.m4')
-rw-r--r--config/tls.m420
1 files changed, 19 insertions, 1 deletions
diff --git a/config/tls.m4 b/config/tls.m4
index acb123f6986..4648a909880 100644
--- a/config/tls.m4
+++ b/config/tls.m4
@@ -1,5 +1,6 @@
dnl Check whether the target supports TLS.
AC_DEFUN([GCC_CHECK_TLS], [
+ AC_REQUIRE([AC_CANONICAL_HOST])
GCC_ENABLE(tls, yes, [], [Use thread-local storage])
AC_CACHE_CHECK([whether the target supports thread-local storage],
gcc_cv_have_tls, [
@@ -66,7 +67,24 @@ AC_DEFUN([GCC_CHECK_TLS], [
[dnl This is the cross-compiling case. Assume libc supports TLS if the
dnl binutils and the compiler do.
AC_LINK_IFELSE([__thread int a; int b; int main() { return a = b; }],
- [gcc_cv_have_tls=yes], [gcc_cv_have_tls=no])
+ [chktls_save_LDFLAGS="$LDFLAGS"
+ dnl Shared library options may depend on the host; this check
+ dnl is only known to be needed for GNU/Linux.
+ case $host in
+ *-*-linux*)
+ LDFLAGS="-shared -Wl,--no-undefined $LDFLAGS"
+ ;;
+ esac
+ chktls_save_CFLAGS="$CFLAGS"
+ CFLAGS="-fPIC $CFLAGS"
+ dnl If -shared works, test if TLS works in a shared library.
+ AC_LINK_IFELSE([int f() { return 0; }],
+ AC_LINK_IFELSE([__thread int a; int b; int f() { return a = b; }],
+ [gcc_cv_have_tls=yes],
+ [gcc_cv_have_tls=no]),
+ [gcc_cv_have_tls=yes])
+ CFLAGS="$chktls_save_CFLAGS"
+ LDFLAGS="$chktls_save_LDFLAGS"], [gcc_cv_have_tls=no])
]
)])
if test "$enable_tls $gcc_cv_have_tls" = "yes yes"; then