5

What are practical reasons for using multiple cache directories or clearing cache altogether when using CCACHE?

Help description for Buildroot BR2_CCACHE configuration option says:

Note that Buildroot does not try to invalidate the cache contents when the compiler changes in an incompatible way. Therefore, if you make a change to the compiler version and/or configuration, you are responsible for purging the ccache cache by removing the $HOME/.buildroot-ccache directory.

If I understand correctly, different compiler builds are recognized by CCACHE and caching is done on per-compiler basis. So, what are those situations that description is referring to?

Also, some sources seem to suggest that cache should be cleared regularly. Others point out that cache is cleaned up automatically when it reaches the "max cache size" threshold.

Obviously, if cached data is corrupted, then you need to do something about it. Are there other reasons to clear the cache? Wouldn't it make sense to keep a single cache?

montiainen
  • 125
  • 2
  • 7

1 Answers1

8

The major reason is because buildroot sets the CCACHE_COMPILERCHECK variable to 'none'. See ccache.mk in Buildroot.

Buildroot does this for good reason: everytime they would rebuild the same compiler version (let's say gcc 4.8.0), all the ccache results would be thrown out, even if they're still valid. Additionally, it's possible that another part of the toolchain would change. This would also impact the cached files, but it would not be detected by checking if the compiler version changes. In the future, it's possible that an extensive check that covers all necessary parts of the toolchain will be used. It doesn't seem like this is the case yet.

Obviously, this is not optimal: ideally, ccache results would be purged automatically when you change the compiler version from 4.8 to 4.9. Right now, you have to do so manually.

Mathiasdm
  • 1,791
  • 14
  • 26
  • 2
    I've got nothing to add, this answer is perfect. Thanks! – Thomas Petazzoni Jan 13 '15 at 08:16
  • I didn't understand that the point of that help description is to say that Buildroot doesn't use the per-compiler cache item separation mechanism of ccache. I think I just experienced an epiphany. Just for clarification: In the case of Buildroot, it is justifiable to use toolchain-specific cache if working on multiple separate projects. Do I understand this correctly? – montiainen Jan 13 '15 at 12:28
  • Yes, you understand correctly. You can use multiple ccache directories and switch between them depending on the toolchain you are using. However, be careful not to get confused between them :) – Mathiasdm Jan 13 '15 at 14:07