Compiler: Size of generated executable file

retard re at tard.com.invalid
Tue Jan 12 03:22:35 PST 2010


Mon, 11 Jan 2010 17:59:46 -0800, Walter Bright wrote:

> retard wrote:
>> Just looking at the executable size (when compiled with dmc, the latter
>> program is 30 kB and the first one is ~40 kB) makes it pretty clear
>> that dmc/optlink does not optimize this.
> 
> Yes, it does, if you use the -Nc (function level linking) switch when
> compiling. dmd puts functions in COMDATs by default. Some older C
> programs require that the layout of functions in memory match their
> appearance in the source file, hence dmc doesn't do that by default.
> 
> http://www.digitalmars.com/ctg/sc.html#dashCapNc

That still doesn't explain why the resulting binaries from the two 
examples have so big a difference in size. When I compile them with gcc 
4.4.3, the non-stripped non-optimized binaries are 6994 and 6427 bytes. 
Stripped and -Os optimized ones are 4504 and 4264 bytes. So the extra 
functions cost 240 bytes while your compiler generates 10 kB of 
additional data. The printf is linked in statically? Is this some windows 
related limitation?



More information about the Digitalmars-d mailing list