Thread overview
D on AArch64 CPU
May 14, 2017
Richard Delorme
May 14, 2017
Richard Delorme
May 14, 2017
kinke
May 14, 2017
Marco Leise
Aug 06, 2017
David J Kordsmeier
Aug 06, 2017
Joakim
Aug 09, 2017
Johannes Pfau
Aug 10, 2017
David J Kordsmeier
Oct 20, 2017
David J Kordsmeier
May 14, 2017
I recently bought the infamous Raspberry pi 3, which has got a cortex-a53 4 cores 1.2 Ghz CPU (Broadcom). After installing on it a 64 bit OS (a non official fedora 25), I was wondering if it was possible to install a D compiler on it.

I first try LDC 0.17.4
After modifying some phobos/runtime file to fake support of IEEE Quadruple precision floating point number available on this CPU, I got a compiler..
$ ldc2 --version
LDC - the LLVM D compiler (0.17.4):
  based on DMD v2.068.2 and LLVM 3.9.1
  Default target: aarch64-unknown-linux-gnu
  Host CPU: (unknown)
  http://dlang.org - http://wiki.dlang.org/LDC
[...]

I then try LDC 1.2.0, but fail to compile it. Whatever if I use clang (3.9) or gcc (6.3), the compilation stopped at some time, probably because of the lack of memory of the pi 3 (1 GB).

I finally try GDC, on 6.3 gcc, and with support of version 2.68 of the D language. After struggling a little on a few phobos/druntime files, I got a compiler here too:
$ gdc --version
gdc (GCC) 6.3.0
Copyright © 2016 Free Software Foundation, Inc.

Unfortunately both are unable to compile the following program:
//-----8<--------------------
import std.conv, std.stdio;

void main() {
	double pi = to!double("3.1415926");
	writeln("pi = ", pi);
}
//-----8<--------------------
opt/ldc-0.17.4/include/d/std/conv.d(295): Error: template std.conv.toImpl cannot deduce function from argument types !(double)(string), candidates are:
/opt/ldc-0.17.4/include/d/std/conv.d(361):        std.conv.toImpl(T, S)(S value) if (isImplicitlyConvertible!(S, T) && !isEnumStrToStr!(S, T) && !isNullToStr!(S, T))
/opt/ldc-0.17.4/include/d/std/conv.d(475):        std.conv.toImpl(T, S)(ref S s) if (isRawStaticArray!S)
/opt/ldc-0.17.4/include/d/std/conv.d(491):        std.conv.toImpl(T, S)(S value) if (!isImplicitlyConvertible!(S, T) && is(typeof(S.init.opCast!T()) : T) && !isExactSomeString!T && !is(typeof(T(value))))
/opt/ldc-0.17.4/include/d/std/conv.d(542):        std.conv.toImpl(T, S)(S value) if (!isImplicitlyConvertible!(S, T) && is(T == struct) && is(typeof(T(value))))
/opt/ldc-0.17.4/include/d/std/conv.d(591):        std.conv.toImpl(T, S)(S value) if (!isImplicitlyConvertible!(S, T) && is(T == class) && is(typeof(new T(value))))
/opt/ldc-0.17.4/include/d/std/conv.d(295):        ... (9 more, -v to show) ...
bug.d(4): Error: template instance std.conv.to!double.to!(string) error instantiating

and same for gdc:
/opt/gdc/lib/gcc/aarch64-unknown-linux-gnu/6.3.0/include/d/std/conv.d:295:24: erreur : template std.conv.toImpl cannot deduce function from argument types !(double)(string), candidates are:
         return toImpl!T(args);
                        ^
/opt/gdc/lib/gcc/aarch64-unknown-linux-gnu/6.3.0/include/d/std/conv.d:361:3: note : std.conv.toImpl(T, S)(S value) if (isImplicitlyConvertible!(S, T) && !isEnumStrToStr!(S, T) && !isNullToStr!(S, T))
 T toImpl(T, S)(S value)
   ^
/opt/gdc/lib/gcc/aarch64-unknown-linux-gnu/6.3.0/include/d/std/conv.d:475:3: note : std.conv.toImpl(T, S)(ref S s) if (isRawStaticArray!S)
 T toImpl(T, S)(ref S s)
   ^
/opt/gdc/lib/gcc/aarch64-unknown-linux-gnu/6.3.0/include/d/std/conv.d:491:3: note : std.conv.toImpl(T, S)(S value) if (!isImplicitlyConvertible!(S, T) && is(typeof(S.init.opCast!T()) : T) && !isExactSomeString!T && !is(typeof(T(value))))
 T toImpl(T, S)(S value)
   ^
