why simple hello world binary is ~700KB

BCS ao at pathlink.com
Fri Oct 5 08:01:19 PDT 2007


Reply to Michael,

> BCS wrote:
> 
>> Reply to Bedros,
>> 
>>> why when I compile this program under gdc I get 697KB of binary and
>>> when I compile similar C code in gcc I get 6.5KB (both under Linux
>>> (GCC) 4.1.2 20070214 (  (gdc 0.24, using dmd 1.020))
>>> 
>>> import std.stdio;
>>> 
>>> int main ()
>>> {
>>> writefln("Hello World!");
>>> return 0;
>>> }
>>> how can I get small footprint binaries out of any D compiler? any
>>> difference between gdc and dmd?
>> short version: D doesn't (yet) use shared objects for the stdlib, C
>> does. At this point, that hello world has most of the stdlib in it.
>> This issue has been brought up before and something will get done
>> about it sooner or later.
>> 
> I got a near 110K 'hello,world' on my XP with D 1.015, will there any
> way to link only the used part of stdlib in future version?
> 


IIRC that is a linker issue. Tango side steps it by putting next to nothing 
in the lib and lets you compile just about everthing and then just link in 
the modules you use.





More information about the Digitalmars-d mailing list