www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.ldc - D compiler for Android

reply Joakim <dlang joakim.fea.st> writes:
Something cool I was just able to do, thought I'd share, I built 
a D compiler that runs on Android/ARM... which was also built on 
Android/ARM!  That's right, no cross-compiling, even when 
building the D compiler.  Using the excellent, free Termux app 
from the Play Store 
(https://play.google.com/store/apps/details?id=com.termux&hl=en) 
and the required pre-built packages, like git, CMake, and clang, 
and compiling libconfig and my slighly tweaked llvm from source, 
I'm able to run all the same tests which were cross-compiled 
before.

In fact, the failing tests in core.internal.convert now pass when 
compiled natively, which makes sense as it was the compile-time 
portion of those tests failing, though some math-related tests in 
std.math now fail.  If I revert Kai's longdouble patch, which 
isn't needed now that it's not cross-compiling, one additional 
test in std.algorithm.sorting fails, the last one.  Other than 
that, all tests that passed before pass when natively compiled.  
I'll look into those math issues next.
Nov 29 2015
next sibling parent Parallax <patrick.php8 gmail.com> writes:
On Sunday, 29 November 2015 at 14:12:09 UTC, Joakim wrote:
 Something cool I was just able to do, thought I'd share, I 
 built a D compiler that runs on Android/ARM... which was also 
 built on Android/ARM!  That's right, no cross-compiling, even 
 when building the D compiler.  Using the excellent, free Termux 
 app from the Play Store 
 (https://play.google.com/store/apps/details?id=com.termux&hl=en) and the
required pre-built packages, like git, CMake, and clang, and compiling
libconfig and my slighly tweaked llvm from source, I'm able to run all the same
tests which were cross-compiled before.

 [...]
Great work. Can you share the binary ldc with us?
Nov 29 2015
prev sibling next sibling parent reply Parallax <patrick.php8 gmail.com> writes:
On Sunday, 29 November 2015 at 14:12:09 UTC, Joakim wrote:
 Something cool I was just able to do, thought I'd share
Great work. Can you share the binary ldc with us?
Nov 29 2015
parent reply Joakim <dlang joakim.fea.st> writes:
On Sunday, 29 November 2015 at 16:34:11 UTC, Parallax wrote:
 On Sunday, 29 November 2015 at 14:12:09 UTC, Joakim wrote:
 Something cool I was just able to do, thought I'd share
Great work. Can you share the binary ldc with us?
I didn't know if anyone would be interested, plus I need to look into supplying the necessary shared libraries. I was instead thinking about supplying a script, that would download the llvm/libconfig/ldc source, patch, and build ldc for you in the Termux app, but those with weaker CPUs would not want to run that. Of course, I'd like to get ldc into the Termux list of pre-built packages, so it's an even easier install. The Go compiler is already on there. Which interests you: binary, build script, or Termux package?
Nov 29 2015
next sibling parent reply ZombineDev <valid_email he.re> writes:
On Sunday, 29 November 2015 at 16:46:30 UTC, Joakim wrote:
 Which interests you: binary, build script, or Termux package?
I'm interested in getting LDC through Play Store! :D Seriously, thanks to the excellent work you've been doing, this may soon be a reality. When the Vulkan API is officially released I'll make a D binding for it (something along the lines of DerelictVulkan) and it would be awesome if I can make it available for Android, in addition to Linux and Windows. Perhaps such a library (along with sample apps) will be useful for you to test the Android support that you're developing. Anyway, I think that both scripts and precompiled binaries are useful. Currently I don't have any dev tools on my phone, so I would prefer something that I could easily test without external dependencies. On the other hand, when I become more interested in development for Android, I'll probably use the scripts to get the latest LDC from git. I haven't heard about Termux, so I will check it.
Nov 29 2015
parent reply Joakim <dlang joakim.fea.st> writes:
On Sunday, 29 November 2015 at 21:26:40 UTC, ZombineDev wrote:
 On Sunday, 29 November 2015 at 16:46:30 UTC, Joakim wrote:
 Which interests you: binary, build script, or Termux package?
I'm interested in getting LDC through Play Store! :D Seriously, thanks to the excellent work you've been doing, this may soon be a reality.
Would be nice to get ldc into the Termux list of pre-compiled packages.
 When the Vulkan API is officially released I'll make a D 
 binding for it (something along the lines of DerelictVulkan) 
 and it would be awesome if I can make it available for Android, 
 in addition to Linux and Windows. Perhaps such a library (along 
 with sample apps) will be useful for you to test the Android 
 support that you're developing.
That'd be great, but I don't know when I'd have a device that supports Vulkan, though they've announced it will be supported on Android eventually.
 Anyway, I think that both scripts and precompiled binaries are 
 useful. Currently I don't have any dev tools on my phone, so I 
 would prefer something that I could easily test without 
 external dependencies. On the other hand, when I become more 
 interested in development for Android, I'll probably use the 
 scripts to get the latest LDC from git. I haven't heard about 
 Termux, so I will check it.
I'll look into making my binary work on a non-Termux shell in Android, by including some necessary shared libraries like I did for the linux/x86 version.
Nov 29 2015
parent Joakim <dlang joakim.fea.st> writes:
Heh, just built a test runner apk in the Termux app on Android, 
without using the Android NDK at all and building and signing the 
apk using OpenSSL, ie without using the SDK either, since they 
don't provide an Android NDK or SDK that runs natively on 
Android. :)

The new test runner apk passes all the same tests as before, plus 
it's down to a handful of disabled tests across only four modules 
now, down from six modules before: three unit test blocks across 
two modules in druntime (really just one unit test block in 
core.thread, because the other two from rt.lifetime pass but 
cannot be run before some other tests in the same test run), a 
couple test cases in std.datetime which leak memory because of a 
custom test-only range, and two asserts and one static assert in 
std.math, all related to testing hypot.

Of course, a handful of workarounds and lower optimization flags 
were used to get here, which will have to be cleaned up going 
forward.  I'll polish those up over time.

Time to start writing up some PRs and put out some new test 
builds, including one for Android/ARM and hopefully an official 
Termux package.
Dec 19 2015
prev sibling parent Parallax <patrick.php8 gmail.com> writes:
On Sunday, 29 November 2015 at 16:46:30 UTC, Joakim wrote:
 Which interests you: binary, build script, or Termux package?
I think build script allow us to update with new version by ourself, if package or binary not update often it will be great.
Nov 29 2015
prev sibling parent Dan Olson <gorox comcast.net> writes:
Joakim <dlang joakim.fea.st> writes:

 Something cool I was just able to do, thought I'd share, I built a D
 compiler that runs on Android/ARM... which was also built on
 Android/ARM!  That's right, no cross-compiling, even when building the
 D compiler.
Very cool!
Nov 29 2015