Jump to navigationJump to search
Download Source:

Introduction to Ccache

ccache is a compiler cache. It acts as a caching pre-processor to C/C++ compilers, using the -E compiler switch and a hash to detect when a compilation can be satisfied from cache. This often results in a 5 to 10 times speedup in common compilations.

Project Homepage:


Compile the package:

./configure --prefix=/usr &&

Install the package:

make install


This package does not install any libraries so only one installation is needed.

Compile the package:

CC="gcc ${BUILD64}" ./configure --prefix=/usr &&

Install the package:

make install


Using ccache

There are 2 ways to configure ccache. Either to prefix the compiler with ccache or to create alternate symlinks.

Method 1

To prefix the compiler with ccache you would need to set the following environment variables where appropriate:

CC="ccache gcc"
CXX="ccache g++"

Or on multilib

CC="ccache gcc ${BUILD32}"
CXX="ccache g++ ${BUILD32}"

Method 2

The second way would be to create some compatibility symlinks.

install -dv -m755 /opt/ccache/bin &&
ln -sfv ../../../usr/bin/ccache /opt/ccache/bin/gcc &&
ln -sfv ../../../usr/bin/ccache /opt/ccache/bin/cc &&
ln -sfv ../../../usr/bin/ccache /opt/ccache/bin/g++

Then put those links at the top of your path each time you login.

cat > /etc/profile.d/ << "EOF"
# Begin /etc/profile.d/

export PATH="/opt/ccache/bin:${PATH}"
export CCACHE_PATH="/usr/bin"
# End /etc/profile.d/


The CCACHE_PATH is the order of the directories that ccache will look for compilers in. If it is not set ccache will default to using $PATH.

Using ccache with distcc

In addition to the above section. The CCACHE_PREFIX variable is a prefix tagged onto the command that ccache would run to compile code.

export CCACHE_PREFIX="distcc"


Installed Programs: ccache
Installed Libraries: None
Installed Directories: None