Building for ARM 32-bit embedded
kinke
noone at nowhere.com
Fri Oct 11 22:31:21 UTC 2024
Hey! Seems like you (and ChatGPT) unfortunately haven't found
https://wiki.dlang.org/Cross-compiling_with_LDC, it would
hopefully have made the journey a bit easier. But I'm sure you
learned a lot along the way! :)
Just to show that cross-compiling and -linking can work without
too much effort too, with a vanilla LDC config and an already
available C cross-toolchain (admittedly cheating via `-betterC`,
which doesn't require druntime+Phobos library builds - but we
have an `ldc-build-runtime` helper to make that easier, see the
linked Wiki page), also on Ubuntu 24 (but targeting AArch64, as I
had that cross-toolchain on disk already):
```
$ cat hello.d
import core.stdc.stdio;
extern(C) void main() {
puts("Hello world");
}
$ ldc2 -mtriple=aarch64-linux-gnu -gcc=aarch64-linux-gnu-gcc
-betterC hello.d
$ file hello
hello: ELF 64-bit LSB pie executable, ARM aarch64, version 1
(SYSV), dynamically linked, interpreter
/lib/ld-linux-aarch64.so.1,
BuildID[sha1]=d78ca80f36c54f0b83565d7adcf29b6161567a2f, for
GNU/Linux 3.7.0, not stripped
```
> The documentation says that you have to jump a bit through
> hoops to get LLVM working if you're not building on the
> platform that you're targeting
Which documentation are you referring to?
More information about the digitalmars-d-ldc
mailing list