[前][次][番号順一覧][スレッド一覧]

ruby-changes:71919

From: Nobuyoshi <ko1@a...>
Date: Mon, 23 May 2022 12:13:45 +0900 (JST)
Subject: [ruby-changes:71919] 218e8bdcb0 (master): Disable usage of TLS unless available

https://git.ruby-lang.org/ruby.git/commit/?id=218e8bdcb0

From 218e8bdcb0f52e83ef295eb1661d9b1494fbbbf4 Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Sun, 22 May 2022 16:49:48 +0900
Subject: Disable usage of TLS unless available

Thread-local storage is supported since Mac OS X 10.7.  Enable TLS
only when the target version is enough.
---
 configure.ac     | 9 +++++++--
 thread_pthread.h | 2 +-
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/configure.ac b/configure.ac
index 7a820dabd6..bddb5a4f40 100644
--- a/configure.ac
+++ b/configure.ac
@@ -340,16 +340,21 @@ AS_CASE(["$host_os:$build_os"], https://github.com/ruby/ruby/blob/trunk/configure.ac#L340
 AS_CASE(["$target_os"],
 [darwin*], [
     AC_MSG_CHECKING(if minimum required OS X version is supported)
-    AC_COMPILE_IFELSE([AC_LANG_SOURCE([[@%:@include <AvailabilityMacros.h>
+    AC_PREPROC_IFELSE([AC_LANG_SOURCE([[@%:@include <AvailabilityMacros.h>
 	@%:@if MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_5
 	@%:@error pre OS X 10.5
 	[!<===== pre OS X 10.5 =====>]
 	@%:@endif
-	int __thread conftest;
 	]])],
 	[AC_MSG_RESULT(yes)],
 	[AC_MSG_RESULT(no)
 	AC_MSG_ERROR([Unsupported OS X version is required])])
+    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)])
 ])
 
 RUBY_MINGW32
diff --git a/thread_pthread.h b/thread_pthread.h
index cc1675b77c..b5314082d5 100644
--- a/thread_pthread.h
+++ b/thread_pthread.h
@@ -92,7 +92,7 @@ struct rb_thread_sched { https://github.com/ruby/ruby/blob/trunk/thread_pthread.h#L92
 
 #if __STDC_VERSION__ >= 201112
   #define RB_THREAD_LOCAL_SPECIFIER _Thread_local
-#elif defined(__GNUC__)
+#elif defined(__GNUC__) && !defined(RB_THREAD_LOCAL_SPECIFIER_IS_UNSUPPORTED)
   /* note that ICC (linux) and Clang are covered by __GNUC__ */
   #define RB_THREAD_LOCAL_SPECIFIER __thread
 #else
-- 
cgit v1.2.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]