Skip to content

Use initial-exec TLS for glibc only, enable TLS elsewhere, auto-enable TLSDESC

Alex requested to merge alxu/mesa:tls-portability into main

It is not portable to use initial-exec TLS in dlopened libraries. glibc and FreeBSD allocate extra memory for extra initial-exec variables specifically for libGL, but other libcs including musl do not.

Keep initial-exec disabled on FreeBSD since it is apparently broken for some reason:

#966 (comment 394512) https://github.com/jbeich/mesa/commit/81dbdb15d55054242eded0eb2f32621d583c1aaf

Enable TLS on OpenBSD and Haiku based on the u_thread.h comment that emutls is better than pthread_getspecific, which seems plausible given that emutls has strictly more information to work with.

Fixes #966 (closed).

TLSDESC speeds up access to dynamic TLS. This is especially important for non-glibc targets, but is also helpful for non-initial-exec TLS variables.

The entry asm does not support TLSDESC, but it only accesses initial-exec symbols, so it is not necessary to handle that separately.

Merge request reports