compiled code file size

Duke Normandin dukeofperl at ml1.net
Fri Sep 20 10:32:36 PDT 2013


On Friday, 20-Sep-13 10:49 AM, Dicebot wrote:
> On Friday, 20 September 2013 at 16:20:34 UTC, Duke Normandin wrote:
>> I'm re-visiting the D language. I've compared the file sizes of 2
>> executables - 1 is compiled C code using gcc; the other is D code
>> using dmd.
>>
>> helloWorld.d => helloWorld.exe = 146,972 bytes
>> ex1hello.c => ex1-hello.exe = 5,661 bytes
>>
>> Why such a huge difference???
>>
>> Duke
>
> You are doing it wrong.
> ```
> $ gcc hello.c; ls -lah a.out
> -rwxr-xr-x 1 dicebot users 4.9K Sep 20 18:47 a.out
> ```
> vs
> ```
> $ gcc -static hello.c; ls -lah a.out
> -rwxr-xr-x 1 dicebot users 717K Sep 20 18:48 a.out
> ```
>
> (C standard library is dynamically linked by default)
>
> So actual relative difference is about 2x - quite big but not as
> huge. It mostly comes from additional D runtime stuff.

I get the same executable size whether or not I use `-static' with 
cygwin/win7 ...

Still tons smaller than the D executable though. Not good!! me young 
mucker!!!!  :D


More information about the Digitalmars-d mailing list