0

I want to optimize the compilation/linkage time of the project by defining as much as possible templates as extern and instantiating them only once.

I order to achieve that I would like to know which template instantiations are created more that once.

Due to the fact that linkers mostly throw away such duplicates I think that the information about what exactly happened on linkage would be very useful.

Is there any flag for MSVC linker that would show me such information?

kennytm
  • 510,854
  • 105
  • 1,084
  • 1,005
Alex
  • 9,891
  • 11
  • 53
  • 87

1 Answers1

0

This stack overflow question is very similar. In their case is when doing template meta programming.

I think the direct answer will not be provided by the compiler. Also the number count might not be the best metric (no doubt that it is quite useful). A big template class will take much more time than 5 one line template functions.

At my work we have been looking at this since our compile times are quite long. What helped us is to actually check the time each file/library takes to compile and analyze that. Often it is template instantiation. In windows, specially on debug, the linking is quite slow for us. Having smaller modules helped on that. Also using the Pimpl idiom and forward declarations helped as they will allow to reduce the ripple of files needed to be compiled when an implementation detail changes. In addition the module will also export less symbols

Community
  • 1
  • 1
zomeck
  • 51
  • 4