What can be done to reduce executable size?

Sean Kelly sean at invisibleduck.org
Fri Dec 16 11:03:44 PST 2011


On Dec 15, 2011, at 7:40 PM, Andrei Alexandrescu wrote:

> On 12/10/11 9:39 AM, Bane wrote:
>> Short term and long term suggestions ? Anything we can do ? I heard it
>> is some problem with linking dead code?
>> 
>> 
>> 
>> import std.stdio;
>> int main(){
>> writefln("Hello Bloat!");
>> return 0;
>> }
>> 
>> dmd -release -O hello.d
>> 
>> On Windows:
>> v1.071 = 339 Kb
>> v2.056 = 1017 Kb
>> 
>> It looks very ugly and might distract some people.
> 
> In fact there was a low-hanging fruit, and I'm sure there are some more. This diff reduces the size of hello, world (compiled with -O -release -inline and after strip) from 700KB to 220 KB:
> 
> https://github.com/D-Programming-Language/phobos/commit/b7f42ec925fb1d64564d48ea419e201bfc65ed53
> 
> Right now an executable starts at around 218KB, which includes druntime (gc, type info, the works). Importing std.stdio and using writeln() only adds a couple of KBs.

So importing std.file adds 800K to a executable?


More information about the Digitalmars-d mailing list