Modern C++ Lamentations
Jacob Carlborg
doob at me.com
Tue Jan 1 09:44:40 UTC 2019
On 2018-12-31 16:51, H. S. Teoh wrote:
> Then it must be doing something wrong, since running dmd with
> -L-gc-sections produces a 2 MB executable, but running ldc2 (without any
> special options) produces a 456 KB executable. Exactly the same set of
> source files. No dependencies on compiler-specific features in the code.
>
> To put this more in perspective, I re-tested this with a trivial Hello
> World program:
>
> import std.stdio;
> void main() {
> writeln("Hello world");
> }
>
> Compile this with dmd:
>
> $ dmd -L--gc-sections test.d
> $ ls -l test
> -rwxrwxr-x 1 hsteoh hsteoh 967416 Dec 31 07:43 test
>
> Compile this with ldc2:
>
> $ ldc2 test.d
> hsteoh at crystal:/tmp$ \ls -l test
> -rwxrwxr-x 1 hsteoh hsteoh 24632 Dec 31 07:44 test
>
> Note the order of magnitude difference in size, and that ldc2 achieves
> this by default, with no additional options needed.
>
> How do you make dmd produce the same (or comparable) output?
For me I get comparable output with DMD and LDC:
LDC: 932 KB
DMD (--gc-sections): 957 KB
DMD: 988 KB
This is running using Docker containers (which are running Ubuntu).
Funny thing, on macOS it's the opposite of your experience:
LDC: 5 MB
LDC (-dead_strip): 957 KB
DMD: 882 KB
DMD (-dead_strip): 361 KB
--
/Jacob Carlborg
More information about the Digitalmars-d
mailing list