Install ccache to build code faster

Install ccache to speed up compile times for compiling c and c++ code. Installation on fedora is simple.

$ sudo yum install ccache

Before installation, your compilers were found in /usr/bin

$ which gcc cc

/usr/bin/gcc
/usr/bin/cc

After installing ccache, each binary got replaced by a softlink to ccache.

$ ls -l /usr/lib64/ccache/

c++ -> ../../bin/ccache
cc -> ../../bin/ccache
g++ -> ../../bin/ccache
gcc -> ../../bin/ccache
x86_64-redhat-linux-c++ -> ../../bin/ccache
x86_64-redhat-linux-g++ -> ../../bin/ccache
x86_64-redhat-linux-gcc -> ../../bin/ccache

This would be simple to install from scratch. You would need to move the binaries and create each softlink yourself. The other way to run it is to replace your calls to the compilers with ccache. But that would require you edit each project individually. I like the softlinks because it just works right out of the box.

To make sure it’s working, check out the statistics, or just build something that normally takes a long time to compile!

Before:

$ ccache -s

cache directory             /var/cache/ccache
cache hit                    0
cache miss                   0
files in cache            1772
cache size                27.0 Mbytes
max cache size           976.6 Mbytes

After compiling something:

$ ccache -s

cache directory           /var/cache/ccache
cache hit                  166
cache miss                 886
called for link             40
multiple source files        2
compile failed              15
preprocessor error          90
not a C/C++ file            24
autoconf compile/link       95
no input file              903
 files in cache           1772
cache size                27.0 Mbytes
max cache size           976.6 Mbytes
Posted by admica   @   13 May 2009

Related Posts

Like this post? Share it!

Digg Twitter StumbleUpon Delicious Technorati Facebook RSS

0 Comments

No comments yet. Be the first to leave a comment !
Leave a Comment

Name

Email

Website

Previous Post
« Failed to write session data for php with lighttpd
Next Post
Free the fish »
Powered by Wordpress   |   Lunated designed by ZenVerse