Skip to content

Fix combined use of compiler launcher with lint tools

(Second revision, based on the feedback in !1773 (closed))

When using ccache with clang-tidy, ccache needs to wrap compiler invocation, rather than cmake innvocation. But it needs to do it without affecting the command line that iwyu-like tools are receiving.

With this fix, if __run_co_compile is used, compile launcher is passed using the new --launcher option, but if __run_co_compile is not needed, compiler launcher is prepended to the command line as before.

To better illustrate the change: with this fix if running clang-tidy with CXX_COMPILER_LAUNCHER set to "/usr/bin/time;-p;ccache" (time -p added strictly for illustration purposes), the command line changes from:

/usr/bin/time -p ccache cmake -E __run_co_compile \
  --tidy=clang-tidy ... -- g++ ...

to:

cmake -E __run_co_compile \
  --launcher=/usr/bin/time;-p;ccache \
  --tidy=clang-tidy ... -- g++ ...

This allows the compiler to be run via the launcher, but leaves tidy (& friends) invocations unaffected.

Fixes: #16493 (closed)
Topic-rename: co-compile-with-launcher

Edited by Brad King

Merge request reports