Skip to content

[CMake] Make precompiled headers opt-in for ccache builds #141927

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions llvm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,14 @@ if(LLVM_CCACHE_BUILD)
set(LLVM_CCACHE_PARAMS "CCACHE_CPP2=yes CCACHE_HASHDIR=yes CCACHE_SLOPPINESS=pch_defines,time_macros"
CACHE STRING "Parameters to pass through to ccache")

# FIXME: This is a workaround for an unknown underlying issue where the header file
# changes but then the pch does not get rebuilt before its dependencies.
# See: https://github.com/llvm/llvm-project/issues/142449
set(LLVM_CCACHE_PCH OFF CACHE BOOL "Use precompiled headers in ccache builds")
if (NOT LLVM_CCACHE_PCH)
set(CMAKE_DISABLE_PRECOMPILE_HEADERS "ON")
endif()

if(NOT CMAKE_HOST_WIN32)
set(CCACHE_PROGRAM "${LLVM_CCACHE_PARAMS} ${CCACHE_PROGRAM}")
if (LLVM_CCACHE_MAXSIZE)
Expand Down
4 changes: 3 additions & 1 deletion llvm/docs/CMake.rst
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,9 @@ enabled sub-projects. Nearly all of these variable names begin with
Defaults to OFF. The size and location of the cache maintained
by ``ccache`` can be adjusted via the LLVM_CCACHE_MAXSIZE and LLVM_CCACHE_DIR
options, which are passed to the CCACHE_MAXSIZE and CCACHE_DIR environment
variables, respectively.
variables, respectively. By default, enabling the ccache build will disable
using precompiled headers as they have been known to cause intermittent CI
failures. This can be adjusted via the LLVM_CCACHE_PCH option.

**LLVM_CODE_COVERAGE_TARGETS**:STRING
If set to a semicolon separated list of targets, those targets will be used
Expand Down
Loading