/opt/gdc/lib/gcc/aarch64-unknown-linux-gnu/6.3.0/include/d/std/conv.d:542:3: note : std.conv.toImpl(T, S)(S value) if (!isImplicitlyConvertible!(S, T) && is(T == struct) && is(typeof(T(value))))
 T toImpl(T, S)(S value)
   ^
/opt/gdc/lib/gcc/aarch64-unknown-linux-gnu/6.3.0/include/d/std/conv.d:591:3: note : std.conv.toImpl(T, S)(S value) if (!isImplicitlyConvertible!(S, T) && is(T == class) && is(typeof(new T(value))))
 T toImpl(T, S)(S value)
   ^
/opt/gdc/lib/gcc/aarch64-unknown-linux-gnu/6.3.0/include/d/std/conv.d:295:24: note : ... (9 more, -v to show) ...
         return toImpl!T(args);
                        ^
bug.d:4:23: erreur : template instance std.conv.to!double.to!(string) error instantiating
  double pi = to!double("3.1415926");

I did not touch at std.conv nor std.stdio. On LDC, the only modification concerned math.d and gamma, missing support for 128-bit floating points.

May 14, 2017
On Sunday, 14 May 2017 at 15:05:08 UTC, Richard Delorme wrote:

I did not touch at std.conv nor std.stdio. On LDC, the only
modification concerned math.d and gammafuntion.d, missing support for 128-bit floating points. On GDC, I had to complete the errno.d file (under linux the errors are duplicated among different architectures, the aarch64 being forgotten). I also had to modify the math.d files, taking inspiration from the file from the LDC compiler.

So my questions:
 - Does anybody got a working compiler on AArch64?
 - To me the bug looks the same on both compilers, so I do not no where the fill a bug, to ldc? gdc? dmd? Or should I wait for an offcial support of this architecture?

May 14, 2017
On Sunday, 14 May 2017 at 15:11:09 UTC, Richard Delorme wrote:
> On Sunday, 14 May 2017 at 15:05:08 UTC, Richard Delorme wrote:
>
> I did not touch at std.conv nor std.stdio. On LDC, the only
> modification concerned math.d and gammafuntion.d, missing support for 128-bit floating points. On GDC, I had to complete the errno.d file (under linux the errors are duplicated among different architectures, the aarch64 being forgotten). I also had to modify the math.d files, taking inspiration from the file from the LDC compiler.
>
> So my questions:
>  - Does anybody got a working compiler on AArch64?

Almost certainly no.

>  - To me the bug looks the same on both compilers, so I do not no where the fill a bug, to ldc? gdc? dmd? Or should I wait for an offcial support of this architecture?

LDC has open AArch64 issues.
One is about quadruple-real support in Phobos (https://github.com/ldc-developers/ldc/issues/1516), with first (suspended) steps towards that goal pending upstream (as all non-DMD compilers need this at some point; https://github.com/dlang/phobos/pull/4036, https://github.com/dlang/phobos/pull/4047).
The other LDC issue concerns the ABI, especially varargs (https://github.com/ldc-developers/ldc/issues/1931).

None of the currently active LDC devs work with AArch64, so help would be greatly appreciated.
May 14, 2017
Am Sun, 14 May 2017 15:11:09 +0000
schrieb Richard Delorme <abulmo@club-internet.fr>:

> Or should I wait for an offcial support of this architecture?

You ARE the official support now. :)

-- 
Marco

August 06, 2017
On Sunday, 14 May 2017 at 15:05:08 UTC, Richard Delorme wrote:
> I recently bought the infamous Raspberry pi 3, which has got a cortex-a53 4 cores 1.2 Ghz CPU (Broadcom). After installing on it a 64 bit OS (a non official fedora 25), I was wondering if it was possible to install a D compiler on it.
>

Richard, I would be interested in working through the GDC issues further with you if you haven't completely given up on this.  I am surprised the response is that there is still no official support.  I am struggling on nearly every project I have on aarch64 with really lagging support for a wide variety of software, mainly platform support in more complex builds that does not include aarch64, and clearly the compilers all need more core level work to bring up a language and programming toolchains in a new environment.  I think Go, for example, isn't fully supported on aarch64, and Rust has the same issue.

If you are still available, I would like to share notes on the GDC 6.3 work that you started, and see if we can work through the issues with the core team.  I realize there is probably some lack of visibility into the interest that exists in the ARM-embedded area for D, but I've been using gdc on ARM since 2014.  It has been reasonably good for me, however, with the migration of many device manufacturers to AARCH64, most notably the Raspi3 and all of the hordes of Android devices hitting the market, there is a substantial installed base.

I can commit some hardware to builds also, and have some contacts in the industry around arm stuff, so it shouldn't be hard to find more dedicated gear if this helps teams like the GDC team who may not have access to gear to even run nightly builds.

Honestly, I stopped using D when I ran into this issue, was hoping, as you, that "someone should fix this".  However, that's not how good OSS works, and I'm willing to put some cycles on it if there is a way forward.  At the time, I had to make some fast decisions and opted to rewrite my code base in C.  I look forward to hearing from you and anyone else interested in working on/contributing to this topic.

Also, why I don't look at LDC further, I think RAM on the embedded devices is still pretty skimpy, Raspi3 only has 1GB ram.  It's not great for compiling with the LLVM-based things and probably run OOM.  Other devices I have only have 512MB ram.  So gcc is usually fine in these circumstances.

August 06, 2017
On Sunday, 6 August 2017 at 06:26:57 UTC, David J Kordsmeier wrote:
> Also, why I don't look at LDC further, I think RAM on the embedded devices is still pretty skimpy, Raspi3 only has 1GB ram.
>  It's not great for compiling with the LLVM-based things and probably run OOM.  Other devices I have only have 512MB ram.  So gcc is usually fine in these circumstances.

Don't know about gdc, but ldc is close (most of the listed upstream PRs are merged):

https://github.com/ldc-developers/ldc/issues/2153

As for memory, ldc can be used to cross-compile from a more capable machine, the official builds all ship with the AArch64 backend enabled now:

https://github.com/ldc-developers/ldc/releases/tag/v1.3.0

The next ldc beta will ship with a build tool that lets you easily compile or cross-compile the stdlib yourself, so you can generate the stdlib for AArch64 even if it isn't provided:

https://github.com/ldc-developers/ldc/pull/2253
August 09, 2017
Am Sun, 14 May 2017 15:05:08 +0000
schrieb Richard Delorme <abulmo@club-internet.fr>:

> I recently bought the infamous Raspberry pi 3, which has got a cortex-a53 4 cores 1.2 Ghz CPU (Broadcom). After installing on it a 64 bit OS (a non official fedora 25), I was wondering if it was possible to install a D compiler on it.
> 

> I finally try GDC, on 6.3 gcc, and with support of version 2.68
> of the D language. After struggling a little on a few
> phobos/druntime files, I got a compiler here too:
> $ gdc --version
> gdc (GCC) 6.3.0
> Copyright © 2016 Free Software Foundation, Inc.
> 

Iain recently updated GDC & phobos up to 2.074 and we have a pull request for 2.075. So don't worry about fixing old GDC phobos/druntime versions, recent gdc git branches should already have AArch64 phobos changes.

We have a test runner for AArch and GDC master here: https://buildbot.dgnu.org/#/builders/2/builds/29

There are still some failing test suite tests though and AFAICS we currently don't build phobos on that CI at all.

(We can run ARM/AArch tests without special hardware, thanks to
QEMU's user mode emulation)

-- Johannes

August 10, 2017
On Wednesday, 9 August 2017 at 08:37:53 UTC, Johannes Pfau wrote:
>
> Iain recently updated GDC & phobos up to 2.074 and we have a pull request for 2.075. So don't worry about fixing old GDC phobos/druntime versions, recent gdc git branches should already have AArch64 phobos changes.
>
> We have a test runner for AArch and GDC master here: https://buildbot.dgnu.org/#/builders/2/builds/29
>
> There are still some failing test suite tests though and AFAICS we currently don't build phobos on that CI at all.
>
> (We can run ARM/AArch tests without special hardware, thanks to
> QEMU's user mode emulation)
>
> -- Johannes

Thanks both for the reply.   I'll be interested to try both gdc and the ldc cross compiler options.
October 20, 2017
On Thursday, 10 August 2017 at 07:00:55 UTC, David J Kordsmeier wrote:
> On Wednesday, 9 August 2017 at 08:37:53 UTC, Johannes Pfau wrote:
>>
>> Iain recently updated GDC & phobos up to 2.074 and we have a pull request for 2.075. So don't worry about fixing old GDC phobos/druntime versions, recent gdc git branches should already have AArch64 phobos changes.
>>
>> We have a test runner for AArch and GDC master here: https://buildbot.dgnu.org/#/builders/2/builds/29
>>
>> There are still some failing test suite tests though and AFAICS we currently don't build phobos on that CI at all.
>>
>> (We can run ARM/AArch tests without special hardware, thanks to
>> QEMU's user mode emulation)
>>
>> -- Johannes
>
> Thanks both for the reply.   I'll be interested to try both gdc and the ldc cross compiler options.

BTW - I randomly decided to check on the latest status of builds today, to see if by chance AARCH64 is passing the buildbot tests run for GDC.  Pleased to find, that actually as of four days ago, it is passing:

https://buildbot.dgnu.org/#/builders/2/builds/45/steps/3/logs/stdio

Looking forward to jumping back into D.