eliminate unused virtual functions

前端 未结 2 942
执念已碎
执念已碎 2020-12-19 22:39

To eliminate unused (ordinary) function I can use: -ffunction-sections, -fdata-section and --gc-sections. and it works.

I know that using polymorphism, function are

相关标签:
2条回答
  • 2020-12-19 23:18

    For learning purpose I suggest you to learn the semantics of language elements and learn to use them for their purpose. I.e. use virtuals there yo want polymorphism and leave them alone otherwise.

    Worrying about things like the amount of dead code left in by the linker can be safely left to 5-10 years ahead or forever.

    And optimization improves every year, so even if today yo could find 0.01% of the image as possible waste by the time you get to production it may be gone just by itself.

    0 讨论(0)
  • 2020-12-19 23:30

    Thanks to Jonathan Wakely I started digging and I found gcc options:

    -fvtable-gc Emit special relocations for vtables and virtual function references so that the linker can identify unused virtual functions and zero out vtable slots that refer to them. This is most useful with -ffunction-sections and -Wl,--gc-sections, in order to also discard the functions themselves.

    But it is not supported in GCCv4.7.1

    0 讨论(0)
提交回复
热议问题