ccache-support.txt 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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 the directory defined by the +BR2_CCACHE_DIR+
  15. configuration option, which defaults to
  16. +$HOME/.buildroot-ccache+. This default location is outside of
  17. Buildroot output directory so that it can be shared by separate
  18. Buildroot builds. If you want to get rid of the cache, simply remove
  19. this directory.
  20. You can get statistics on the cache (its size, number of hits,
  21. misses, etc.) by running +make ccache-stats+.
  22. The make target +ccache-options+ and the +CCACHE_OPTIONS+ variable
  23. provide more generic access to the ccache. For example
  24. -----------------
  25. # set cache limit size
  26. make CCACHE_OPTIONS="--max-size=5G" ccache-options
  27. # zero statistics counters
  28. make CCACHE_OPTIONS="--zero-stats" ccache-options
  29. -----------------
  30. +ccache+ makes a hash of the source files and of the compiler options.
  31. If a compiler option is different, the cached object file will not be
  32. used. Many compiler options, however, contain an absolute path to the
  33. staging directory. Because of this, building in a different output
  34. directory would lead to many cache misses.
  35. To avoid this issue, buildroot has the +Use relative paths+ option
  36. (+BR2_CCACHE_USE_BASEDIR+). This will rewrite all absolute paths that
  37. point inside the output directory into relative paths. Thus, changing
  38. the output directory no longer leads to cache misses.
  39. A disadvantage of the relative paths is that they also end up to be
  40. relative paths in the object file. Therefore, for example, the debugger
  41. will no longer find the file, unless you cd to the output directory
  42. first.
  43. See https://ccache.samba.org/manual.html#_compiling_in_different_directories[the
  44. ccache manual's section on "Compiling in different directories"] for
  45. more details about this rewriting of absolute paths.