Binary Size: function-sections, data-sections, etc.

Marco Leise Marco.Leise at gmx.de
Tue Dec 20 16:54:16 PST 2011


Am 20.12.2011, 20:45 Uhr, schrieb Trass3r <un at known.com>:

> On Tuesday, 20 December 2011 at 19:36:19 UTC, Marco Leise wrote:
>> Nice of you to start some discussion on these flags. I use them myself  
>> (and a few others that seem to affect code size) in a 'tiny' target  
>> inside the D Makefile I use.
>> Currently it looks like this:
>>
>> 	dmd <sources,directory,bin> -m32 -O -release -noboundscheck  
>> -L--strip-all -L-O1 -L-znodlopen -L-znorelro  
>> -L--no-copy-dt-needed-entries -L--relax -L--sort-common -L--gc-sections  
>> -L-lrt -L--as-needed
>> 	strip <bin> -R .comment -R .note.ABI-tag -R .gnu.hash -R .gnu.version  
>> -R .jcr -R .got
>>
>> That's not even funny, I know :D
>
> How far down do you get in terms of size with this?


I've just installed 2.057 and there were changes that affect code size, so  
I'll test it once more:

Simple "Hello, world!"
   dmd-2.057
     normal release build (64-bit):   604_156 bytes
     + in 32-bit                  :   490_033 bytes
     + strip-all                  :   250_008 bytes
     + all the other flags        :   147_256 bytes (-102_752 bytes, ~41%)
   gcc-Version 4.6.1 20110627 (gdc 0.30, using dmd 2.055)
     32-bit release, smallest     :   577_856 bytes

Small GUI application using gtk and cairo
   dmd-2.057
     normal release build (32-bit): 5_832_735 bytes
     + strip-all                  : 2_519_124 bytes
     + all the other flags        : 2_243_240 bytes (-275_884 bytes, ~11%)
   gcc-Version 4.6.1 20110627 (gdc 0.30, using dmd 2.055)
     32-bit release, smallest     : 3_204_832 bytes


More information about the Digitalmars-d mailing list