Built without any explicit flags, this results in an almost 1.2 MB program, with 156 linked D modules (./hello | wc -l), incl. Phobos modules.
When building/linking with -defaultlib=druntime-ldc, the size is almost halved, and 80 druntime modules are linked.
With DMD v2.100.1, the size is almost 900 KB, while only including 37 modules (druntime only). [Some extra intra-dependencies in LDC's druntime are to be expected.] And DMD merges druntime and Phobos to a single library.
I guess this might be caused by the linker pulling in template instantiation symbols (instantiated and also available in druntime) from Phobos object files (Phobos library listed before druntime in linker cmdline, as Phobos depends on druntime). And just as I'm filing this issue, I've retried with bfd and gold, and yep, the same 80 modules (and ~620 KB size) without explicit -defaultlib=druntime-ldc, so it's lld-specific.
Ubuntu 22, LDC v1.30.0, lld v14:
Built without any explicit flags, this results in an almost 1.2 MB program, with 156 linked D modules (
./hello | wc -l
), incl. Phobos modules.When building/linking with
-defaultlib=druntime-ldc
, the size is almost halved, and 80 druntime modules are linked.With DMD v2.100.1, the size is almost 900 KB, while only including 37 modules (druntime only). [Some extra intra-dependencies in LDC's druntime are to be expected.] And DMD merges druntime and Phobos to a single library.
I guess this might be caused by the linker pulling in template instantiation symbols (instantiated and also available in druntime) from Phobos object files (Phobos library listed before druntime in linker cmdline, as Phobos depends on druntime). And just as I'm filing this issue, I've retried with bfd and gold, and yep, the same 80 modules (and ~620 KB size) without explicit
-defaultlib=druntime-ldc
, so it's lld-specific.