Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reasons to clear ccache or use multiple ccache directories

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?

like image 361
montiainen Avatar asked Mar 17 '23 09:03

montiainen


1 Answers

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.

like image 55
Mathiasdm Avatar answered Mar 23 '23 01:03

Mathiasdm