[ccache] Speeding up builds with clang-tidy, clang-analyzer and iwyu

Christian Ledergerber christian.ledergerber at ecorobotix.com
Sat Aug 1 15:31:13 UTC 2020


Hi All,

for our builds currently clang-tidy is currently the limiting factor in 
terms of speed.

There is one utility out there which tries to cache the output of 
clang-tidy, however it seems to be stale:
https://github.com/ejfitzgerald/clang-tidy-cache

Yet, I have the impression that my case is much simpler:

We use clang-tidy with the warnings-as errors flag. Hence, the compiler 
is only ever started if there are no clang-tidy warnings. IMHO this 
implies that there can only be a ccache hit, if clang-tidy generated no 
output and hence the output of clang-tidy does not need to be cached.

To me it seems like the following should work:

1. try to use ccache

2. if no hit:

- run clang-tidy

- run clang

For this I would need to know whether ccache generated a hit - lets say 
as return code of the executable.

Of course then the integration into cmake will be the next challenge, 
but this is for sure possible. For now we use a standard integration using:

set(CMAKE_C_COMPILER_LAUNCHER ccache)

set(CMAKE_CXX_COMPILER_LAUNCHER ccache)

So: my question is: is it possible to detect for each invocation of 
ccache whether it had a cache hit and NOT launch the compiler if it didn't?

What do you think in general of this approach?

Thank you!

Christian




More information about the ccache mailing list