digitalmars.D - why simple hello world binary is ~700KB
- Bedros Hanounik (8/8) Oct 04 2007 why when I compile this program under gdc I get 697KB of binary and when...
- Bedros Hanounik (2/17) Oct 04 2007
- Sean Kelly (5/6) Oct 04 2007 About the smallest "hello world" binary you'll get from a recent version...
- Gregor Richards (5/15) Oct 04 2007 Um, I hope you mean the /D/ stdlib? The C stdlib is never statically lin...
- Sean Kelly (7/22) Oct 04 2007 You're right. I meant the D standard library. But Phobos' use of
- =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= (9/16) Oct 05 2007 s/cstdlib/dstdlib/
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: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 RichardsOk, 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
Gregor Richards wrote:Sean Kelly wrote: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 SeanBedros Hanounik wrote: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.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.
Oct 04 2007
Sean Kelly wrote:Bedros Hanounik wrote: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...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.
Oct 05 2007