[Pkg-d-devel] Bug#791976: ldc: Please support ARM64

Edmund Grimley Evans edmund.grimley.evans at gmail.com
Wed May 24 22:19:18 UTC 2017


I've played a bit with trying to build this package on arm64:

sudo apt-get install ...
dpkg-source -x ldc*.dsc
cd ldc-1.1.1/
dpkg-buildpackage -b -d

The first five or so errors were compile-time "static assert" errors
in code that looks like floating-point library code. In each case I
could temporarily avoid the problem by changing the preceding
condition to something like "else static if (true)": it might give an
inaccurate result, but that is unlikely to matter for now.

The next error was much more interesting: a segfault in a program
containing D code. GDB revealed that the segfault was in glibc's
(_IO_)vsnprintf, called from D code, and from the disassembly it's
clear that there had been a calling convention mismatch: the caller (D
code) is putting the va_list (which on arm64 Linux is a 32-byte
struct) onto the stack, but the callee (C code) is expecting to find a
pointer to the struct in register X3.

I then wrote a few 6-line programs and compiled them with the D
compiler (bootstrap/b/bin/ldc2, if I recall correctly). It was clear
that this compiler is passing structs of size greater than 16 bytes in
a different way from the normal AArch64 calling convention on Linux.

This is quite a plausible bug to find here, because LDC has mostly
been used on iOS, it seems, and on iOS va_list is just a pointer,
while in general it is fairly unusual to pass a larger struct as an
argument in C, so it's quite plausible that a bug like this might not
have been discovered.

Perhaps this is the only remaining major bug. Perhaps if the calling
convention could be modified appropriately
(bootstrap/gen/abi-aarch64.cpp) then the package could be built. Of
course there must already be code somewhere in LLVM/Clang for
implementing the standard/Linux AArch64 calling convention...

(I'm assuming, of course, that D is supposed to use the same calling
convention as C throughout, rather than use one calling convention
internally and a different one for calling C code.)

The are versions of LDC upstream with higher version numbers, so one
could look at those, but I haven't seen any mention of them working
better on arm64 Linux.



More information about the Pkg-d-devel mailing list