Created attachment 7008 [details]
Test case showing ccache wrongly using the cached object file
ccache's 3.x optimization, not to call the preprocessor, fails when using the CPATH environment variable to add additional include paths. The reason for this is, ccache 3.x does not include this environment variable in the hash generation for the .manifest file.
A Test case for this bug is attached. The last line should print b/foo.h instead of a/foo.h.
This is a regression from ccache 2.4, which behaves correctly regarding this issue, as it uses the preprocessor which does correctly handle the CPATH environment variable.
A fix should not only take care of CPATH but also of the following variables, as the manpages of gcc and clang suggest: C_INCLUDE_PATH, CPLUS_INCLUDE_PATH, OBJC_INCLUDE_PATH and OBJCPLUS_INCLUDE_PATH (clang only).
The related variable LIBRARY_PATH, to add additional paths to look for library files, should be of no concern, as ccache doesn't cache calls to the linker.
Fixed in 8328b3b93525cb4091054bd2162cc3ddc970ef3d.
Included in v3.1.7.