android: Fix ELF TLS support.

Android 29 introduced general-dynamic TLS variable support ("quick
function call to look up the location of the dynamically allocated
storage"), while Mesa on normal Linux has used initial-exec ("use some of
the startup-time fixed slots, hope for the best!").  Both would be better
options than falling all the way back to pthread_getspecific(), which is
the alternative we have pre-29.

Reviewed-by: Roman Stratiienko <r.stratiienko@gmail.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10389>
This commit is contained in:
Eric Anholt
2021-04-21 13:58:58 -07:00
committed by Marge Bot
parent 75a9cb1033
commit 0d8e431871
2 changed files with 19 additions and 2 deletions
+9
View File
@@ -77,6 +77,15 @@
*/
#ifdef _MSC_VER
#define __THREAD_INITIAL_EXEC __declspec(thread)
#elif defined(ANDROID)
/* Android 29 gained ELF TLS support, but it doesn't support initial-exec and
* it will throw:
*
* dlopen failed: TLS symbol "(null)" in dlopened
* "/vendor/lib64/egl/libEGL_mesa.so" referenced from
* "/vendor/lib64/egl/libEGL_mesa.so" using IE access model.
*/
#define __THREAD_INITIAL_EXEC __thread
#else
#define __THREAD_INITIAL_EXEC __thread __attribute__((tls_model("initial-exec")))
#endif