System

Setting up ccache for llvm package only

I have a couple of servers that require llvm, and to compile them is a strain. There are no bins for these, so I read that ccache is an option to help with that. Here is the procedure on how to install and configure ccache to only be used for llvm

emerge -v ccache
cd /var/cache
mkdir ccache
vi ccache.conf

In the ccache.conf file:

max_size = 10G
umask = 002
hash_dir = false
compiler_check = %compiler% -dumpversion
cache_dir_levels = 3

Edit make.conf

vi /etc/make.conf

FEATURES="parallel-fetch -xattr"
CCACHE_DIR="/var/cache/ccache"
CCACHE_SIZE="10G"

Create the env/ccache.conf file

vi /etc/portage/env/ccache.conf

FEATURES="${FEATURES} ccache"

Create or edit /etc/package.env

vi /etc/package.env

sys-devel/llvm ccache.conf

Now, when emerging llvm you should see some ccache in the compile:

[970/3121] /usr/lib/ccache/bin/x86_64-pc-linux-gnu-g++ -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/var/tmp/portage/sys-devel/llvm-14.0.6-r2/work/llvm_build-abi_x86_64.amd64/lib/Analysis -I/var/tmp/portage/sys-devel/llvm-14.0.6-r2/work/llvm/lib/Analysis -I/var/tmp/portage/sys-devel/llvm-14.0.6-r2/work/llvm_build-abi_x86_64.amd64/include -I/var/tmp/portage/sys-devel/llvm-14.0.6-r2/work/llvm/include -DNDEBUG -O2 -pipe -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-maybe-uninitialized -Wno-class-memaccess -Wno-redundant-move -Wno-pessimizing-move -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wmisleading-indentation -fdiagnostics-color -ffunction-sections -fdata-sections -std=c++14 -MD -MT lib/Analysis/CMakeFiles/LLVMAnalysis.dir/Loads.cpp.o -MF lib/Analysis/CMakeFiles/LLVMAnalysis.dir/Loads.cpp.o.d -o lib/Analysis/CMakeFiles/LLVMAnalysis.dir/Loads.cpp.o -c /var/tmp/portage/sys-devel/llvm-14.0.6-r2/work/llvm/lib/Analysis/Loads.cpp

Also, look at file sizes on /var/cache/ccache to verify caching is hapening.