Compiler: Size of generated executable file
grauzone
none at example.net
Sat Jan 9 10:44:07 PST 2010
Nick Sabalausky wrote:
> "Ph" <romanua at gmail.com> wrote in message
> news:hia7qc$b5k$1 at digitalmars.com...
>> 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?
>>
>
> That's not even a third of a megabyte, why does this keep getting brought up
> as an issue by so many people?
Maybe most of them don't know that it's only constant overheads.
On the other hand, template bloat can inflate binaries surprisingly
much. For example, the unlinked object file of "hello world" in D1 is
2.3 KB, while in D2, it's 36 KB. That's because writefln() is a template
in D2. (The final executable is almost twice the size as the D2 one too,
although it's questionable how much of the additional size is due to
templates.)
More information about the Digitalmars-d
mailing list