www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - File size of exe: DMD vs LDC

reply Chris <wendlec tcd.ie> writes:
I have a program whose size is 3.2 MB when compiled with LDC, and 
6.3 MB when compiled with DMD. Both are release builds. That's 
almost twice as big.
May 09 2016
next sibling parent Vladimir Panteleev <thecybershadow.lists gmail.com> writes:
On Monday, 9 May 2016 at 10:58:12 UTC, Chris wrote:
 I have a program whose size is 3.2 MB when compiled with LDC, 
 and 6.3 MB when compiled with DMD. Both are release builds. 
 That's almost twice as big.
You can upload the .map files to http://thecybershadow.net/d/mapview/ to get a visualization of what's taking how much space.
May 09 2016
prev sibling next sibling parent reply Jacob Carlborg <doob me.com> writes:
On 2016-05-09 12:58, Chris wrote:
 I have a program whose size is 3.2 MB when compiled with LDC, and 6.3 MB
 when compiled with DMD. Both are release builds. That's almost twice as
 big.
LDC can strip sections which DMD cannot. -- /Jacob Carlborg
May 09 2016
parent reply Walter Bright <newshound2 digitalmars.com> writes:
On 5/9/2016 5:24 AM, Jacob Carlborg wrote:
 LDC can strip sections which DMD cannot.
Why not?
May 09 2016
parent reply Dicebot <public dicebot.lv> writes:
On Monday, 9 May 2016 at 13:48:50 UTC, Walter Bright wrote:
 On 5/9/2016 5:24 AM, Jacob Carlborg wrote:
 LDC can strip sections which DMD cannot.
Why not?
AFAIR, because of how ModuleInfo/TypeInfo is emitted which makes linker never collect sections because they are referenced at least from there. LDC was intentionally modified to change code gen in that regard to make --gc-sections work - David will surely tell more :)
May 09 2016
parent reply David Nadlinger <code klickverbot.at> writes:
On Monday, 9 May 2016 at 13:53:45 UTC, Dicebot wrote:
 On Monday, 9 May 2016 at 13:48:50 UTC, Walter Bright wrote:
 On 5/9/2016 5:24 AM, Jacob Carlborg wrote:
 LDC can strip sections which DMD cannot.
Why not?
AFAIR, because of how ModuleInfo/TypeInfo is emitted which makes linker never collect sections because they are referenced at least from there. LDC was intentionally modified to change code gen in that regard to make --gc-sections work - David will surely tell more :)
It's something along those lines. What is certainly true is that I spent quite some time trying to work around "interesting" linker behaviour to make this work. You can find more details on my solution at https://issues.dlang.org/show_bug.cgi?id=879. I haven't looked at DMD's related codegen in a while, so I don't know what exactly remains to be done there. — David
May 09 2016
parent reply Walter Bright <newshound2 digitalmars.com> writes:
On 5/9/2016 11:48 AM, David Nadlinger wrote:
 AFAIR, because of how ModuleInfo/TypeInfo is emitted which makes linker never
 collect sections because they are referenced at least from there. LDC was
 intentionally modified to change code gen in that regard to make --gc-sections
 work - David will surely tell more :)
It's something along those lines. What is certainly true is that I spent quite some time trying to work around "interesting" linker behaviour to make this work. You can find more details on my solution at https://issues.dlang.org/show_bug.cgi?id=879. I haven't looked at DMD's related codegen in a while, so I don't know what exactly remains to be done there. — David
Thanks. At least the deh sections are a non-issue now that DMD generates Dwarf exception handling tables.
May 09 2016
parent Chris <wendlec tcd.ie> writes:
On Monday, 9 May 2016 at 20:06:55 UTC, Walter Bright wrote:
 On 5/9/2016 11:48 AM, David Nadlinger wrote:

 Thanks. At least the deh sections are a non-issue now that DMD 
 generates Dwarf exception handling tables.
I've compiled the same code[1] with dmd v2.071.0 (release build) and now the size has grown to 7.1 MB. It's 7.0 MB with dmd v2.070 (release build). [1] Same, except for the changes I had to make to adapt it to the new import system (`static import` etc.)
May 12 2016
prev sibling parent reply Nick Sabalausky <SeeWebsiteToContactMe semitwist.com> writes:
On 05/09/2016 06:58 AM, Chris wrote:
 I have a program whose size is 3.2 MB when compiled with LDC, and 6.3 MB
 when compiled with DMD. Both are release builds. That's almost twice as
 big.
FWIW, keep in mind that doesn't necessarily imply the same 2x scale will still hold for larger programs. Could be as much as 2x, could be as little as a constant +3MB.
May 12 2016
parent reply David Nadlinger <code klickverbot.at> writes:
On Thursday, 12 May 2016 at 17:27:37 UTC, Nick Sabalausky wrote:
 FWIW, keep in mind that doesn't necessarily imply the same 2x 
 scale will still hold for larger programs. Could be as much as 
 2x, could be as little as a constant +3MB.
In typical programs, it is indeed a factor, and can be considerably more than 2x too. I've seen 400 MiB vs. 1.3 GiB, for example. — David
May 12 2016
parent David Nadlinger <code klickverbot.at> writes:
On Thursday, 12 May 2016 at 21:35:12 UTC, David Nadlinger wrote:
 In typical programs it is indeed a factor, and can be 
 considerably more than 2x too. […]
To expand on that a bit, if you write template- and CTFE-less programs with no unused code and no inlined functions, you would obviously expect much less gain from linker-level dead code/data elimination than for a typical D2 program. — David
May 12 2016