www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - D for Android

reply "Joakim" <dlang joakim.airpost.net> writes:
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.
May 08 2014
next sibling parent "FrankLike" <1150015857 qq.com> writes:
On Thursday, 8 May 2014 at 16:16:22 UTC, Joakim wrote:
 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.

interesting.
May 08 2014
prev sibling next sibling parent "w0rp" <devw0rp gmail.com> writes:
Awesome. I appreciate this work.
May 08 2014
prev sibling next sibling parent Etienne <etcimon gmail.com> writes:
On 2014-05-08 12:16 PM, Joakim wrote:
 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.

Thanks for this, it's more than necessary and I believe no time will have been wasted.
May 09 2014
prev sibling next sibling parent reply "Chris" <wendlec tcd.ie> writes:
On Thursday, 8 May 2014 at 16:16:22 UTC, Joakim wrote:
 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.

I can't tell you how much I appreciate this! It's wonderful. All the stuff I'm working on will have to go on smart phones and tablets sooner or later. People do ask for it, because everything is an "app" these days. Much as I appreciate all the efforts to improve D as a language (GC, library etc.), if we can't get into the mobile market, D won't take off. People think "app". "What do you think?" - "Think? Is there an app for that?"
May 09 2014
parent Xavier Bigand <flamaros.xavier gmail.com> writes:
Le 09/05/2014 15:22, Chris a écrit :
 On Thursday, 8 May 2014 at 16:16:22 UTC, Joakim wrote:
 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.

I can't tell you how much I appreciate this! It's wonderful. All the stuff I'm working on will have to go on smart phones and tablets sooner or later. People do ask for it, because everything is an "app" these days. Much as I appreciate all the efforts to improve D as a language (GC, library etc.), if we can't get into the mobile market, D won't take off. People think "app". "What do you think?" - "Think? Is there an app for that?"

May 09 2014
prev sibling next sibling parent "Szymon Gatner" <noemail gmail.com> writes:
On Thursday, 8 May 2014 at 16:16:22 UTC, Joakim wrote:

Great to hear! Much appreciated.
May 09 2014
prev sibling next sibling parent reply "Peter Alexander" <peter.alexander.au gmail.com> writes:
On Thursday, 8 May 2014 at 16:16:22 UTC, Joakim wrote:
 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.

Please do. I'd recommend adding it to the Core Development section on the wiki so that it doesn't get lost. http://wiki.dlang.org/ Thanks!
May 10 2014
parent reply Etienne <etcimon gmail.com> writes:
I've been reading on Emscripten and LDC and how they would be nice 
together, and came across this nice little library:
http://www.leaningtech.com/duetto/examples/

It's a C++ server/client framework that compiles to JS through clang => 
LLVM bytecode => ASM.js.

I'd like to point out that asm.js is a very fast subset of the 
javascript language that allows almost native speeds (3x slowdown vs C 
only) which enables games to be run in the browser without external 
dependencies.

This had me thinking of forking the Emscripten project in order to 
support the druntime / phobos library & give it access to the browser 
DOM interface, as to allow javascript web applications to be written 
fully in D (to produce interfaces like openUI5 and more).

This would have multiple advantages:
- Suitable for huge front-end development frameworks using safe typing 
and contractual programming
- Opens the door to petaFLOPS of distributed CPU power based simply on 
website visitation without affecting user experience
- Allows Javascript proprietary code to be harder to de-obfuscate or 
reverse engineer
- FAST Browser-based database engines and full runtime capabilities can 
be developed (and added as browser extensions for persistence) to be 
actively used by the server with a simple interface

And most of all, it simplifies web development.

I'm not going to instantly call for a project to be started, but I'd 
love to hear some why do's and why don'ts b/c I don't like to rely on my 
point of view alone.
May 13 2014
parent Etienne <etcimon gmail.com> writes:
wrong button ;)
May 13 2014
prev sibling next sibling parent reply "Joakim" <dlang joakim.airpost.net> writes:
On Thursday, 8 May 2014 at 16:16:22 UTC, Joakim wrote:
 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.

An update on the porting effort: I just got most modules' unit tests to pass as part of an Android/x86 app, a native "apk," ie a D shared library called from a small C wrapper, no Java required. :) All druntime/phobos modules but one, std.datetime, passed their tests on the Android/x86 command-line a couple months ago. Three of those modules segfault when run as part of the tests in an apk- core.thread, std.parallelism, and std.socket- going to look at those next. I'm guessing the first two might be related to the C wrapper also calling pthreads, as they passed on the command-line. This means most of 1. and 2. above can be crossed off the list. I'll start cleaning up my fairly simple build process and document it on the wiki, so that others can easily play with D on Android/x86. Most of the patches so far have been merged into git master, with the dmd patch above now a PR: https://github.com/D-Programming-Language/dmd/pull/3643 Only small tweaks were needed beyond that, which I'll submit as PRs in the coming days. Looking forward to help on 3., 4., and 5. above, and to seeing what others do with this new platform.
Jul 23 2014
next sibling parent Jacob Carlborg <doob me.com> writes:
On 17/08/14 20:19, Joakim wrote:

 Thanks to Jacob Carlborg and the excellent work he's done on dstep, for
 allowing me to automate translation of most of those headers and save a
 bunch of time. :) I'll submit the repo to deimos or dub, whichever is
 the better place to put it.

