1// -*- mode:doc; -*- 2// vim: set syntax=asciidoc: 3 4[[ccache]] 5==== Using +ccache+ in Buildroot 6 7http://ccache.samba.org[ccache] is a compiler cache. It stores the 8object files resulting from each compilation process, and is able to 9skip future compilation of the same source file (with same compiler 10and same arguments) by using the pre-existing object files. When doing 11almost identical builds from scratch a number of times, it can nicely 12speed up the build process. 13 14+ccache+ support is integrated in Buildroot. You just have to enable 15+Enable compiler cache+ in +Build options+. This will automatically 16build +ccache+ and use it for every host and target compilation. 17 18The cache is located in +$HOME/.buildroot-ccache+. It is stored 19outside of Buildroot output directory so that it can be shared by 20separate Buildroot builds. If you want to get rid of the cache, simply 21remove this directory. 22 23You can get statistics on the cache (its size, number of hits, 24misses, etc.) by running +make ccache-stats+. 25 26The make target +ccache-options+ and the +CCACHE_OPTIONS+ variable 27provide more generic access to the ccache. For example 28 29----------------- 30# set cache limit size 31make CCACHE_OPTIONS="--max-size=5G" ccache-options 32 33# zero statistics counters 34make CCACHE_OPTIONS="--zero-stats" ccache-options 35----------------- 36 37+ccache+ makes a hash of the source files and of the compiler options. 38If a compiler option is different, the cached object file will not be 39used. Many compiler options, however, contain an absolute path to the 40staging directory. Because of this, building in a different output 41directory would lead to many cache misses. 42 43To avoid this issue, buildroot has the +Use relative paths+ option 44(+BR2_CCACHE_USE_BASEDIR+). This will rewrite all absolute paths that 45point inside the output directory into relative paths. Thus, changing 46the output directory no longer leads to cache misses. 47 48A disadvantage of the relative paths is that they also end up to be 49relative paths in the object file. Therefore, for example, the debugger 50will no longer find the file, unless you cd to the output directory 51first. 52 53See https://ccache.samba.org/manual.html#_compiling_in_different_directories[the 54ccache manual's section on "Compiling in different directories"] for 55more details about this rewriting of absolute paths. 56