are mixin string templates with functions removed?
Dicebot
public at dicebot.lv
Thu Aug 1 12:01:53 PDT 2013
On Thursday, 1 August 2013 at 17:53:38 UTC, Ali Çehreli wrote:
> I think the question is whether the instantiations of such
> templates are removed. If the instance is used only to
> initialize an enum, the function shouldn't stay in the binary.
>
> Even if the function remains, I think the linker takes care of
> removing unused functions.
>
> Ali
Unfortunately, you are wrong. No symbol optimization is done by
DMD is linker can't figure this out on its own, it requires
specific object file layout to do reference counting for symbols.
It is really easy to check - make template function with some
anchor value inside (OXDEADBEEF) and compile it with this
template used exclusively in constraints or CTFE. Then strip and
objdump - you'll find anchors in resulting binary for every
instantiation.
More information about the Digitalmars-d-learn
mailing list