Toolchain with ldc and AArch64 OSX

Danilo Krahn anon at dlang.de
Sun Jul 9 05:32:56 UTC 2023


On Saturday, 24 June 2023 at 15:16:37 UTC, Cecil Ward wrote:
> I have LDC running on an ARM Mac. If anyone else out there is 
> an LDC or GDC user, could you knock up a quick shell program to 
> compile and link a .d file to produce an executable ? found the 
> linker but these tools are all new to me and a bit of help 
> would save me a lot of trial and error and frustration as I try 
> to find docs. GDC would be great too.
>
> I have managed to achieve this before on a Raspberry Pi AArch64 
> Linux Debian where the compiler can link and generate an 
> executable just in integrated fashion in the one command. The 
> OSX tools seem rather different however.

```d
import std.stdio : writeln;

void main() {
     writeln("Hello, world!");
}
```

Compilation using LDC on macOS is just:

```
ldc2 --release --O3 main.d
```

Or some more options, to reduce executable size:

```
ldc2 --release --O3 --flto=full -fvisibility=hidden 
-defaultlib=phobos2-ldc-lto,druntime-ldc-lto -L=-dead_strip -L=-x 
-L=-S -L=-lz main.d
```

Executable size using first command: 1.3MB
Executable size using second command: 756KB


More information about the Digitalmars-d-learn mailing list