On Tuesday, 3 March 2015 at 21:20:35 UTC, Rishub Nagpal wrote:
On Wednesday, 25 February 2015 at 08:04:02 UTC, Joakim wrote:
The remaining piece is to insert the correct function call to ___tls_get_addr when TLS variables are accessed, ie the equivalent to this patch for dmd's backend needs to be created for llvm:

https://github.com/joakim-noah/dmd/commit/477f52cffb0d8bd1a698dd33ad7e2e66d9fa62ca#diff-d427199c5cd504da634c0c42fc2b3371

I've been putting off looking into llvm's internals enough to write that for a while now. If you or anybody else knows llvm better, feel free to take it. The remaining changes needed are in this small patch for llvm:

https://gist.github.com/joakim-noah/1fb23fba1ba5b7e87e1a

Why exactly do we need to insert that TLS function call? Shouldn't Android/ARM follow the normal ELF logic? I am not really sure what Dan Olsen did here:

https://github.com/smolt/llvm/commit/42c2d7057b62454bb466abe8d146dd3c717e2cc5

Is he creating a iOS TLS ABI?


I have spent the last week doing heavy research, and I am not sure if I really understand the problem

Do you have any references or documented code I can read to better understand what exactly is going on?

I referred you to my dmd PR above with more details. The third comment there goes over it all, with additional links to articles and the TLS implementation in druntime for Android:

https://github.com/D-Programming-Language/dmd/pull/3643#issuecomment-45479519

As I said before, Android does not support native TLS, just as OS X did not when Walter wrote his TLS implementation for OS X. If you read his article, you will get the idea of what we're doing.

In any case, you don't really need to understand everything in order to add the missing piece. Similar to how llvm already adds a call to ___tls_get_addr(tls_index* ti) when compiled with PIC, we need to add a call to ___tls_get_addr(void* p) when a TLS variable is invoked to pull the right pointer offset in our Android scheme. Right now, I'm just trying it on x86, as you can see in my gist above, before attempting the same on ARM.

If you or someone else is already familiar with llvm internals, they can do this quicker than me. If not, I'll get to it eventually.

Reply via email to