Thread overview
LDC 1.11.0 beta2
Jul 15, 2018
kinke
Jul 18, 2018
Dennis
Jul 18, 2018
kinke
Jul 18, 2018
Ali
Jul 18, 2018
Joakim
Jul 21, 2018
Joakim
July 15, 2018
Glad to announce the second beta for LDC 1.11.

* Based on D 2.081.1+ (today's DMD stable).
* Prebuilt packages now using LLVM 6.0.1 and including additional cross-compilation targets (MIPS, MSP430, RISC-V and WebAssembly).
* Rudimentary support for compiling & linking directly to WebAssembly. See the dedicated Wiki page [1] for how to get started.
* Some support for classes without TypeInfos, for -betterC and/or a minimal (d)runtime.

Full release log and downloads: https://github.com/ldc-developers/ldc/releases/tag/v1.11.0-beta2

Thanks to all contributors!

[1] https://wiki.dlang.org/Generating_WebAssembly_with_LDC
July 18, 2018
On Sunday, 15 July 2018 at 19:46:24 UTC, kinke wrote:
> * Rudimentary support for compiling & linking directly to WebAssembly. See the dedicated Wiki page [1] for how to get started.

This is really awesome! I tried the examples, is there any other documentation about it currently? I tried passing strings instead of numbers to the callback, but it passes the length as a number only. I doesn't work with char pointers either, I presume that's still WIP. Still, really exciting.
July 18, 2018
On Sunday, 15 July 2018 at 19:46:24 UTC, kinke wrote:
> Glad to announce the second beta for LDC 1.11.

> * Prebuilt packages now using LLVM 6.0.1 and including additional cross-compilation targets (MIPS, MSP430, RISC-V and WebAssembly).
> * Rudimentary support for compiling & linking directly to WebAssembly. See the dedicated Wiki page [1] for how to get started.

> [1] https://wiki.dlang.org/Generating_WebAssembly_with_LDC

The WebAssembly part discussed on hackernews https://news.ycombinator.com/item?id=17546063

July 18, 2018
On Wednesday, 18 July 2018 at 01:35:11 UTC, Ali wrote:
> On Sunday, 15 July 2018 at 19:46:24 UTC, kinke wrote:
>> Glad to announce the second beta for LDC 1.11.
>
>> * Prebuilt packages now using LLVM 6.0.1 and including additional cross-compilation targets (MIPS, MSP430, RISC-V and WebAssembly).
>> * Rudimentary support for compiling & linking directly to WebAssembly. See the dedicated Wiki page [1] for how to get started.
>
>> [1] https://wiki.dlang.org/Generating_WebAssembly_with_LDC
>
> The WebAssembly part discussed on hackernews https://news.ycombinator.com/item?id=17546063

Second link on the front page now.
July 18, 2018
On Wednesday, 18 July 2018 at 00:47:49 UTC, Dennis wrote:
> This is really awesome! I tried the examples, is there any other documentation about it currently? I tried passing strings instead of numbers to the callback, but it passes the length as a number only. I doesn't work with char pointers either, I presume that's still WIP. Still, really exciting.

Passing strings seems to be a PITA due to non-shared memory, see https://medium.com/@mbebenita/hello-world-in-webassembly-83951757775.
This seems specific to the current wasm browser implementations though, or at the very least not specific to D or LDC, so you can look up existing Clang/Rust/... wasm tutorials/articles for more in-depth infos.
July 21, 2018
On Sunday, 15 July 2018 at 19:46:24 UTC, kinke wrote:
> Glad to announce the second beta for LDC 1.11.
>
> * Based on D 2.081.1+ (today's DMD stable).
> * Prebuilt packages now using LLVM 6.0.1 and including additional cross-compilation targets (MIPS, MSP430, RISC-V and WebAssembly).
> * Rudimentary support for compiling & linking directly to WebAssembly. See the dedicated Wiki page [1] for how to get started.
> * Some support for classes without TypeInfos, for -betterC and/or a minimal (d)runtime.
>
> Full release log and downloads: https://github.com/ldc-developers/ldc/releases/tag/v1.11.0-beta2
>
> Thanks to all contributors!
>
> [1] https://wiki.dlang.org/Generating_WebAssembly_with_LDC

Ldc 1.11 beta 2 is also the first ldc release with a mostly working Android/AArch64 port.

In order to cross-compile the stdlib for 64-bit ARM, follow these instructions for linux/x64, adapted from the wiki page for Android/ARM (https://wiki.dlang.org/Build_D_for_Android), which require the same build tools- CMake, the Android NDK, and either Make or Ninja:

export CC=/path/to/your/android-ndk-r17b/toolchains/llvm/prebuilt/linux-x86_64/bin/clang

/path/to/your/ldc2-1.11.0-beta2-linux-x86_64/bin/ldc-build-runtime --ninja --targetPreset=Android-aarch64

Leave off the --ninja flag if you're using Make instead, and adjust the paths in all the commands, replacing /path/to/your/ with the correct paths on your system. This will download the ldc source into a temporary directory called ldc-build-runtime.tmp and attempt to cross-compile the stdlib for Android/AArch64, but fail with the following error:

std/math.d(4320): Error: static assert:  `infL > 2.00000L && (infL <= 4.00000L)` is false

Download and apply a small workaround patch for Phobos (https://gist.github.com/joakim-noah/7b997a7f8c49ff8f9d93658f78ec3cbe) to get it to work:

curl -L -O https://gist.githubusercontent.com/joakim-noah/7b997a7f8c49ff8f9d93658f78ec3cbe/raw/a7c7a2d46a679e34236f00fa9a5dee19e3b50667/compile_phobos_aarch64

git apply compile_phobos_aarch64

/path/to/your/ldc2-1.11.0-beta2-linux-x86_64/bin/ldc-build-runtime --ninja --targetPreset=Android-aarch64 --reset

You can now cross-compile command-line binaries for Android/AArch64, similar to Android/ARM as shown on the wiki:

export NDK=/path/to/your/android-ndk-r17b

/path/to/your/ldc2-1.11.0-beta2-linux-x86_64/bin/ldc2 -mtriple=aarch64-none-linux-android -L-L/path/to/your/ldc-build-runtime.tmp/lib -Xcc=--sysroot=$NDK/platforms/android-21/arch-arm64 -Xcc=-fuse-ld=bfd -Xcc=-gcc-toolchain -Xcc=$NDK/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64 -Xcc=-target -Xcc=aarch64-none-linux-android -Xcc=-fpie -Xcc=-pie sieve.d

The Phobos patch shows the remaining pieces that need to be ported, support for 128-bit real floating-point at compile-time (as that static assert tripping is likely because the 128-bit `real.max` is slightly larger than the 80-bit one and overflows to Inf) and core.stdc.stdarg.va_arg for AArch64.

You can also build the stdlib test runners, after applying this druntime patch to disable a few tests that cannot be compiled (https://gist.github.com/joakim-noah/417ffbac4d6041242d3091001595981d):

curl -L -O https://gist.githubusercontent.com/joakim-noah/417ffbac4d6041242d3091001595981d/raw/555d5c85f9055fe63d7c2c6a0493425a9c21edd2/disable_druntime_tests_aarch64

git apply disable_druntime_tests_aarch64

/path/to/your/ldc2-1.11.0-beta2-linux-x86_64/bin/ldc-build-runtime --ninja --targetPreset=Android-aarch64 --testrunners

You can then copy the druntime-test-runner and phobos2-test-runner binaries from the ldc-build-runtime.tmp directory to the Termux app on an Android/AArch64 device to see what tests fail. In my experience, all the druntime tests pass and tests only fail for 6-7 Phobos modules, mostly related to CTFE not supporting 128-bit floating point:

https://github.com/ldc-developers/ldc/issues/2153#issuecomment-379847985

The debug versions of the above test binaries (which are also built with the above command) hang when run, tripping an assert in the GC on startup, though they work fine when natively compiled with an older ldc 0.17 on an Android/AArch64 device.

If you'd like to chip in on any of these remaining issues, here's a straightforward way to get started on porting D to the most widely-deployed CPU architecture used for personal computing on the planet, with almost all iOS devices and about half of Android devices now running on AArch64, billions of devices.

I'll get those last few druntime tests ported next.