]> git.ipfire.org Git - thirdparty/ccache.git/commit
Always include input file path in direct mode hash
authorJoel Rosdahl <joel@rosdahl.net>
Sat, 16 Nov 2019 21:59:33 +0000 (22:59 +0100)
committerJoel Rosdahl <joel@rosdahl.net>
Sun, 17 Nov 2019 19:43:15 +0000 (20:43 +0100)
commit02bcef0d82ac8f1397c9b13bf1215cf770e6b7da
treead984e7b7ba16165f6e74ea223bdddd9577da881
parent4540e216522070f9d2961a7b118e0b2651215698
Always include input file path in direct mode hash

The “file_macro sloppiness” mode is a way of opting out of inclusion of
the input file path in the direct mode hash. This can produce a false
cache hit in the following scenario:

- a/r.h exists.
- a/x.c has #include "r.h".
- b/x.c is identical to a/x.c.
- Compiling a/x.c records a/r.h in the manifest.
- Compiling b/x.c results in a false cache hit since a/x.c and b/x.c
  share manifests and a/r.h exists.

Therefore, ditch the file_macro sloppiness mode so that the input file
path is always included in the direct mode hash.

This bug has existed ever since the file_macro sloppiness was introduced
in eb5d9bd3beb5 (ccache 3.0). It has remained undetected since
compilations tend to use .d files and ccache before 3.7.5 added an
implicit “-MQ <output_file_path>” argument, thus in practice including
the output file path in the hash and therefore making manifests unique
when the object file path mirrors the source file path. However, ccache
3.7.5 no longer adds the implicit -MQ option, thus exposing the bug.

Fixes #489.

(cherry picked from commit 404eedde2b8c7a048ea1f68a8e70e49c5ea74df2)
doc/MANUAL.adoc
src/Config.cpp
src/ccache.cpp
src/ccache.hpp
test/suites/direct.bash
unittest/test_Config.cpp