Generated binary size

Dicebot public at dicebot.lv
Fri Sep 13 06:25:01 PDT 2013


On Friday, 13 September 2013 at 13:14:49 UTC, Joseph Rushton 
Wakeling wrote:
> Ahh, OK.
>
> Related query -- is there any way of telling the compiler 
> (gdc/gdmd or preferably any of the D compilers) to strip out 
> unused symbols/functions/data from the binary?
>
> I have a module that includes a quite large array of immutable 
> data (used for test purposes), but when this is compiled in 
> with other code it adds about 10MB (!) to the executable size, 
> even when the executable never uses it.

It is exactly what `gdc -fdata-sections -Xlinker --gc-sections 
app.d` will do.

Be careful though, if you use dynamic loading of shared libraries 
(or build your app as library) that may result in weird stuff 
when applied to all sources :)


More information about the D.gnu mailing list