Skip to content

Commit 282ae83

Browse files
authored
Add WarpX_CCACHE Option (#4637)
WarpX autodetects `ccache` and uses it, and there's nothing you can do about it. This PR disables it by default, and lets developers enable it through `-DWarpX_CCACHE:BOOL=ON`. The reason for this is mostly related to compiler wrappers, of which there are many... If `g++` is a compiler wrapper, then `ccache g++` cannot see the effective flags passed to underlying real `g++`. That leads eventually to false positive cache hits, which is a pain to debug. For compiler wrappers you want `g++` the wrapper to invoke the call to `ccache <real g++ invocation>` to fix that, which is for example how Spack handle it. Further, if you use spack with ccache enabled, the defaults of WarpX cause `ccache` to be invoked twice (inner & outer), doubling the cache requirements. Finally, compiler wrapper that handle ccache themselves may set further ccache options / flags that WarpX does not set, such as disabling hashing of the build dir -- w/o that option cache may be useless. * Update Order and Docs
1 parent d8df8f6 commit 282ae83

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

CMakeLists.txt

+10-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,15 @@ set_cxx17_superbuild()
4343
# this is an optional tool that stores compiled object files; allows fast
4444
# re-builds even with "make clean" in between. Mainly used to store AMReX
4545
# objects
46-
set_ccache()
46+
if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
47+
set(WarpX_CCACHE_DEFAULT ON)
48+
else()
49+
set(WarpX_CCACHE_DEFAULT OFF) # we are a subproject in a superbuild
50+
endif()
51+
option(WarpX_CCACHE "Enable ccache for faster rebuilds" ${WarpX_CCACHE_DEFAULT})
52+
if(WarpX_CCACHE)
53+
set_ccache()
54+
endif()
4755

4856

4957
# Output Directories ##########################################################
@@ -149,6 +157,7 @@ endif()
149157
# this defined the variable BUILD_TESTING which is ON by default
150158
#include(CTest)
151159

160+
152161
# Dependencies ################################################################
153162
#
154163

Docs/source/install/cmake.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ By default, the most important dependencies of WarpX are automatically downloade
116116
CMake Option Default & Values Description
117117
============================= ============================================== ===========================================================
118118
``BUILD_SHARED_LIBS`` ON/**OFF** `Build shared libraries for dependencies <https://cmake.org/cmake/help/latest/variable/BUILD_SHARED_LIBS.html>`__
119-
``CCACHE_PROGRAM`` First found ``ccache`` executable. Set to ``-DCCACHE_PROGRAM=NO`` to disable CCache.
119+
``WarpX_CCACHE`` **ON**/OFF Search and use CCache to speed up rebuilds.
120120
``AMReX_CUDA_PTX_VERBOSE`` ON/**OFF** Print CUDA code generation statistics from ``ptxas``.
121121
``WarpX_amrex_src`` *None* Path to AMReX source directory (preferred if set)
122122
``WarpX_amrex_repo`` ``https://github.com/AMReX-Codes/amrex.git`` Repository URI to pull and build AMReX from

0 commit comments

Comments
 (0)