[clang] [flang] [llvm] [mlir] [polly] [CMake][LLVM] Add PCH infrastructure and LLVMSupport PCH (PR #176420)
Jakub Kuderski via cfe-commits
cfe-commits at lists.llvm.org
Fri Jan 16 17:14:15 PST 2026
================
@@ -1304,6 +1304,27 @@ if (LLVM_BUILD_INSTRUMENTED AND LLVM_BUILD_INSTRUMENTED_COVERAGE)
message(FATAL_ERROR "LLVM_BUILD_INSTRUMENTED and LLVM_BUILD_INSTRUMENTED_COVERAGE cannot both be specified")
endif()
+if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND NOT DEFINED CMAKE_DISABLE_PRECOMPILE_HEADERS)
+ # Pre-compiled headers with GCC (tested versions 14+15) provide very little
+ # compile-time improvements, but substantially increase the build dir size.
+ # Therefore, disable PCH with GCC by default.
+ message(NOTICE "Precompiled headers are disabled by default with GCC. "
+ "Pass -DCMAKE_DISABLE_PRECOMPILE_HEADERS=OFF to override.")
+ set(CMAKE_DISABLE_PRECOMPILE_HEADERS ON)
+endif()
+if(NOT CMAKE_DISABLE_PRECOMPILE_HEADERS)
+ message(STATUS "Precompiled headers enabled.")
+ if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
+ # Clang requires this flag in order for precompiled headers to work with ccache
----------------
kuhar wrote:
```suggestion
# Clang requires this flag in order for precompiled headers to work with ccache.
```
https://github.com/llvm/llvm-project/pull/176420
More information about the cfe-commits
mailing list