TLS for Android
joakim at airpost.net
Fri Mar 7 16:55:04 PST 2014
So I've been looking into implementing TLS for Android/x86,
rummaging through old TLS git commits for dmd and ldc to see what
to do. It appears that Walter implemented TLS on OS X more than
four years ago by packing thread-local variables into special
segments and then unpacking them in druntime, which uses
pthread_(get|set)specific on OS X nowadays:
Since Android also provides these pthread functions for TLS,
seems like a similar approach is called for.
I notice that ldc never used this approach, depending on llvm's
built-in TLS support instead:
It seems that this also meant that TLS wasn't garbage-collected
on OSX, until David added it a little more than a year ago:
I can copy what dmd is doing on OS X Mach-O with ELF, but it's
not going to be easily transferable to ldc, which will be
necessary for Android/ARM.
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.
More information about the digitalmars-d-ldc