Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check if a ccache call was a cache hit

Tags:

ccache

As part of my build process, I'd like to get statistics on the build time and whether ccache found the item in the cache. I know about ccache -s where I can compare the previous and current cache hit counts.

However, if I have hundreds of compilation threads running in parallel, the statistics don't tell me which file caused the hit.

The return code of ccache is that of the compiler. Is there any way I can get ccache to tell me if it was successful?

like image 728
mrks Avatar asked Apr 28 '19 13:04

mrks


1 Answers

There are two options:

  1. Enable the ccache log file: Set log_file in the configuration (or the environment variable CCACHE_LOGFILE) to a file path. Then you can figure out the result of each compilation from the log data. It can be a bit tedious if there are many parallel ccache invocations (the log file is shared between all of them, so log records from the different processes will be interleaved) but possible by taking the PID part of each log line into account.
  2. In ccache 3.5 and newer, it's better to enable the debug mode: Set debug = true in the configuration (or the environment variable CCACHE_DEBUG=1). ccache will then store the log for each produced object file in <objectfile>.ccache-log. Read more in Cache debugging in the ccache manual.
like image 157
Joel Rosdahl Avatar answered Sep 19 '22 13:09

Joel Rosdahl