rustc nightly added support for adding extra annotations in the form of Makefile comments to dep-info files to track environment variables accessed by way of the env!
macro. sccache should parse these directives and add referenced environment variables as hash inputs.
@alexcrichton has a pull request open to add support to cargo. I'm sure it'd be straightforward to add support to sccache's parser.