[libcxx][libcxxabi] Use of thread_local in libcxxabi

Hi Marshall,

(Guess you are back in the sunny part of the world? ;))

So, I noted that there is a bit of code in libcxxabi (cxa_exception_storage.cpp) that uses thread_local (if explicitly enabled). I’m wondering why we don’t give this option in libcxx? It seems we always delegate all TLS stuff in libcxx to pthreads.

Thanks!

  • Asiri

There isn’t much TLS stuff in libcxx, and what is there isn’t terribly suitable for the thread_local keyword.

The biggest usage of TLS in libcxx involves TLS destructors. There are several things that a thread needs to do on exit ( notify_all_at_thread_exit, set_value_at_thread_exit, make_ready_at_thread_exit), and libcxx implements most of those things in terms of TLS destructors.

Destructors for pthread_tls is also typically more widely supported than destructors for thread_local objects.