Precompiled headers and why Squid won't be using them (2023)
6 months ago
- #Compilation Optimization
- #Precompiled Headers
- #C++
- Precompiled headers reduce duplicate work by saving intermediate states of key headers in C++ compilation.
- GCC uses .gch suffix for precompiled headers, automatically used if present in the same directory.
- Clang requires .pch suffix and explicit -include-pch switch, with strict inclusion rules.
- MSVC support for precompiled headers is not yet targeted for Squid.
- Squid's coding guidelines could theoretically benefit from precompiled headers due to extensive header inclusions.
- Experimental results showed a modest 5% compile time improvement with GCC, but integration challenges exist.
- Autotools integration for GCC is hacky, involving custom Makefile rules and conditional builds.
- Clang's strict requirement for -include-pch and build order control presents a significant hurdle.
- The complexity and limited benefits led to abandoning precompiled headers for Squid.
- Suggestions for improvement include Clang adopting GCC's more forgiving behavior towards missing precompiled headers.