-
Notifications
You must be signed in to change notification settings - Fork 552
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
Support rustup overrides properly #87
Comments
cc @brson, you may have thoughts here as well |
Could it be possibly easier to resolve the compiler path, but instead hash the compiler binary itself and use that as key rather than the path? This would also remove all needs to duplicate the logic of |
The cache I'm discussing here is only in memory on the local machine where you're running sccache: Lines 825 to 865 in 24f4306
For the hashes for compiled objects themselves we include hashes of the full contents of the Rust compiler's sysroot. Unfortunately we only do this the first time we locate a new compiler so this could result in invalid cache entries being stored when this situation is encountered. |
So the simplest version would be to track changes of the compiler sysroot (inotify, is there something similiar on windows?) and additionally check on launch of the server and invalidate the cache on each of those events, causing a full checksum of the sysroot to be done? |
I think the best solution would still be something similar to what I proposed in my initial comment: make the Rust compiler cache two-tiered. The first tier would just be keyed by path+mtime, the second tier would check if this is a rustup rustc and if so use
Then the second tier could use that path+mtime to cache compiler info since that's the real compiler binary and will change if it gets updated. Additionally this would fix the original problem as stated where /src/a might compile with stable rust, /src/b might have an override for nightly rust, but they are both using the rustup shim |
@luser what's the preferred way of detecting |
I would start with something simple: take the path to fn has_rustup(rustc: &Path) -> bool {
rustc.with_file_name("rustup").with_extension(std::env::consts::EXE_EXTENSION).is_file()
} (you might want something slightly fancier, the |
I am currently using |
It would be awesome if you could review #666 :) |
Fixed by #666. |
@luser there seems to be an uncovered edgecase which can still trigger this behaviour under certain unknown circumstances. I did not get around to investigate the issue yet, though it's been a few months (I can't seem to find the initial comments right now pointing this out, I have a reproducible test case). |
For the initial cut at Rust support we're not handling rustup overrides, since we're caching compiler info purely by compiler path. With rustup, the same compiler binary can invoke different Rust toolchains depending on the cwd, so we'll have to handle that somehow.
I was thinking of using a two-tier cache where we cache the "is this a Rust compiler?" result in the server code as we currently do, but then internally check for the presence of a
rustup
binary next torustc
and runrustup which rustc
or something in the compile cwd to locate the actual compiler in use, and then have a cache of compilers using that path.The text was updated successfully, but these errors were encountered: