Difference between revisions of "Speed Builds Using Compiler Cache"

From odroid US
Jump to: navigation, search
Line 14: Line 14:
 
ln -s $(which ccache)  $(echo $CROSS_COMPILE)cpp
 
ln -s $(which ccache)  $(echo $CROSS_COMPILE)cpp
 
ln -s $(which ccache)  $(echo $CROSS_COMPILE)c++
 
ln -s $(which ccache)  $(echo $CROSS_COMPILE)c++
 +
 
</pre>
 
</pre>
  
Line 68: Line 69:
 
SD-Card Clean cache, clean build 45m15s
 
SD-Card Clean cache, clean build 45m15s
 
SD-Card cached, clean build [re-test this]
 
SD-Card cached, clean build [re-test this]
 +
 +
NFS-mounted root file system, Clean cache, clean build: 25m48s
 +
 
eMMC Clean cache, clean build 17m14s
 
eMMC Clean cache, clean build 17m14s
 
eMMC cached, clean build 2m10s
 
eMMC cached, clean build 2m10s
Line 81: Line 85:
 
SSD Clean cache, clean build 5m25s
 
SSD Clean cache, clean build 5m25s
 
SSD cached, clean build 0m33s
 
SSD cached, clean build 0m33s
 
 
</pre>
 
</pre>

Revision as of 16:07, 18 January 2013

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
# The CROSS_COMPILE environment variable should be empty for odroid native builds, it could be something like
# arm-none-linux-gnueabi- for cross-building on a host.
ln -s $(which ccache)  $(echo $CROSS_COMPILE)gcc
ln -s $(which ccache)  $(echo $CROSS_COMPILE)g++
ln -s $(which ccache)  $(echo $CROSS_COMPILE)cpp
ln -s $(which ccache)  $(echo $CROSS_COMPILE)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, using SD Card. An eMMC build completed after about 17 minutes.

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

Now the clean re-build takes 2 minutes 15 seconds on (eMMC)

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# 


Kernel Build Time Comparisons

using odroidu2_ubuntu-defconfig and linux-3.0.57 (ed's kernel)

Processor	    : Odroid-U2
Memory		    : 2GiB
Operating System    : Debian Wheezy

SD-Card Clean cache, clean build 45m15s
SD-Card cached, clean build [re-test this]

NFS-mounted root file system, Clean cache, clean build: 25m48s

eMMC Clean cache, clean build 17m14s
eMMC cached, clean build 2m10s

This data is for cross-building on x86_64 Linux host CodeSourcery (2011.09-64) toolchain.

Processor	: 4x Intel(R) Core(TM)2 Quad CPU    Q9550  @ 2.83GHz
Memory		: 8177MB (2393MB used)
Operating System		: Linux Mint 13 Maya
Using solid-state drive for source code and ccache directory (CCACHE_DIR)

SSD Clean cache, clean build 5m25s
SSD cached, clean build 0m33s