LLVM Clang 11 Has A Nice Build Speed Improvement With New Feature For Pre-Compiled Headers
Written by Michael Larabel in LLVM on 8 August 2020 at 08:44 PM EDT. 4 Comments
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.
Related News
About The Author
Author picture

Michael Larabel is the principal author of Phoronix.com and founded the site in 2004 with a focus on enriching the Linux hardware experience. Michael has written more than 20,000 articles covering the state of Linux hardware support, Linux performance, graphics drivers, and other topics. Michael is also the lead developer of the Phoronix Test Suite, Phoromatic, and OpenBenchmarking.org automated benchmarking software. He can be followed via Twitter or contacted via MichaelLarabel.com.

Popular News This Week