Huge output size for simple programs

NX via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Sep 11 07:29:59 PDT 2015


On Friday, 11 September 2015 at 13:45:03 UTC, Adam D. Ruppe wrote:
> 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)

So I did some testing:

# dmd -defaultlib=libphobos2.so "app.d"
Source:
void main()
{
	main();
}
Result:
app.o -> 5.3 KB
app (exe) -> 9.4 KB


# dmd -defaultlib=libphobos2.so "app.d"
Source:
import std.stdio, std.conv, core.stdc.stdlib, std.typecons, 
std.parallelism;
void main()
{
	main();
}
Result:
app.o -> 6 KB
app (exe) -> 13.7 KB


Just because I imported some stuff from a dynamically linked 
library makes output weirdly big. Try it yourself, change the 
number of imported modules and output size will significantly 
change.

One question: Why?


More information about the Digitalmars-d-learn mailing list