diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2023-04-05 23:48:50 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2023-04-07 13:42:48 +0900 |
commit | f99af439805fe51b38aa1cf79f9c657f857510f4 (patch) | |
tree | c7fb3f820a4031b16d820e474ecb5058d91f152f /configure.ac | |
parent | cc0b8c47bfb108cb4ad6d5148669c9fac54b6ac4 (diff) |
[Bug#19161] Detect thread local storage specifier
Checking by `__STDC_VERSION__` is unreliable because old gcc 4.8
supports `-std=gnu11` option but does not implement `_Thread_local`.
Check the implementation directly instead.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/7669
Diffstat (limited to 'configure.ac')
-rw-r--r-- | configure.ac | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/configure.ac b/configure.ac index a0fadaa856..4bc9b60159 100644 --- a/configure.ac +++ b/configure.ac @@ -385,13 +385,6 @@ AS_IF([test "$GCC" = yes], [ AS_IF([test "$gcc_major" -lt 4], [ AC_MSG_ERROR([too old GCC: $gcc_major.$gcc_minor]) ]) - - AC_CACHE_CHECK([if thread-local storage is supported], [rb_cv_tls_supported], - [AC_LINK_IFELSE([AC_LANG_PROGRAM([[int __thread conftest;]])], - [rb_cv_tls_supported=yes], - [rb_cv_tls_supported=no])]) - AS_IF([test x"$rb_cv_tls_supported" != xyes], - [AC_DEFINE(RB_THREAD_LOCAL_SPECIFIER_IS_UNSUPPORTED)]) ], [ linker_flag= ]) @@ -2750,6 +2743,22 @@ AS_IF([test "$THREAD_MODEL" = pthread], [ AC_DEFINE_UNQUOTED(SET_ANOTHER_THREAD_NAME(thid,name), $set_another_thread_name) ]) ]) + + AC_CACHE_CHECK([for thread-local storage sepcifier], [rb_cv_tls_specifier], + rb_cv_tls_specifier=none + RUBY_WERROR_FLAG([ + for attr in \ + _Thread_local \ + __thread \ + ; do + AC_LINK_IFELSE([AC_LANG_PROGRAM([[$attr int conftest;]])], + [rb_cv_tls_specifier=$attr; break]) + done + ]) + ) + AS_IF([test x"${rb_cv_tls_specifier}" != xnone], + [AC_DEFINE_UNQUOTED(RB_THREAD_LOCAL_SPECIFIER, ${rb_cv_tls_specifier})] + ) ]) AS_IF([test x"$ac_cv_header_ucontext_h" = xno], [ |