Skip to content
  • Ilya A. Kriveshko's avatar
    Fix combined use of compiler launcher with lint tools · eaf9f69d
    Ilya A. Kriveshko authored and Brad King's avatar Brad King committed
    When using ccache with clang-tidy, ccache needs to wrap compiler
    invocation, rather than cmake invocation.  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
    eaf9f69d