Speed Builds Using Compiler Cache

From odroid US
Revision as of 02:58, 14 January 2013 by Osterluk (Talk | contribs) (Created page with "A package named ccache can speed up builds. It is easy to use. <pre> # install the c compiler cache # as root apt-get install ccache # add symlinks so ccache can invoke the ...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

A package named ccache can speed up builds. It is easy to use.

# install the c compiler cache
# as root
apt-get install ccache
# add symlinks so ccache can invoke the compiler
# /usr/local/bin is usually in the path before /usr/bin, so that is where we put the symlinks 
cd /usr/local/bin
ln -s $(which ccache) gcc
ln -s $(which ccache) g++
ln -s $(which ccache) cpp
ln -s $(which ccache) c++

To test, it build the kernel. You need to be set up with kernel source and prerequisites first: (link to tutorial)

cd /usr/src/linux
# clear the ccache
ccache -c
# start clean
make clean
#
time make -j8

After about 45 minutes, the native build is complete.

# clean the object files
make clean
# time the build again
time make -j8

Now the complete build takes 27 minutes. Check the ccache statistics:

root@odroidu2-1:/usr/src/linux# ccache -s    
cache directory                     /root/.ccache
cache hit (direct)                  2554
cache hit (preprocessed)               3
cache miss                             0
called for link                       11
called for preprocessing               2
unsupported source language           62
no input file                         68
files in cache                      7709
cache size                         316.4 Mbytes
max cache size                       1.0 Gbytes
root@odroidu2-1:/usr/src/linux# 


TODO: Repeat with eMMC. The native build is much slower thatn I expected, even with ccache.