From 73c51b5c5779d0d147a35dc819f738bd9f680e42 Mon Sep 17 00:00:00 2001 From: Yonggang Luo Date: Thu, 28 Jul 2022 04:31:06 +0800 Subject: [PATCH] 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 Acked-by: Eric Engestrom Reviewed-by: Jesse Natalie Part-of: --- 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