| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 | // -*- mode:doc; -*-// vim: set syntax=asciidoc:[[ccache]]==== Using +ccache+ in Buildroothttp://ccache.samba.org[ccache] is a compiler cache. It stores theobject files resulting from each compilation process, and is able toskip future compilation of the same source file (with same compilerand same arguments) by using the pre-existing object files. When doingalmost identical builds from scratch a number of times, it can nicelyspeed up the build process.+ccache+ support is integrated in Buildroot. You just have to enable+Enable compiler cache+ in +Build options+. This will automaticallybuild +ccache+ and use it for every host and target compilation.The cache is located in +$HOME/.buildroot-ccache+. It is storedoutside of Buildroot output directory so that it can be shared byseparate Buildroot builds. If you want to get rid of the cache, simplyremove this directory.You can get statistics on the cache (its size, number of hits,misses, etc.) by running +make ccache-stats+.The make target +ccache-options+ and the +CCACHE_OPTIONS+ variableprovide more generic access to the ccache. For example-----------------# set cache limit sizemake CCACHE_OPTIONS="--max-size=5G" ccache-options# zero statistics countersmake CCACHE_OPTIONS="--zero-stats" ccache-options-----------------+ccache+ makes a hash of the source files and of the compiler options.If a compiler option is different, the cached object file will not beused. Many compiler options, however, contain an absolute path to thestaging directory. Because of this, building in a different outputdirectory would lead to many cache misses.To avoid this issue, buildroot has the +Use relative paths+ option(+BR2_CCACHE_USE_BASEDIR+). This will rewrite all absolute paths thatpoint inside the output directory into relative paths. Thus, changingthe output directory no longer leads to cache misses.A disadvantage of the relative paths is that they also end up to berelative paths in the object file. Therefore, for example, the debuggerwill no longer find the file, unless you cd to the output directoryfirst.See https://ccache.samba.org/manual.html#_compiling_in_different_directories[theccache manual's section on "Compiling in different directories"] formore details about this rewriting of absolute paths.
 |