Instead of hashing the compiler's mtime+size to detect the compiler version, it should be possible to hash the output of a custom command like "$compiler -dumpspecs". See also Debian bug report #506968: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=506968
I plan to implement this in ccache 3.1.
Implemented.