Module: Mesa
Branch: main
Commit: 73c51b5c5779d0d147a35dc819f738bd9f680e42
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=73c51b5c5779d0d147a35dc819f738bd9f680e42

Author: Yonggang Luo <[email protected]>
Date:   Thu Jul 28 04:31:06 2022 +0800

util: thread_local doesn't support to be exported on OSX

The linkage error is:
Undefined symbols for architecture x86_64:
  "thread-local wrapper routine for _glapi_tls_Context", referenced from:
      __mesa_GetActiveUniform_impl in libmesa.a(main_uniform_query.cpp.o)

Fixes: a9e2c699aa3 ("util/c11: Update function u_thread_create to be c11 
conformance")
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/6756

Signed-off-by: Yonggang Luo <[email protected]>
Acked-by: Eric Engestrom <[email protected]>
Reviewed-by: Jesse Natalie <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17784>

---

 src/util/u_thread.h | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/util/u_thread.h b/src/util/u_thread.h
index 2b9deaab169..98b7978b752 100644
--- a/src/util/u_thread.h
+++ b/src/util/u_thread.h
@@ -79,7 +79,12 @@
  * expensive pthread_getspecific() or its equivalent).
  */
 #ifdef USE_ELF_TLS
-#if defined(__GLIBC__)
+#if DETECT_OS_APPLE
+/* Apple Clang emits wrappers when using thread_local that break module 
linkage,
+ * but not with __thread
+ */
+#define __THREAD_INITIAL_EXEC __thread
+#elif defined(__GLIBC__)
 #define __THREAD_INITIAL_EXEC thread_local 
__attribute__((tls_model("initial-exec")))
 #define REALLY_INITIAL_EXEC
 #else

Reply via email to