Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to accelerate clang-tidy using ccache or similar?

Since employing ccache on our CI server, we find that the bottleneck in terms of build time is now our static analysis pass, that uses clang-tidy, among other tools. Does anyone know of a way to accelerate clang-tidy in a similar way to how ccache does so with a regular compiler?

like image 224
Tim Angus Avatar asked Dec 03 '18 16:12

Tim Angus


People also ask

Why is clang tidy so slow?

Running clang-tidy is rather slow - internally it compiles each file and then runs the checks so it will always be some factor slower than compilation.

What does ccache do?

Ccache is a compiler cache. It speeds up recompilation by caching the result of previous compilations and detecting when the same compilation is being done again. Ccache has been carefully written to always produce exactly the same compiler output that you would get without the cache.

What is ccache in Linux?

Ccache is a compiler cache. It speeds up recompilation by caching previous compilations and detecting when the same compilation is being done again. Ccache is free software, released under the GNU General Public License version 3 or later.

How do I install ccache?

To install ccache with Homebrew, run brew install ccache . With MacPorts, run port install ccache . You can also download and install yourself, using the instructions in the repository. Make sure ccache can be found in your $PATH .


1 Answers

I found another important detail here:

https://gitlab.kitware.com/cmake/cmake/-/merge_requests/1791/diffs

which is used here:

https://reviews.bitcoinabc.org/D5150?id=15995

So in order to be able to cache the output of the compiler when integrating clang-tidy using the : set(CMAKE_CXX_CLANG_TIDY ...

method you need to use the COMPILER_LAUNCHER method to configure ccache

find_program(CCACHE ccache)
if(CCACHE)
    set(CMAKE_C_COMPILER_LAUNCHER ${CCACHE})
    set(CMAKE_CXX_COMPILER_LAUNCHER ${CCACHE})
endif(CCACHE)

and NOT the launcher rule method:

find_program(CCACHE ccache)
if(CCACHE)
    set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ${CCACHE})
    set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ${CCACHE})
endif(CCACHE)
like image 118
Christian Ledergerber Avatar answered Sep 23 '22 16:09

Christian Ledergerber