Hello World with GDC and LDC differs in size a lot.
kinke
noone at nowhere.com
Wed Mar 20 11:02:24 UTC 2019
On Wednesday, 20 March 2019 at 10:28:24 UTC, Rel wrote:
> I tried compiling a simple Hello World on Windows
> with the latest DMD and the latest stable LDC. DMD
> compilation results in 239kb executable and LDC
> compilation results in 500kb executable (more than
> twice bigger). -Os and -flto=full didn't do anything
> to the executable size. So I'm wondering why is that?
> I thought that LDC compiled binaries should be smaller
> due to different kinds of optimizations in LLVM.
So you're comparing LDC with DMD, not GDC as the title suggests.
DMD on Windows defaults to 32-bit code *and* the DigitalMars C
runtime, while a 64-bit LDC to 64-bit code and the MS runtime.
Which runtime (static/dynamic) depends on whether you invoke LDC
in a VS command prompt or in a naked cmd.exe, and can be tweaked
via -mscrtlib. I guess that accounts for most of the size
difference; just check your executables' DLL dependencies.
Try coupling `-flto=full` with
`-defaultlib=phobos2-ldc-lto,druntime-ldc-lto`, that probably
helps in reducing the size further.
More information about the digitalmars-d-ldc
mailing list