Re: Toolchain with ldc and AArch64 OSX

2023-07-09 Thread Cecil Ward via Digitalmars-d-learn

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.


Re: Toolchain with ldc and AArch64 OSX

2023-07-09 Thread Danilo via Digitalmars-d-learn

Forgot the following flags:
`-L=-merge_zero_fill_sections -L=-no_exported_symbols 
-L=-no_eh_labels -L=-dead_strip_dylibs`


So the full command is:
```
ldc2 --release --O3 --flto=full -fvisibility=hidden 
-defaultlib=phobos2-ldc-lto,druntime-ldc-lto -L=-dead_strip -L=-x 
-L=-S -L=-lz -L=-merge_zero_fill_sections -L=-no_exported_symbols 
-L=-no_eh_labels -L=-dead_strip_dylibs main.d

```
resulting in a executable of 588KB.


Re: Toolchain with ldc and AArch64 OSX

2023-07-08 Thread Danilo Krahn via Digitalmars-d-learn

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


Re: Toolchain with ldc and AArch64 OSX

2023-06-24 Thread max haughton via Digitalmars-d-learn

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.


I’m going to try installing GDC on the Mac next, have got that 
running on the Pi too successfully.


I have ldc installed (from `brew`) on my (also arm) Mac, it works 
fine, or do you specifically want to work out which linker to 
invoke manually and so on?


I'm not sure if gdc is currently easy to obtain on arm macs. I 
think it should work fine but some packages hadn't enabled arm 
support on macos yet, last time *I* checked at least.


Toolchain with ldc and AArch64 OSX

2023-06-24 Thread Cecil Ward via Digitalmars-d-learn
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.


I’m going to try installing GDC on the Mac next, have got that 
running on the Pi too successfully.