Ccache
Jump to navigation
Jump to search
Ccache is a tool to speed up recompilation time. it caches compilations so that the next time, the same compilation can be avoided and the results can be taken from the cache.
Even when dependencies are tracked with file modification, there are many situations where files get rebuilt when a previous compilation was exactly the same. Using ccache in a situation like this is a real time-saver.
$sudo apt install ccache
# config: cache dir is ~/.ccache, conf file ~/.ccache/ccache.conf
# max size of cache
ccache -M 64Gi # -M 0 for unlimited
# unlimited number of files
ccache -F 0
# rules in build/CMakeCache.txt
//CXX compiler launcher
CMAKE_CXX_COMPILER_LAUNCHER:STRING=/usr/bin/ccache
# or to export rule
export CMAKE_C_COMPILER_LAUNCHER=ccache
export CMAKE_CXX_COMPILER_LAUNCHER=ccache
export CMAKE_CUDA_COMPILER_LAUNCHER=ccache