]> git.ipfire.org Git - thirdparty/gcc.git/blame - config/tls.m4
re PR c++/30703 (ICE Segmentation fault on using OpenMP)
[thirdparty/gcc.git] / config / tls.m4
CommitLineData
e1e73e8d
TT
1dnl Check whether the target supports TLS.
2AC_DEFUN([GCC_CHECK_TLS], [
2fb31455 3 GCC_ENABLE(tls, yes, [], [Use thread-local storage])
e1e73e8d
TT
4 AC_CACHE_CHECK([whether the target supports thread-local storage],
5 have_tls, [
6 AC_RUN_IFELSE([__thread int a; int b; int main() { return a = b; }],
7 [dnl If the test case passed with dynamic linking, try again with
aad741f4
EB
8 dnl static linking, but only if static linking is supported (not
9 dnl on Solaris 10). This fails with some older Red Hat releases.
e1e73e8d
TT
10 save_LDFLAGS="$LDFLAGS"
11 LDFLAGS="-static $LDFLAGS"
aad741f4
EB
12 AC_LINK_IFELSE([int main() { return 0; }],
13 AC_RUN_IFELSE([__thread int a; int b; int main() { return a = b; }],
14 [have_tls=yes], [have_tls=no],[]),
15 [have_tls=yes])
e1e73e8d
TT
16 LDFLAGS="$save_LDFLAGS"],
17 [have_tls=no],
597c25e6
DJ
18 [AC_LINK_IFELSE([__thread int a; int b; int main() { return a = b; }],
19 [have_tls=yes], [have_tls=no])]
e1e73e8d
TT
20 )])
21 if test "$enable_tls $have_tls" = "yes yes"; then
22 AC_DEFINE(HAVE_TLS, 1,
23 [Define to 1 if the target supports thread-local storage.])
24 fi])