Ehem, ARM

Joakim joakim at airpost.net
Sat Dec 28 14:21:43 PST 2013


> I just got a basic D program running with a patched druntime on 
> Android/x86. :) I was also able to compile and run sieve.d from 
> the D samples, after replacing std.stdio.writefln with 
> core.stdc.stdio.printf and moving the flags declaration inside 
> main.  It would segfault at "flags[]=true" if I didn't move 
> that declaration inside, so there are obviously still some 
> scoping issues, perhaps because I haven't ported all of 
> druntime to Android yet, only about halfway done.

I finished porting most of druntime to Android/x86 and have 
started trying to run the tests: I just got 31 out of 38 druntime 
modules' unit tests to pass. :)

I figured out the segfault mentioned above was because TLS is 
done differently on Android- flags[] is a global when outside 
main and thread-local by default as a result, adding a shared 
attribute makes it work again- and I was getting a lot of 
segfaults on the unit tests for the same reason.  After making 
all the simple globals in the unit tests, like cpuid in 
rt.arrayfloat/int/etc., into shared variables, only 8 modules' 
unittests segfault, one after passing.

Bionic doesn't support __thread for TLS, but it does let you use 
the pthread_key_(create|delete)/pthread_(set|get)specific APIs, 
just as druntime does on OS X.  Here's the bionic implementation:

https://github.com/android/platform_bionic/blob/master/libc/bionic/pthread_key.cpp

I haven't completely grasped TLS and how it's done on OS X yet, 
but I get the sense I'll have to modify dmd a little to get TLS 
working with bionic.  It appears that Martin and Johannes have 
looked into this before, so if you two have any feedback, let me 
know.

I'm hoping TLS is the last remaining piece for druntime to be 
finished porting to Android/x86, then I want to try Phobos, which 
I'm guessing shouldn't be as bad.


More information about the Digitalmars-d mailing list