Compiler: Size of generated executable file

Sean Kelly sean at invisibleduck.org
Sun Jan 10 11:13:46 PST 2010


Ph Wrote:

> Why a generated file is so huge?
> "Empty" program such as:
> 
> int main(char[][] args)
> {
> 
> 	return 0;
> }
> 
> compiled with dmd2 into file with size of  266268 bytes.
> Even after UPX, it's size is 87552 bytes.
> Size of this code,compiled with VS(yes,yes, C++), is 6 656 bytes.
> Compiler add's standard library  to file, am i right?
> Is there some optimization which delete unused code from file?

The minimum size of a program used to be around 70k, but TypeInfo size has ballooned since then, and I believe the weak links to ModuleInfo were eliminated because of a problem with optlink (if I remember correctly).  At the very least, every app will link in the GC because it's initialized during program startup, even if it's never called in user code.  The GC calls core.thread in druntime, so that will be pulled in as well, along with core.exception.



More information about the Digitalmars-d mailing list