Skip to content
Kaspar Schleiser edited this page Aug 31, 2016 · 1 revision

Introduction

"ccache is a compiler cache. It speeds up recompilation by caching previous compilations and detecting when the same compilation is being done again."

Usually, the initial build takes a little (5% - 20%) longer, but repeated builds are up to ten times faster. Using ccache is safe, as ccache tries very hard to not mess up things and falls back to a normal compile if it cannot ensure correct output.

There's one drawback: without further tweaking, gcc stops emmiting coloured output.

Setup

  • install using your distro's package manager. Eg., on ubuntu or debian:

# sudo apt-get install ccache

  • set CCACHE variable to ccache:

# export CCACHE=ccache

  • (optional) add the above export line to your ~/.profile

Result

Build without ccache:

[kaspar@booze default (master)]$ time BOARD=samr21-xpro make clean all
Building application "default" for "samr21-xpro" with MCU "samd21".

[...]

   text    data     bss     dec     hex filename
  37016     180    6008   43204    a8c4 /home/kaspar/src/riot/examples/default/bin/samr21-xpro/default.elf

real    0m12.321s
user    0m10.317s
sys     0m1.170s
[kaspar@booze default (master)]$

First build with ccache enabled:

[kaspar@booze default (master)]$ time BOARD=samr21-xpro make clean all
Building application "default" for "samr21-xpro" with MCU "samd21".

[...]

   text    data     bss     dec     hex filename
  37016     180    6008   43204    a8c4 /home/kaspar/src/riot/examples/default/bin/samr21-xpro/default.elf

real    0m15.462s
user    0m12.410s
sys     0m1.597s
[kaspar@booze default (master)]$

Subsequent build with ccache enabled:

[kaspar@booze default (master)]$ time BOARD=samr21-xpro make clean all
Building application "default" for "samr21-xpro" with MCU "samd21".

[...]

   text    data     bss     dec     hex filename
  37016     180    6008   43204    a8c4 /home/kaspar/src/riot/examples/default/bin/samr21-xpro/default.elf

real    0m2.157s
user    0m1.213s
sys     0m0.327s
[kaspar@booze default (master)]$
Clone this wiki locally