Huge output size for simple programs
Adam D. Ruppe via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri Sep 11 06:45:01 PDT 2015
On Friday, 11 September 2015 at 11:15:33 UTC, NX wrote:
> hello_world (linux executable) -> 13 MB !!!
Try running `strip yourexecutable` on all compilers, but on gdc
it should make the biggest difference. It brings debugging info
and exported symbols.
> Is this because whole GC implementation code is injected into
> executable or maybe libphobos.a being statically linked or is
> this because TypeInfo* ModuleInfo* stuff?
Static linking is a couple hundred kilobytes, some of the library
being intertwined is a couple hundred more.
C's stdlib is also large, but since it comes with the operating
system preinstalled, you don't think about it much. Ditto times
twenty for Java, .net, C++, dynamic languages, etc.
Just D's isn't preinstalled so it carries what it needs with the
executable for broadest compatibility. You could dynamically link
if you like (`-defaultlib=libphobos2.so` on dmd linux) though
then to share the application, you've gotta share that
multi-megabyte .so as well as the executable.... and deal with
dependency management, so it really makes it worse.
And if you aren't distributing it, meh, what's 400 kb on your own
hard drive?
More information about the Digitalmars-d-learn
mailing list