LLVM Clang 11 Has A Nice Build Speed Improvement With New Feature For Pre-Compiled Headers
There are many improvements in LLVM/Clang 11.0 due out in the weeks ahead though an interesting change merged prior to last month's code branching that slipped under our radar... If using the clang-cl driver for MSVC or when otherwise making use of pre-compiled headers (PCH) functionality, there is a new option that can offer significant build time speed-ups.
When making use of Clang PCH functionality for leveraging pre-compiled headers, Clang 11.0 is introducing the -fpch-instantiate-templates option separate from the existing PCH options. This -fpch-instantiate-templates option instantiates templates already while generating a precompiled header instead of instantiating every time the pre-compiled header is used. Avoiding the instantiation each time the pre-compiled header is used can provide measurable build time improvements. Aside from the MSVC clang-cl drop-in, this feature though isn't enabled by default since it can result in errors if the source header file is not self-contained.
But if you are leveraging Clang pre-compiled headers and the source header files are self-contained, the speed improvement can be quite noticeable. The original merge request that dates back to October 2019 notes the possibility of 20~30% build times saved by making use of this feature.
LLVM 11.0 / Clang 11.0 should be officially out within roughly the next month depending upon how the blocker bug situation plays out with this new option and a whole lot more.
When making use of Clang PCH functionality for leveraging pre-compiled headers, Clang 11.0 is introducing the -fpch-instantiate-templates option separate from the existing PCH options. This -fpch-instantiate-templates option instantiates templates already while generating a precompiled header instead of instantiating every time the pre-compiled header is used. Avoiding the instantiation each time the pre-compiled header is used can provide measurable build time improvements. Aside from the MSVC clang-cl drop-in, this feature though isn't enabled by default since it can result in errors if the source header file is not self-contained.
But if you are leveraging Clang pre-compiled headers and the source header files are self-contained, the speed improvement can be quite noticeable. The original merge request that dates back to October 2019 notes the possibility of 20~30% build times saved by making use of this feature.
LLVM 11.0 / Clang 11.0 should be officially out within roughly the next month depending upon how the blocker bug situation plays out with this new option and a whole lot more.
4 Comments