Cool :) I recommend dub. -- /Jacob Carlborg
Aug 18 2014
prev sibling parent Xavier Bigand <flamaros.xavier gmail.com> writes:
Le 17/08/2014 20:19, Joakim a écrit :
 On Thursday, 24 July 2014 at 01:17:44 UTC, Joakim wrote:
  I'll start cleaning up my fairly simple build process and document it
 on the wiki, so that others can easily play with D on Android/x86.

http://wiki.dlang.org/Build_DMD_for_Android It got a little long, as I don't have everything scripted yet, tried to explain all my steps, and attempted to put everything in one place, including listing the necessary android adb commands. Hopefully, some of you can help script more of it and eventually integrate D into the Android build scripts. Let me know if you have any problems with the process.
 Looking forward to help on 3., 4., and 5. above, and to seeing what
 others do with this new platform.

I finally built a native Android/x86 GUI app in D, translated from a sample C app in the Android NDK, after translating a bunch of android headers and putting them up on github: https://github.com/joakim-noah/android Thanks to Jacob Carlborg and the excellent work he's done on dstep, for allowing me to automate translation of most of those headers and save a bunch of time. :) I'll submit the repo to deimos or dub, whichever is the better place to put it. I'll keep updating the wiki with more info, how to build for the command-line and run the druntime/phobos unit tests, along with directions for future work.

It's maybe more than we need to port DQuick to Android. Really nice.
Sep 03 2014
prev sibling next sibling parent "Elvis Zhou" <elvis.x.zhou gmail.com> writes:
On Thursday, 24 July 2014 at 01:17:44 UTC, Joakim wrote:
 On Thursday, 8 May 2014 at 16:16:22 UTC, Joakim wrote:
 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.

An update on the porting effort: I just got most modules' unit tests to pass as part of an Android/x86 app, a native "apk," ie a D shared library called from a small C wrapper, no Java required. :) All druntime/phobos modules but one, std.datetime, passed their tests on the Android/x86 command-line a couple months ago. Three of those modules segfault when run as part of the tests in an apk- core.thread, std.parallelism, and std.socket- going to look at those next. I'm guessing the first two might be related to the C wrapper also calling pthreads, as they passed on the command-line. This means most of 1. and 2. above can be crossed off the list. I'll start cleaning up my fairly simple build process and document it on the wiki, so that others can easily play with D on Android/x86. Most of the patches so far have been merged into git master, with the dmd patch above now a PR: https://github.com/D-Programming-Language/dmd/pull/3643 Only small tweaks were needed beyond that, which I'll submit as PRs in the coming days. Looking forward to help on 3., 4., and 5. above, and to seeing what others do with this new platform.

Congratulations! I'll definitely give it a try when Android/Arm get ready and I think your great efforts will give D a new life as the best programming language for mobile platform.D may be another ObjC once it runs on Android/iOS stably.
Jul 23 2014
prev sibling next sibling parent "Brad Anderson" <eco gnuk.net> writes:
On Thursday, 24 July 2014 at 01:17:44 UTC, Joakim wrote:
 This means most of 1. and 2. above can be crossed off the list.
  I'll start cleaning up my fairly simple build process and 
 document it on the wiki, so that others can easily play with D 
 on Android/x86.  Most of the patches so far have been merged 
 into git master, with the dmd patch above now a PR:

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

 Only small tweaks were needed beyond that, which I'll submit as 
 PRs in the coming days.  Looking forward to help on 3., 4., and 
 5. above, and to seeing what others do with this new platform.

Very awesome news. Great work!
Jul 23 2014
prev sibling parent "Joakim" <dlang joakim.airpost.net> writes:
On Thursday, 24 July 2014 at 01:17:44 UTC, Joakim wrote:
  I'll start cleaning up my fairly simple build process and 
 document it on the wiki, so that others can easily play with D 
 on Android/x86.

wiki: http://wiki.dlang.org/Build_DMD_for_Android It got a little long, as I don't have everything scripted yet, tried to explain all my steps, and attempted to put everything in one place, including listing the necessary android adb commands. Hopefully, some of you can help script more of it and eventually integrate D into the Android build scripts. Let me know if you have any problems with the process.
 Looking forward to help on 3., 4., and 5. above, and to seeing 
 what others do with this new platform.

I finally built a native Android/x86 GUI app in D, translated from a sample C app in the Android NDK, after translating a bunch of android headers and putting them up on github: https://github.com/joakim-noah/android Thanks to Jacob Carlborg and the excellent work he's done on dstep, for allowing me to automate translation of most of those headers and save a bunch of time. :) I'll submit the repo to deimos or dub, whichever is the better place to put it. I'll keep updating the wiki with more info, how to build for the command-line and run the druntime/phobos unit tests, along with directions for future work.
Aug 17 2014