-
Notifications
You must be signed in to change notification settings - Fork 558
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make hashes less dependent on source and build paths #207
Comments
Forget everything I've said about compiler flags and paths. I did some debugging of Same thing for the environment flags, where only However, the preprocessor output contains lots of paths, at least for gcc. These are typically of the form: # 1 "/home/alice/git/coolproject/modules/foo/src/cool_source.cpp"
# 1 "/home/alice/git/coolproject-build/Release//"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "/usr/include/stdc-predef.h" 1 3 4
# 1 "<command-line>" 2
# 1 "/home/alice/git/coolproject/modules/foo/src/cool_source.cpp"
... A relatively simple solution (that hopefully works) would be to strip the preprocessor output of all lines starting with Edit: Or simply pass |
PR #208 addresses this issue for GCC (and hopefully Clang). I'm not sure if the corresponding problem exists for MSVC. |
Does this issue affect other languages like rust? |
It does! #196 has some discussion. There's a PR with a potential fix for Rust, but it'll have the same problem as C compilations (paths in debug info will be wrong), and I'm not sure it'll work properly even with that fix, since it looks like the build directory winds up in one of the internal rlib hashes, which might make rustc unhappy. |
Thank you for that kind reply. I think cargo could structure things differently on its end to remove some unnecessary duplication and simultaneously make sccache's life easier; I had originally proposed some sort of fs-local cache on cargo's end in a github issue and that's when I was first informed about sccache and the difficult problems it was trying to solve :) |
…lla#207 Some rustc arguments like --out-dir, -L, and --extern contain absolute paths which make building the same crate (from crates.io) in different projects unable to get cache hits despite being otherwise the same. This patch omits those arguments from the hash calculation which makes sccache much more useful for local development. For additional safety we add the cwd to the hash key, since that winds up in the rlib and otherwise this patch could result in some compiles returning invalid results from cache.
Hi - I have just upgraded to a build including these fixes and it seems to work with two directories on the same machine, however I am still getting 100% cache misses when running on a different machine. Can you suggest how I go about debugging this to establish the cause of the cache misses? |
…lla#207 Some rustc arguments like --out-dir, -L, and --extern contain absolute paths which make building the same crate (from crates.io) in different projects unable to get cache hits despite being otherwise the same. This patch omits those arguments from the hash calculation which makes sccache much more useful for local development. For additional safety we add the cwd to the hash key, since that winds up in the rlib and otherwise this patch could result in some compiles returning invalid results from cache.
Currently I was not able to properly use a shared cache between two machines without them using the exact same source and build folders, which seems quite unnecessary.
Apparently (according to #4 ), there are already some thoughts for how to fix this?
My gut feeling is that since the preprocessed result is what's being hashed (together with the command line flags that affect how the compilation is performed), things like file names (input, output) and include paths should not be important at all, so you should be able to remove them from the hash completely, right? (this includes-I
,-o
,-MT
,-MF
,-include
etc, plus the source file name)The text was updated successfully, but these errors were encountered: