www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - D on AArch64 CPU

reply Richard Delorme <abulmo club-internet.fr> writes:
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
parent reply Richard Delorme <abulmo club-internet.fr> writes:
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
next sibling parent kinke <noone nowhere.com> writes:
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
prev sibling parent Marco Leise <Marco.Leise gmx.de> writes:
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
May 14