Generated binary size
Joseph Rushton Wakeling
joseph.wakeling at webdrake.net
Fri Sep 13 06:14:38 PDT 2013
On 13/09/13 14:02, Dicebot wrote:
> `--gc-sections` is ld flag that enabled garbage collection of unreferenced
> sections in resulting binary. For it to work gcc/gdc need to be run with
> `-fdata-sections`and `-ffunction-sections` placing each symbol into own section.
> That will, for example, remove template function bodies that got inlined for all
> calls. For template-heavy code with good inliner it can reduce binary sizes
> tremendously (running it on snippet from this topic will reduce gdc binary size
> to almost match dmd one).
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'd be
nice to be able to strip that out automatically rather than having to tweak the
build script manually to leave out that module -- it's so much simpler to have
the Makefile simply build using the whole library source. [*]
[* Yes, yes, I know, I should abandon Make and sort out a decent built system at
long last ...]
More information about the D.gnu
mailing list