Mercurial > hg > CbC > CbC_gcc
comparison config/tls.m4 @ 145:1830386684a0
gcc-9.2.0
author | anatofuz |
---|---|
date | Thu, 13 Feb 2020 11:34:05 +0900 |
parents | f6334be47118 |
children |
comparison
equal
deleted
inserted
replaced
131:84e7813d76e9 | 145:1830386684a0 |
---|---|
2 AC_DEFUN([GCC_CHECK_TLS], [ | 2 AC_DEFUN([GCC_CHECK_TLS], [ |
3 AC_REQUIRE([AC_CANONICAL_HOST]) | 3 AC_REQUIRE([AC_CANONICAL_HOST]) |
4 GCC_ENABLE(tls, yes, [], [Use thread-local storage]) | 4 GCC_ENABLE(tls, yes, [], [Use thread-local storage]) |
5 AC_CACHE_CHECK([whether the target supports thread-local storage], | 5 AC_CACHE_CHECK([whether the target supports thread-local storage], |
6 gcc_cv_have_tls, [ | 6 gcc_cv_have_tls, [ |
7 AC_RUN_IFELSE([__thread int a; int b; int main() { return a = b; }], | 7 AC_RUN_IFELSE([AC_LANG_SOURCE([__thread int a; int b; int main() { return a = b; }])], |
8 [dnl If the test case passed with dynamic linking, try again with | 8 [dnl If the test case passed with dynamic linking, try again with |
9 dnl static linking, but only if static linking is supported (not | 9 dnl static linking, but only if static linking is supported (not |
10 dnl on Solaris 10). This fails with some older Red Hat releases. | 10 dnl on Solaris 10). This fails with some older Red Hat releases. |
11 chktls_save_LDFLAGS="$LDFLAGS" | 11 chktls_save_LDFLAGS="$LDFLAGS" |
12 LDFLAGS="-static $LDFLAGS" | 12 LDFLAGS="-static $LDFLAGS" |
13 AC_LINK_IFELSE([int main() { return 0; }], | 13 AC_LINK_IFELSE([AC_LANG_SOURCE([int main() { return 0; }])], |
14 [AC_RUN_IFELSE([__thread int a; int b; int main() { return a = b; }], | 14 [AC_RUN_IFELSE([AC_LANG_SOURCE([__thread int a; int b; int main() { return a = b; }])], |
15 [gcc_cv_have_tls=yes], [gcc_cv_have_tls=no],[])], | 15 [gcc_cv_have_tls=yes], [gcc_cv_have_tls=no],[])], |
16 [gcc_cv_have_tls=yes]) | 16 [gcc_cv_have_tls=yes]) |
17 LDFLAGS="$chktls_save_LDFLAGS" | 17 LDFLAGS="$chktls_save_LDFLAGS" |
18 if test $gcc_cv_have_tls = yes; then | 18 if test $gcc_cv_have_tls = yes; then |
19 dnl So far, the binutils and the compiler support TLS. | 19 dnl So far, the binutils and the compiler support TLS. |
69 fi | 69 fi |
70 fi], | 70 fi], |
71 [gcc_cv_have_tls=no], | 71 [gcc_cv_have_tls=no], |
72 [dnl This is the cross-compiling case. Assume libc supports TLS if the | 72 [dnl This is the cross-compiling case. Assume libc supports TLS if the |
73 dnl binutils and the compiler do. | 73 dnl binutils and the compiler do. |
74 AC_LINK_IFELSE([__thread int a; int b; int main() { return a = b; }], | 74 AC_LINK_IFELSE([AC_LANG_SOURCE([__thread int a; int b; int main() { return a = b; }])], |
75 [chktls_save_LDFLAGS="$LDFLAGS" | 75 [chktls_save_LDFLAGS="$LDFLAGS" |
76 dnl Shared library options may depend on the host; this check | 76 dnl Shared library options may depend on the host; this check |
77 dnl is only known to be needed for GNU/Linux. | 77 dnl is only known to be needed for GNU/Linux. |
78 case $host in | 78 case $host in |
79 *-*-linux*) | 79 *-*-linux* | -*-uclinuxfdpic*) |
80 LDFLAGS="-shared -Wl,--no-undefined $LDFLAGS" | 80 LDFLAGS="-shared -Wl,--no-undefined $LDFLAGS" |
81 ;; | 81 ;; |
82 esac | 82 esac |
83 chktls_save_CFLAGS="$CFLAGS" | 83 chktls_save_CFLAGS="$CFLAGS" |
84 CFLAGS="-fPIC $CFLAGS" | 84 CFLAGS="-fPIC $CFLAGS" |
85 dnl If -shared works, test if TLS works in a shared library. | 85 dnl If -shared works, test if TLS works in a shared library. |
86 AC_LINK_IFELSE([int f() { return 0; }], | 86 AC_LINK_IFELSE([AC_LANG_SOURCE([int f() { return 0; }])], |
87 [AC_LINK_IFELSE([__thread int a; int b; int f() { return a = b; }], | 87 [AC_LINK_IFELSE([AC_LANG_SOURCE([__thread int a; int b; int f() { return a = b; }])], |
88 [gcc_cv_have_tls=yes], | 88 [gcc_cv_have_tls=yes], |
89 [gcc_cv_have_tls=no])], | 89 [gcc_cv_have_tls=no])], |
90 [gcc_cv_have_tls=yes]) | 90 [gcc_cv_have_tls=yes]) |
91 CFLAGS="$chktls_save_CFLAGS" | 91 CFLAGS="$chktls_save_CFLAGS" |
92 LDFLAGS="$chktls_save_LDFLAGS"], [gcc_cv_have_tls=no]) | 92 LDFLAGS="$chktls_save_LDFLAGS"], [gcc_cv_have_tls=no]) |
100 dnl Check whether the target assembler supports TLS. | 100 dnl Check whether the target assembler supports TLS. |
101 AC_DEFUN([GCC_CHECK_CC_TLS], [ | 101 AC_DEFUN([GCC_CHECK_CC_TLS], [ |
102 GCC_ENABLE(tls, yes, [], [Use thread-local storage]) | 102 GCC_ENABLE(tls, yes, [], [Use thread-local storage]) |
103 AC_CACHE_CHECK([whether the target assembler supports thread-local storage], | 103 AC_CACHE_CHECK([whether the target assembler supports thread-local storage], |
104 gcc_cv_have_cc_tls, [ | 104 gcc_cv_have_cc_tls, [ |
105 AC_COMPILE_IFELSE([__thread int a; int b; int main() { return a = b; }], | 105 AC_COMPILE_IFELSE([AC_LANG_SOURCE([__thread int a; int b; int main() { return a = b; }])], |
106 [gcc_cv_have_cc_tls=yes], [gcc_cv_have_cc_tls=no])] | 106 [gcc_cv_have_cc_tls=yes], [gcc_cv_have_cc_tls=no])] |
107 )]) | 107 )]) |
108 if test "$enable_tls $gcc_cv_have_cc_tls" = "yes yes"; then | 108 if test "$enable_tls $gcc_cv_have_cc_tls" = "yes yes"; then |
109 AC_DEFINE(HAVE_CC_TLS, 1, | 109 AC_DEFINE(HAVE_CC_TLS, 1, |
110 [Define to 1 if the target assembler supports thread-local storage.]) | 110 [Define to 1 if the target assembler supports thread-local storage.]) |