1From e915ab84fd0c02d37504f3eb1e1f3be93ea6dc37 Mon Sep 17 00:00:00 2001 2From: Michael Jeanson <mjeanson@efficios.com> 3Date: Thu, 9 Sep 2021 12:11:16 -0400 4Subject: [PATCH] fix: don't use C++ thread_local on MacOs 5 6Recent versions of Apple's clang++ do support 'thread_local' but the 7implementation generates additional helper symbols. This is a problem 8when accessing an extern TLS variable in a C++ compile unit that is 9provided by a C library that doesn't have those extra symbols. 10 11Fallback to using '__thread' on MacOs. 12 13Change-Id: I87cb5b3c9293f7bf66f7115f453b546dd793a449 14Signed-off-by: Michael Jeanson <mjeanson@efficios.com> 15Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> 16 17[Retrieved from: 18https://github.com/urcu/userspace-rcu/commit/e915ab84fd0c02d37504f3eb1e1f3be93ea6dc37] 19Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com> 20--- 21 include/urcu/tls-compat.h | 7 ++++++- 22 1 file changed, 6 insertions(+), 1 deletion(-) 23 24diff --git a/include/urcu/tls-compat.h b/include/urcu/tls-compat.h 25index 24ef1b9a..25cf375a 100644 26--- a/include/urcu/tls-compat.h 27+++ b/include/urcu/tls-compat.h 28@@ -34,7 +34,12 @@ extern "C" { 29 30 #ifdef CONFIG_RCU_TLS 31 32-#if defined (__cplusplus) && (__cplusplus >= 201103L) 33+/* 34+ * Don't use C++ 'thread_local' on MacOs, the implementation is incompatible 35+ * with C and will result in a link error when accessing an extern variable 36+ * provided by the C library from C++ code. 37+ */ 38+#if defined (__cplusplus) && (__cplusplus >= 201103L) && !defined(__APPLE__) 39 # define URCU_TLS_STORAGE_CLASS thread_local 40 #elif defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) 41 # define URCU_TLS_STORAGE_CLASS _Thread_local 42