Toolchain with ldc and AArch64 OSX
Cecil Ward
cecil at cecilward.com
Sun Jul 9 17:30:31 UTC 2023
On Sunday, 9 July 2023 at 05:32:56 UTC, Danilo Krahn wrote:
> 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
Brilliant, much appreciated! :) I posted ages ago about the bloat
that I see where function bodies are compiled even though they
are in fact always inlined and so the original body is never
needed. The address of these functions is not taken, so no
indirect pointer calling, and the functions are all explicitly
private which I hope is like static in C? Anyway, no one is
calling them from outside the module.
More information about the Digitalmars-d-learn
mailing list