0

I've been doing a lot of googling to figure out various ways I could analyze my include directives per translation unit to determine why my overall build is so slow. The entire project consists of around 800 translation units, and when combined with the number of header files we maintain and use (e.g. third party) it's difficult to track exactly what we're including at the top-level that may be included by most translation units being built that do not even need it. I feel like eliminating needless includes will help bring our build times down.

Can anyone suggest any techniques or tools that may be useful in analyzing unnecessary includes? For example, maybe something that prints which headers are included the most in descending order across the whole project build (all translation units)? It would be even better if such a tool could provide statistics such as " included by 600 translation units and not needed by 90% of them". I do not want to use precompiled headers, so I feel like this is my only option (eliminate unnecessary includes and redesign headers to make use of the pimpl idiom to improve build times).

Note I'm using clang as my compiler on linux & android (NDK). I also build with MSVC on the Windows platform.

void.pointer
  • 24,859
  • 31
  • 132
  • 243
  • Questions asking us to recommend or find a book, tool, software library, tutorial or other off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it. – SergeyA Aug 02 '17 at 14:49
  • There is a plugin for visual studio called [IncludeToolbox](https://marketplace.visualstudio.com/items?itemName=Wumpf.IncludeToolbox) that has a "try and remove includes" feature that I've used with moderate success. Just removes headers and re-iterates compiling to see if they were needed. (if you have some downtime on your machine) – Cory Kramer Aug 02 '17 at 14:49
  • FWIW I've already seen the SO question linked as a duplicate to my own. It doesn't really help. I guess I'll try my luck on reddit, they're slightly less anal about questions like this. – void.pointer Aug 02 '17 at 14:53

0 Answers0