ccache-support.txt 2.3 KB

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