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

2020-08-14 Thread Joel Rosdahl via ccache
On Fri, 14 Aug 2020 at 08:39, Christian Ledergerber
 wrote:
>
> I have created the following issue for cmake to launch the discussion:
> https://gitlab.kitware.com/cmake/cmake/-/issues/21092

When you described your idea I didn't think you meant making changes
for incorporation in the upstream CMake software but to some local
CMake version. I think that it will be hard to implement it in a
generic enough way for CMake since

1. The solution will require a specific ccache version to work at all.
2. The method of using ccache to probe whether clang-tidy should be
run won't work for users who don't use warnings-as-errors. Also, how
would CMake know that warnings-as-errors is used? It could be part of
WarningsAsErrors in the config file or it could be on the command line
but only for some warnings, etc. Sounds brittle and complex.
3. The method is also brittle since the clang-tidy step will be
skipped if the source is built (and therefore cached) by a normal
non-clang-tidy build.

(But if you apply your changes to a local CMake version you can make
any assumptions you want, of course.)

I spontaneously think that it would be a better idea to either (a)
stop running clang-tidy for a normal build and instead run it as a
special build once in a while, or (b) improve
https://github.com/ejfitzgerald/clang-tidy-cache if you find it
deficient in some way (I know nothing about it), or (c) implement
clang-tidy support in ccache or another compiler cache program.

Just a comment on your CMake GitLab issue:

> 2. Add Class.clang-tidy to configuration of extra_files_to_hash of ccache 
> using the command line syntax: --set-config=KEY=VALUE see 
> https://ccache.dev/manual/latest.html

That's not a good idea. --set-config is just a convenience alternative
to manually editing the ccache configuration file. If you run it once
for each compilation you will have race conditions between invocations
and you will mess up the user's ccache configuration. To enable some
ccache setting for a specific compilation you should set the
corresponding environment variable, i.e. CCACHE_EXTRAFILES in this
case.

-- Joel

___
ccache mailing list
ccache@lists.samba.org
https://lists.samba.org/mailman/listinfo/ccache


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

2020-08-14 Thread Christian Ledergerber via ccache

I have created the following issue for cmake to launch the discussion:
https://gitlab.kitware.com/cmake/cmake/-/issues/21092

On 04.08.20 19:46, Joel Rosdahl wrote:

On Sun, 2 Aug 2020 at 19:49, Christian Ledergerber via ccache
 wrote:

In the mean-time I have been thinking some more and what I am afraid of
is that the result will not be correct if the flags to clang-tidy change.

A typical command run by make looks like this:

cd /home/dev/erx-soft/cmake-build-debug/modules/utils && ccache
/home/dev/clion-2020.1.3/bin/cmake/linux/bin/cmake -E __run_co_compile [...]

If I interpret the example command correctly ccache is used as a
prefix to cmake? That won't have any effect; ccache can't cache the
result of cmake so it will just fall back to executing cmake with the
given arguments (and increase some statistics counter).


--launcher=ccache

I guess this means that cmake will execute "ccache $compiler ..." later.


[...] In other words: it seems like ccache could also hash the flags to
clang-tidy. The question: does it?

No, since ccache doesn't see any clang-tidy arguments when cmake
executes "ccache $compiler ..." as mentioned above.


Now that I am looking at the above command line: Will this require to
also modify the cmake binary to generate other command lines?

I have no idea, but it sounds likely.

Here's an idea to consider: You could write the clang-tidy arguments
to a file and set CCACHE_EXTRAFILES to the file. Or just set it to
preexisting .clang-tidy files? Then the ccache results will be
invalidated when the clang-tidy arguments change. That in combination
with the hypothetical mode where ccache would exit with failure on a
cache miss would maybe enough for your initial idea.

-- Joel


___
ccache mailing list
ccache@lists.samba.org
https://lists.samba.org/mailman/listinfo/ccache