blog.up-link.ro
30Jul/110

FreeBSD: How To Enable ccache on FreeBSD 8.2

ccache is a software development tool that caches the output of C/C++ compilation so that the next time, the same compilation can be avoided and the results can be taken from the cache. This can greatly speed up recompiling time.

The following is a step by step guide to how to enable and use ccache on FreeBSD 8.2.

Install ccache by running the following command:

make install clean -C /usr/ports/devel/ccache

Update /etc/make.conf by adding the following lines:

#CCACHE
.if !defined(NO_CCACHE)
CC= /usr/local/libexec/ccache/world/cc
CCX= /usr/local/libexec/ccache/world/c++
.endif

.if ${.CURDIR:M*/ports/devel/ccache}
NO_CCACHE=yes
.endif

Basically we've started by installing ccache and proceeded by editing /etc/make.conf as to enable ccache on builds.

Now we need to update the environment.

If you are using csh/tcsh shell add the following to /root/.cshrc:

setenv PATH /usr/local/libexec/ccache:$PATH
setenv CCACHE_PATH /usr/bin:/usr/local/bin
setenv CCACHE_DIR /var/tmp/ccache
setenv CCACHE_LOGFILE /var/log/ccache.log

If you are using zsh add the following to your /root/.zshrc file:

export PATH=/usr/local/libexec/ccache:$PATH
export CCACHE_PATH=/usr/bin:/usr/local/bin
export CCACHE_DIR=/var/tmp/ccache
export CCACHE_LOGFILE=/var/log/ccache.log

If you are using bash add the following to your /root/.profile file:

export PATH=/usr/local/libexec/ccache:$PATH
export CCACHE_PATH=/usr/bin:/usr/local/bin
export CCACHE_DIR=/var/tmp/ccache
export CCACHE_LOGFILE=/var/log/ccache.log

After updating the dotfiles we update the environment. Users of csh/tcsh shells can update by:

source /root/.cshrc

Users of zsh can update the environment by running the following command:

source /root/.zshrc

Anyone using bash can update the environment by running the following command:

source /root/.profile

ccache is installed and the environment is updated. Your next build will be performed with ccache enabled.

To display statistics summary:

ccache -s

To zero statistics:

ccache -z

To set ccache temp size (for example 512MB):

/usr/local/bin/ccache -M 512m

To check out the help file for a list of ccache options:

ccache -h

If you come across a port that fails to build, disable ccache and try again:

make NO_CCACHE=yes install clean

You can find more information regarding ccache through:

man ccache
ccache -h
less /usr/local/share/doc/ccache/ccache-howto-freebsd.txt
links /usr/local/share/doc/ccache/index.html
Print This Post Print This Post
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


*

No trackbacks yet.