]> 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 14:34:37 +0000 (15:34 +0100)
commit404eedde2b8c7a048ea1f68a8e70e49c5ea74df2
tree67087e65d3594f600b62a4570f23a2e3cac1c1b0
parent75520370b8f0c5afb8141b9808de69302d085d21
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.
doc/MANUAL.adoc
src/ccache.c
src/ccache.h
src/confitems.c
test/suites/direct.bash
unittest/test_conf.c