# # $FreeBSD: head/devel/ccache/files/ccache-howto-freebsd.txt.in 340872 2014-01-24 00:14:07Z mat $ # 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 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. Clang will return a lot of 'unused argument' warnings: they are harmless. Just add this to /etc/make.conf if you want to hide them: .if ${CC:T} == "clang" CFLAGS+= -Qunused-arguments .endif Any time you change CC/CXX you need to reinstall devel/libtool or you will run in to problems. -- 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"