fix: don't use C++ thread_local on MacOs
authorMichael Jeanson <mjeanson@efficios.com>
Thu, 9 Sep 2021 16:11:16 +0000 (12:11 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 10 Sep 2021 18:20:37 +0000 (14:20 -0400)
Recent versions of Apple's clang++ do support 'thread_local' but the
implementation generates additional helper symbols. This is a problem
when accessing an extern TLS variable in a C++ compile unit that is
provided by a C library that doesn't have those extra symbols.

Fallback to using '__thread' on MacOs.

Change-Id: I87cb5b3c9293f7bf66f7115f453b546dd793a449
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
include/urcu/tls-compat.h

index 24ef1b9a42b6dccad0f4864dc574654fffc3b60e..25cf375a23462dc53536c5da2cc4d5206466081b 100644 (file)
@@ -34,7 +34,12 @@ extern "C" {
 
 #ifdef CONFIG_RCU_TLS
 
-#if defined (__cplusplus) && (__cplusplus >= 201103L)
+/*
+ * Don't use C++ 'thread_local' on MacOs, the implementation is incompatible
+ * with C and will result in a link error when accessing an extern variable
+ * provided by the C library from C++ code.
+ */
+#if defined (__cplusplus) && (__cplusplus >= 201103L) && !defined(__APPLE__)
 # define URCU_TLS_STORAGE_CLASS        thread_local
 #elif defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)
 # define URCU_TLS_STORAGE_CLASS        _Thread_local
This page took 0.025225 seconds and 4 git commands to generate.