Lib change leads to larger executables

kris foo at bar.com
Wed Feb 21 01:12:06 PST 2007


Walter Bright wrote:
>> It does, but increases the exe size of the first example from 180kb to 
>> 617kb!
> 
>  > 180kb is when compiled using build/rebuild/jake etc (no library) and 
> the 617kb
>  > is when using dmd+lib only. Same flags in both cases: none at all
> 
> Let's say you have a template instance, TI. It is declared in two 
> modules, M1 and M2:
> 
> -----------M1------------
> TI
> A
> -----------M2------------
> TI
> B
> -------------------------
> 
> M1 also declares A, and M2 also declares B. Now, the linker is looking 
> to resolve TI, and the first one it finds is one in M1, and so links in 
> M1. Later on, it needs to resolve B, and so links in M2. The redundant 
> TI is discarded (because it's a COMDAT).
> 
> However, suppose the program never references A, and A is a chunk of 
> code that pulls in lots of other bloat. This could make the executable 
> much larger than if, in resolving TI, it had picked M2 instead.
> 
> You can control which module containing TI will be pulled in by the 
> linker to resolve TI, by specifying that module first to lib.exe.
> 
> You can also put TI in a third module that has neither A nor B in it. 
> When compiling M1 and M2, import that third module, so TI won't be 
> generated for M1 or M2.


This is definately useful; thanks for this and for being so expediant 
with the lib change.

In this particular case I suspect something else is the cause, since (a) 
Tango is deliberately very granular (b) the map file for the huge exe is 
showing gobs of data that shouldn't exist <g>



More information about the Digitalmars-d mailing list