digitalmars.D - why simple hello world binary is ~700KB
- Bedros Hanounik <2bedros NOSPAMgmail.com> Oct 04 2007
- Bedros Hanounik <2bedros NOSPAMgmail.com> Oct 04 2007
- Sean Kelly <sean f4.ca> Oct 04 2007
- Gregor Richards <Richards codu.org> Oct 04 2007
- Sean Kelly <sean f4.ca> Oct 04 2007
- =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= <afb algonet.se> Oct 05 2007
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?
Oct 04 2007
Ok, I tried dmd 2.0 with the same code and got 271KB binary out of it. still huge compared to 6.5KB generated by gcc. Bedros Hanounik Wrote: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?
Oct 04 2007
Bedros Hanounik wrote:Ok, I tried dmd 2.0 with the same code and got 271KB binary out of it. still huge compared to 6.5KB generated by gcc.
About the smallest "hello world" binary you'll get from a recent version of D is 100k. Prior to 1.0, it was possible to get a 70k "hello world" program. In every case however, cstdlib is statically linked to the app. Sean
Oct 04 2007
Sean Kelly wrote:Bedros Hanounik wrote:Ok, I tried dmd 2.0 with the same code and got 271KB binary out of it. still huge compared to 6.5KB generated by gcc.
About the smallest "hello world" binary you'll get from a recent version of D is 100k. Prior to 1.0, it was possible to get a 70k "hello world" program. In every case however, cstdlib is statically linked to the app. Sean
Um, I hope you mean the /D/ stdlib? The C stdlib is never statically linked. In fact, glibc is incredibly resistant to being statically linked in any scenario. - Gregor Richards
Oct 04 2007
Gregor Richards wrote:Sean Kelly wrote:Bedros Hanounik wrote:Ok, I tried dmd 2.0 with the same code and got 271KB binary out of it. still huge compared to 6.5KB generated by gcc.
About the smallest "hello world" binary you'll get from a recent version of D is 100k. Prior to 1.0, it was possible to get a 70k "hello world" program. In every case however, cstdlib is statically linked to the app.
Um, I hope you mean the /D/ stdlib? The C stdlib is never statically linked. In fact, glibc is incredibly resistant to being statically linked in any scenario.
You're right. I meant the D standard library. But Phobos' use of fprintf creates quite a few glibc dependencies, be they dynamically or statically resolved. I'll admit that Tango does use fprintf with DMD for coverage and profiling output as well--this is a dependency I've been a tad too lazy to eliminate :-p Sean
Oct 04 2007
Sean Kelly wrote:Bedros Hanounik wrote:Ok, I tried dmd 2.0 with the same code and got 271KB binary out of it. still huge compared to 6.5KB generated by gcc.
About the smallest "hello world" binary you'll get from a recent version of D is 100k. Prior to 1.0, it was possible to get a 70k "hello world" program. In every case however, cstdlib is statically linked to the app.
s/cstdlib/dstdlib/ Last time I tested, D program was right inbetween the C and C++ programs (assuming that static libstdc++ library was used, to make things "fair") So while it was 10x the size of C, it was still half the size of C++... Even more interesting, the Java version was 10x smaller* than C even :-) And if you want a *really* small hello world, then /bin/sh is good too. --anders * not counting the JRE, that is. it was 100x slower to start, though...
Oct 05 2007









Sean Kelly <sean f4.ca> 