D for Android

Joakim via Digitalmars-d digitalmars-d at puremagic.com
Thu May 8 09:16:20 PDT 2014


Well, Android/x86 for now.  I've been plugging away at getting D 
running on Android/x86 and got all of the druntime modules' unit 
tests and 37 of 50 phobos modules' unit tests to pass. I had to 
hack dmd into producing something like packed TLS for ELF, my 
patch is online here:

http://164.138.25.188/dmd/packed_tls_for_elf.patch

I simply turned off all TLS flags for ELF and spliced in the 
el_picvar patch from OS X to call ___tls_get_addr.  Somebody who 
knows dmd better than me should verify to make sure this is right.

I've also put online preliminary pulls for druntime and phobos:

https://github.com/D-Programming-Language/druntime/pull/784
https://github.com/D-Programming-Language/phobos/pull/2150

Now that a significant chunk of D is working on Android/x86, I'm 
looking for others to pitch in.  We really need to get D on 
mobile, and Android/x86 is an ideal place to start.  Dan Olson 
has done some nice work getting D on iOS using ldc, I'm sure he 
could use help too:

http://forum.dlang.org/thread/m2txc2kqxv.fsf@comcast.net
http://forum.dlang.org/thread/m2d2h15ao3.fsf@comcast.net

Stuff remaining to be done:

1. Fix all phobos unit tests.  Those who know the failing modules 
better would be best equipped to get them to work.

2. I tried creating an Android app, ie an apk, which is really 
just a shared library called from the Dalvik JVM, as opposed to 
the standalone executables I've been running from the Android 
command line so far.  The apk enters the D code and then 
segfaults in the new TLS support, I'll debug that next.

3. Use ldc/gdc to build for Android/ARM.

4. Start translating various headers on Android so they can be 
called from D, ie EGL, OpenGL ES, sensors, etc.

5. Integrate the D compilers into the existing Makefile-based 
build system of the Android NDK.  Right now, I extract the 
necessary compiler and linker commands and run them by hand when 
necessary.

All you need to get going is to download the latest Android NDK 
(http://developer.android.com/tools/sdk/ndk/index.html) and run 
Android/x86 (http://www.android-x86.org/, I recommend the 4.3 
build) in a VM.  I'll put up some basic setup and build 
instructions if someone is interested.


More information about the Digitalmars-d mailing list