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

Trass3r un at known.com
Tue Dec 20 10:59:03 PST 2011


> Bottom line:  If we want to reduce D's binary size there are two pieces  
> of low-hanging fruit:
>
> 1.  Make -L--gc-sections the default in dmd.conf on Linux and probably  
> other Posix OS's.
>
> 2.  Add -ffunction-sections and -fdata-sections or equivalents to DMD  
> and compile Phobos with these enabled.  I have no idea how hard this  
> would be, but I imagine it would be easy for someone who's already  
> familiar with object file formats.

Seems like --gc-sections _can_ have its pitfalls:
http://blog.flameeyes.eu/2009/11/21/garbage-collecting-sections-is-not-for-production

Also I read somewhere that --gc-sections isn't always supported (no  
standard switch or something like that).

I personally see no reason not to use -ffunction-sections and  
-fdata-sections for compiling phobos though, cause a test with gdc didn't  
even result in a much bigger lib file, nor did it take significantly  
longer to compile/link.
That site I linked claims though, that it does mean serious overhead even  
if --gc-sections is omitted then.
So we have to do tests with huge codebases first.


More information about the Digitalmars-d mailing list