# # $FreeBSD$ # To use ccache for ports, just add WITH_CCACHE_BUILD=yes to /etc/make.conf. The rest of this guide is for building /usr/src and other checkouts. To use ccache for base (11.0+) just add WITH_CCACHE_BUILD=yes to /etc/src.conf. Refer to src.conf(5) for more information. ------------------------------------------------------------------------------- For older releases, before 11.0, add the following to /etc/make.conf. You can replace cc and c++ with the compilers of your choice. (remember that only GCC and Clang can build world and kernel) .if (!empty(.CURDIR:M/usr/src*) || !empty(.CURDIR:M/usr/obj*)) .if !defined(NOCCACHE) && exists(%%PREFIX%%/%%CCLINKDIR%%/world/cc) CC:=${CC:C,^cc,%%PREFIX%%/%%CCLINKDIR%%/world/cc,1} CXX:=${CXX:C,^c\+\+,%%PREFIX%%/%%CCLINKDIR%%/world/c++,1} .endif .endif For Korn/Bourne shells Add the following to /etc/profile: export PATH=%%PREFIX%%/%%CCLINKDIR%%:$PATH export CCACHE_PATH=/usr/bin:%%LOCALBASE%%/bin For csh/tcsh Add the following to /etc/csh.cshrc: setenv PATH %%PREFIX%%/%%CCLINKDIR%%:$PATH setenv CCACHE_PATH /usr/bin:%%LOCALBASE%%/bin For icc users: Add %%ICCPREFIX%% to CCACHE_PATH ------------------------------------------------------------------------------- To use distcc: For Korn/Bourne shells Add the following to /etc/profile: export CCACHE_PREFIX=distcc export DISTCC_HOSTS="localhost host1 host2" For csh/tcsh Add the following to /etc/csh.cshrc: setenv CCACHE_PREFIX distcc setenv DISTCC_HOSTS "localhost host1 host2" -- If you have a problem building world define NOCCACHE and try again. If you have a problem building a port reset PATH=$CCACHE_PATH and try again. -- Make sure you run 'ccache-update-links' after you install/uninstall additional compilers in order to create/remove compiler links. -- Ccache's default cache size is 1GB and this is larger than the default size of the root partition (/) on FreeBSD. To over come this you may specify a new cache location on a different partition with the following examples. For Korn/Bourne shells Add the following to /etc/profile: export CCACHE_DIR=/usr/.ccache For csh/tcsh Add the following to /etc/csh.cshrc setenv CCACHE_DIR "/usr/.ccache"