================
@@ -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
+ append("-Xclang -fno-pch-timestamp" CMAKE_CXX_FLAGS)
+ elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
+ # GCC 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.
append("-Xclang -fno-pch-timestamp" CMAKE_CXX_FLAGS)
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
# GCC requires this flag in order for precompiled headers to work with
ccache.
```
https://github.com/llvm/llvm-project/pull/176420
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits