TLS for Android

David Nadlinger code at
Sat Mar 8 06:25:24 PST 2014

On 03/08/2014 01:55 AM, Joakim wrote:
> Do you have any advice on how to pull this off with ldc?  Should I be
> going the dmd route and packing the TLS myself?  Does llvm provide good
> support for this?
> Or is there some other llvm TLS shortcut I can use?  I tried to see if
> llvm just has some thread-local implementation that automatically uses
> pthread_setspecific, but didn't find anything.

LLVM does support putting variables into custom sections, and you can 
more or less get away with the DMD bracketing approach (see e.g. the new 
ModuleInfo discovery functionality I implemented for Linux, which is the 
same as DMD's druntime uses). However, there is a catch: Due to what I 
can only imagine is a bug, LLVM does not support emitting a symbol both 
into a custom section and with weak linkage. Thus, you might be in for a 
round of LLVM hacking either way, even though it will likely involve 
much less when going the DMD route.

However, there is a third options which might be worth investigating, 
namely re-implementing at least parts of the necessary runtime linker 
features in druntime and continuing to use the same scheme as on GNU 
Linux/x86. This depends on %gs not being used in another way, etc. though.


More information about the digitalmars-d-ldc mailing list