ldc 1.8

@joakim-noah joakim-noah released this Mar 18, 2018

This release adds a Teapot sample app build script for the Mac. Read how to use this release to build D apps for Android on the wiki.

ldc 1.4 official release

@joakim-noah joakim-noah released this Sep 17, 2017 · 2 commits to master since this release

This release updates the Teapot build scripts and a README link to accompany the first official ldc release that comes with built-in Android support. Read how to use this release to build D apps for Android on the wiki.

Android 1.3 beta

@joakim-noah joakim-noah released this Aug 25, 2017 · 3 commits to master since this release

A cross-compiler build of ldc 1.3, from linux/x64 to Android/ARM, is available below. There's also a native compiler package for the Termux app on Android itself (install Termux and run apt install ldc). I've ported a sample C++/OpenGL ES 2.0 app from the NDK, the Utah Teapot, complete with touch controls and JNI calls to Java code.

You can install and try out the teapot.apk below (Note: Android 5.0 or newer is required), which is almost all written in D, with only a bit of Java to show the frame rate at the top left (the Java isn't needed in this case, but is used here only to demonstrate calling through JNI). It has some standard touch controls:

  • single-finger drag to rotate the teapot
  • pinch in or out to zoom
  • multi-finger drag to move the teapot around
  • double-tap to reset, useful if you lose the teapot off-screen somewhere

Also, the app will remember the teapot's position if you switch to another app and then come back. To compile from source yourself, clone this repo, get the ldc cross-compiler below and the Android NDK, set the LDC and NDK environment variables to the paths where you unpacked those, and use the simple build-apk script to build the Teapot native shared library:

cd android/samples/Teapot
export LDC=~/ldc2-android-arm-1.3.0-beta1-linux-x86_64/ NDK=~/android-ndk-r15c/
./build-apk

Package the shared library into an apk as you would normally. If you'd like to try compiling another D app with these ldc builds, see the instructions for building D for Android on the wiki. If you'd like to build the cross-compiler from source yourself or run the tests for the standard library, there's a wiki page for that too.

Source:

Patches to ldc are available as gists, applied against the release-1.3.x branch.

llvm: small modifications to turn off TLS and add different linker relocations.

ldc cross/native: Both patches avoid building the stdlib as a shared library and the core.stdc.tgmath module, define C and linker flags for the NDK or native toolchain, and add two test-runner targets to CMake.

druntime: changes the test runner to run once and read in the names of all modules to be tested from test.list.

phobos: sets the full path of the app's local folder in std.file.tempDir() (as there is no /tmp or any other global temporary folder in Android) and works around an Android 5.0 regression when locking stdout.

android app: modifies a sample D/OpenGL ES 1.0 app from this repo to invoke the test runner from druntime.

Android 1.2 beta

@joakim-noah joakim-noah released this May 1, 2017 · 7 commits to master since this release

Two builds of ldc 1.2.1, the first a native compiler for use on Android/ARM devices and the second a cross-compiler from linux/x64, are available below. If you'd like to try compiling using these ldc builds or building the ldc cross-compiler from source yourself, follow these instructions from the wiki.

Source:

Patches to ldc are available as gists, applied against the release-1.2.x branch.

llvm: small modifications to turn off TLS and add different linker relocations.

ldc cross/native: The native patch works around the lack of std::to_string on Android, while both patches avoid compiling core.stdc.tgmath, define C and linker flags for the NDK or native toolchain, and add two test-runner targets to CMake.

druntime: changes GC signals using Ilya's upstream PR to work around an issue when running in an apk, adds a few needed math and other declarations from Bionic that were merged recently, fixes a missed pthread type that was renamed, enables checking if fibers are migrated between threads, reverts a recent upstream change in the way module info is passed from the compiler, and changes the test runner to run once and read in the names of all modules to be tested from test.list.

phobos: avoids an alignment issue with llvm optimization on ARM, uses the posix_memalign declaration from druntime, sets the full path of the app's local folder in std.file.tempDir() (as there is no /tmp or any other global temporary folder in Android), relaxes some floating-point tests, stubs out a single assert that triggers a long-standing codegen optimization issue, works around a regression when locking stdout in Android 5.0, and evades freopen not accepting a null argument in Bionic.

android app: modifies a sample D/OpenGL ES 1.0 app from this repo to invoke the test runner from druntime.

Android 1.1 beta

@joakim-noah joakim-noah released this Mar 1, 2017 · 7 commits to master since this release

Two versions of ldc 1.1.1, the first a native compiler for use on Android/ARM devices and the second a cross-compiler from linux/x64, are available below. If you'd like to try compiling using these ldc builds or building the ldc cross-compiler from source yourself, follow these instructions from the wiki.

Source:

Patches to ldc are available as gists, applied against the release-1.1.1 branch.

llvm: small modifications to turn off TLS and add different linker relocations.

ldc cross/native: While the cross-compiler patch looks huge, it mostly consists of Kai and kinke's PR to cross-compile to 64-bit reals, updated to HEAD. The native patch uses Android's builtin math functions, allows ldmd to accept a longer command-line, and works around the lack of std::to_string on Android. Other than that, both patches define the appropriate C and linker flags for the NDK or native toolchain and add two test-runner targets to CMake.

druntime cross/native: Both patches enable checking if fibers are migrated between threads, swap GC signals to work around an issue with running in an apk, turn off two passing test blocks because they cause problems for subsequent tests, revert a recent upstream change in the way module info is passed from the compiler, and change the test runner to run once and read in the names of all modules to be tested from test.list. The native patch changes GC signals using Ilya's upstream PR instead and doesn't bother avoiding a math function that isn't in older Android.

phobos cross/native: Both patches allow some tests to fail on older versions of Android, set the full path of the app's local folder in std.file.tempDir() (as there is no /tmp or any other global temporary folder in Android), and work around two issues in older versions of Android. The cross-compiler patch also swaps memalign for posix_memalign and replaces two math functions, as they weren't in older Android, but I didn't bother adding those workarounds to the native patch.

android app: modifies a sample D/OpenGL app from this repo to invoke the test runner from druntime.

Android 1.0.0 beta

@joakim-noah joakim-noah released this May 11, 2016 · 11 commits to master since this release

Ldc cross-compilers, for either a linux/x86 or linux/x64 host to an Android/ARM target, and native Android/ARM compilers are available below. If you'd like to try cross-compiling using these ldc builds or building the ldc cross-compiler from source yourself, follow these instructions from the wiki.

Source:

Patches to ldc are available as gists, applied against the release-1.0.0 branch.

llvm: small modifications to turn off TLS and add different linker relocations.

ldc: While this looks like a large patch, the vast majority consists of Kai and kinke's in-progress work to cross-compile to 64-bit reals. Other than that, it updates the C floating-point ABI for ARM, defines the appropriate C and linker flags for the NDK, and adds two test-runner targets to CMake.

druntime: swaps GC signals to work around an issue with running in an apk, turns off two passing test blocks because they cause problems for subsequent tests, reverts a recent upstream change in the way module info is passed from the compiler, and changes the test runner to run once and read in the names of all modules to be tested from test.list.

phobos: allows some tests to fail on older versions of Android, fixes an off-by-one bug in std.conv, swaps memalign for posix_memalign as it wasn't in older Android, sets the full path of the app's local folder in std.file.tempDir() (as there is no /tmp or any other global temporary folder in Android), replaces two math functions for older Android, and works around two issues in older versions of Android.

android app: modifies the sample D/OpenGL app from this repo to invoke the test runner from druntime.

Android test runners and compilers

@joakim-noah joakim-noah released this Jan 17, 2016 · 15 commits to master since this release

Two test runners derived from D 2.068.2 are provided below, an Android app, test-runner.apk, and a command-line binary, test-runner (available in zip or xz compressed format), along with a list of tests to run, test.list, which can be modified to remove certain tests if they hang. Ldc cross-compilers, for either a linux/x86 or linux/x64 host to an Android/ARM target, and a native Android/ARM compiler are also available.

Please run the tests and report your results in this thread in the ldc forum.

An ARMv7 device or newer is required, the runner won't work with much older ARMv5 and ARMv6 devices. Android 2.3 Gingerbread or above is required, though these tests haven't been run on any Android older than 4.1 Jelly Bean.

If you'd like to try cross-compiling using the ldc builds for linux provided below or building the ldc cross-compiler and test runner from source yourself, follow these instructions from the wiki using the patches linked below.

Instructions:

The test apk is an Android app, so it's the recommended test runner. However, it requires installing this app from outside the official Play Store and doesn't provide info about skipped tests or other issues, so if you don't like either, you can try the command-line runner.

Note: The apk will append test output to a file named /sdcard/test.log, so if you happen to have a file with that name already, move it before running these tests.
  • Running the apk

  1. Download test-runner.apk and test.list from below to your Android device.
  2. Move test.list to the /sdcard/ directory, which is where the apk will look for it.
  3. Go to Settings->Security and allow installation of apps from unknown sources.
  4. Open your Android file manager, navigate to where you saved the apk, and install it.
  5. Go to your installed apps and run the app named NativeActivity.
  6. After starting the app, the screen will stay dark for 30 seconds to a minute while the tests run, after which you should try touching the screen. If you get a message asking if you want to close the app before a minute is up, hit Wait.
  7. If the screen starts flashing a bunch of colors after a touch, that means all the tests ran. If it stays dark, that means some test likely hung. You might want to wait a little longer and if it doesn't respond to a touch after a longer wait either, the app likely hung so you can close it.
  8. Check the file /sdcard/test.log to see which tests ran and which passed or failed. All the tests should pass and the last module that passes should be std.internal.cstring.
  9. If the app hung, you can find the last test that ran in test.log. Try removing the test after that from test.list, run the apk again, and see if it makes a difference. You can also turn on USB debugging and use adb logcat to see the test results as the app runs, or a stack trace if it crashed.
  • Running from the command-line

  1. Download test.list and either test-runner.zip or test-runner.tar.xz and decompress the latter to get a binary called test-runner. Move both to your Android device.
  2. Install a terminal or SSH server app. After starting the app, typing cd will take you to a directory where you can run command-line binaries.
  3. Copy test-runner and test.list to the same directory and invoke the runner with ./test-runner.
  4. All test output will be written to the screen, examine it for any skipped tests or failures. If the runner hangs, try removing that test from test.list and running again.

Source:

Patches to ldc are available as gists, applied against the master 2.068 branch of ldc. Some of it has been upstreamed already, the rest will be cleaned up and merged soon.

llvm: small modifications to turn off TLS and add different linker relocations.

ldc: While this looks like a large patch, the vast majority consists of Kai's changes for cross-compiling to 64-bit long doubles, which was all taken from these three commits from Kai's longdouble2 branch, with patches from Dan too. Other than that, it adds some predefined versions for Android, adjusts how structs are passed by value for ARM, brackets TLS symbols similarly to dmd, and adds two test-runner targets to CMake.

druntime: turns off three test blocks across two modules, adds fixes for Android/ARM and to run in an apk, modifies TLS support for Android/ARM, reverts manual allocation of exceptions because it interferes with the current codegen for emulated TLS, and changes the test runner to run once and read in the names of all modules to be tested from test.list.

phobos: allows some tests to fail on older versions of Android, adds support for reading Android's concatenated timezone data, disables a few test cases across two modules, backports an upstreamed patch to centralize where test files are created, sets the full path of the app's local folder in std.file.tempDir() (as there is no /tmp or any other global temporary folder in Android), adds some Android fixes, and works around two issues in older versions of Android.

android app: modifies the sample D/OpenGL app from this repo to invoke the test runner from druntime.

Android test runner

@joakim-noah joakim-noah released this Oct 31, 2015 · 16 commits to master since this release

Two test runners derived from D 2.068.2 are provided below, an Android app, NativeActivity-debug.apk, and a command-line binary, test-runner, along with a list of tests to run, test.list, which can be modified to not run certain tests if they hang. Ldc cross-compilers, for either a linux/x86 or linux/x64 host to an Android/ARM target, are also available.

Please run the tests and report your results in this thread in the ldc forum.

An ARMv7 device or newer is required, the runner won't work with much older ARMv5 and ARMv6 devices. Android 2.3 Gingerbread or above is required, though these tests haven't been run on any Android older than 4.1 Jelly Bean.

If you'd like to try cross-compiling using the ldc builds for linux provided below or building the ldc cross-compiler and test runner from source yourself, follow these instructions from the wiki using the patches linked below.

Instructions:

The test apk is an Android app, so it's the recommended test runner. However, it requires installing this app from outside the official Play Store and doesn't provide info about skipped tests or other issues, so if you don't like either, you can try the command-line runner.

Note: The apk will append test output to a file named /sdcard/test.log, so if you happen to have a file with that name already, move it before running these tests.
  • Running the apk

  1. Download NativeActivity-debug.apk and test.list from below to your Android device.
  2. Go to Settings->Security and allow installation of apps from unknown sources.
  3. Open your Android file manager, navigate to where you saved the apk, and install it.
  4. Move test.list to the /sdcard/ directory, which is where the apk will look for it.
  5. Go to your installed apps and run the app named NativeActivity.
  6. After starting the app, the screen will stay dark for 30 seconds to a minute while the tests run, after which you should try touching the screen. If you get a message asking if you want to close the app before a minute is up, hit Wait.
  7. If the screen starts flashing a bunch of colors after a touch, that means all the tests ran. If it stays dark, that means some test likely hung. You might want to wait a little longer and if it doesn't respond to a touch after a longer wait either, the app likely hung so you can close it.
  8. Check the file /sdcard/test.log to see which tests ran and which passed or failed. All the tests should pass and the last module that passes should be std.internal.math.gammafunction.
  9. If the app hung, you can find the last test that ran in test.log. Try removing the test after that from test.list, run the apk again, and see if it makes a difference. You can also turn on USB debugging and use adb logcat to see the test results as the app runs, or a stack trace if it crashed.
  • Running from the command-line

  1. Download test-runner and test.list from below to your Android device.
  2. Install a terminal or SSH server app. After starting the app, typing cd will take you to a directory where you can run command-line binaries.
  3. Copy test-runner and test.list to the same directory and invoke the runner with ./test-runner.
  4. All test output will be written to the screen, examine it for any skipped tests or failures. If the runner hangs, try removing that test from test.list and running again.

Source:

Patches to ldc are available as gists, applied against the master 2.068 branch of ldc. Some of it has been upstreamed already, the rest will be cleaned up and merged soon.

llvm: small modifications to add different linker relocations and turn off TLS and one optimization.

ldc: While this looks like a large patch, the vast majority is support for cross-compiling to 64-bit long doubles, which was all taken from these three commits from Kai's longdouble2 branch, with patches from Dan too. Other than that, it adds some predefined versions for Android, adjusts how structs are passed by value for ARM, brackets TLS symbols similarly to dmd, and adds a test-runner target for CMake.

druntime: turns off a handful of tests in three modules, adds fixes for Android/ARM and to run in an apk, modifies TLS support for Android/ARM, and changes the test runner to run once and read all tests to be run from test.list.

phobos: allows some tests to fail on older versions of Android, adds support for reading Android's concatenated timezone data, disables a few mostly math-related tests across three modules, backports an upstreamed patch to centralize where test files are created, hacks in the full path of the app's local folder into std.file.getcwd() (as there is no /tmp or any other global temporary folder in Android), adds some Android fixes, and disables one new math function.

android app: modifies the sample D/OpenGL app from this repo to invoke the test runner from druntime.

Pre-release

Android test runner apk

@joakim-noah joakim-noah released this Jul 30, 2015 · 16 commits to master since this release

This Android/ARM app will run most of the unit tests for druntime and phobos that are currently working. It requires Android 5 Lollipop, because druntime calls one function, dl_iterate_phdr, that is not in earlier versions of bionic/ARM.

Note: It will append the test output to a file named /sdcard/test.log, so if you happen to have a file with that name already, move it before running these tests.
Instructions:

Download NativeActivity-debug.apk below to your Android 5 device, then go to Settings->Security and allow installation of apps from unknown sources. Open your Android file manager, navigate to where you saved the apk, and install it. After starting the app, the screen will stay dark for 30 seconds to a minute, after which you should try touching the screen. If it starts flashing a bunch of colors after a touch, that means all tests ran. If it stays dark, that means some test likely hung: you might want to wait a little longer and close the app, if it doesn't respond to a touch after a longer wait either.

Check the file /sdcard/test.log to see which tests ran and which passed or failed. All modules' tests but std.datetime should pass and the last module's tests run should be std.socket. You can also turn on USB debugging and use adb logcat to see the test results as the app runs.

Source:

I've updated the patches as github gists for now, applied against the merge-2.067 branch of ldc. Some have been upstreamed already, the rest will be once it's cleaned up. I also had to write a couple small build scripts, mostly for linking, which I'll put online upon request, as those will soon be thrown out and ldc's cmake build system used instead.

llvm: small modifications to turn off TLS and add different linker relocations.

ldc: while it looks big, the vast majority is support for cross-compiling to 64-bit long doubles, which was all taken from these three commits from Kai's longdouble2 branch, with patches from Dan too.

druntime: much of this patch was upstreamed months ago. The rest is TLS support for Android/ARM, some ARM fixes, and a few patches necessary to run the tests as part of an Android app/apk, which means compiling as a shared library.

phobos: hacks in the full path of the app's local folder into modules that need to create a local file for testing (as there is no /tmp or any other global temporary folder in Android), adds some Android fixes that have largely been upstreamed, and disables a handful of math-related tests.

android app: modifies the sample D/OpenGL app from this repo to invoke the test runner from druntime.