4

I'm having trouble getting consistent benefit from ccache in my jenkins pipeline builds. I'm setting CCACHE_BASEDIR to the parent directory of my current build directory (this works out to something like /opt/jenkins/workspace). Given this basedir, I would expect all PR/branch builds that share this common parent to be able to find hits in the cache, but alas they do not. I do see cache hits for subsequent builds in a given directory (if I manually rebuild a particular PR, for example), which implies that CCACHE_BASEDIR is not working like I would expect.

To further diagnose, I've tried setting CCACHE_LOGFILE and although that file is produced by the build, it is effectively empty (it contains only two lines indicating the version of ccache).

Can anyone suggest specific settings or techniques that have worked to get maximum benefit from ccache in jenkins pipelines, or other things to try to diagnose the problem? What might cause the empty ccache log file?

I'm running ccache 3.3.4.

Mike Ellery
  • 2,054
  • 3
  • 21
  • 30
  • Could you get ccache to work manually? You can check ccache stats with `ccache -s` to see if it is caching files. – Florian Castellane Feb 14 '18 at 10:15
  • I observe the same almost-empty log file behaviour as well. Did you ever find out why that was the case @mike-ellery? – Salem Derisavi Mar 10 '21 at 04:30
  • @SalemDerisavi I long ago stopped working on this particular project and i can't recall if I ever got a resolution. The advice from Joel below is probably as good as it gets..and also making sure you have the latest ccache. Beyond that, I don't have any concrete advice. Good luck! – Mike Ellery Mar 11 '21 at 05:33

1 Answers1

1

The solution to the first part of the question is probably to set hash_dir = false (CCACHE_NOHASHDIR=1 if using environment variables) or setting -fdebug-prefix-map=old=new for relocating debug info to a common prefix (e.g. -fdebug-prefix-map=$PWD=.). More details can be found in the "Compiling in different directories" section in the ccache manual.

Regarding CCACHE_LOGFILE: I've never heard about that problem before (I'm the ccache maintainer, BTW), but if you set CCACHE_LOGFILE to a relative file path, try setting it to an absolute path instead.

Joel Rosdahl
  • 846
  • 9
  • 12