Skip to content
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

Don't cache Rust compiles with incremental compilation. Fixes #257 #259

Merged
merged 2 commits into from
Jul 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ matrix:
- os: osx

# rustc version compat
- rust: 1.22.0 # oldest supported version, keep in sync with README.md
- rust: 1.27.0 # oldest supported version, keep in sync with README.md
- rust: beta
- rust: nightly

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Table of Contents (ToC)
Build Requirements
------------------

Sccache is a [Rust](https://www.rust-lang.org/) program. Building it requires `cargo` (and thus `rustc`). sccache currently requires **Rust 1.22**.
Sccache is a [Rust](https://www.rust-lang.org/) program. Building it requires `cargo` (and thus `rustc`). sccache currently requires **Rust 1.27**.

We recommend you install Rust via [Rustup](https://rustup.rs/). The generated binaries can be built so that they are very [portable](#building-portable-binaries). By default `sccache` supports a local disk cache. To build `sccache` with support for `S3` and/or `Redis` cache backends, add `--features=all` or select a specific feature by passing `s3`, `gcs`, and/or `redis`. Refer the [Cargo Documentation](http://doc.crates.io/manifest.html#the-features-section) for details.

Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ for:
target: x86_64-pc-windows-msvc
- channel: nightly
target: x86_64-pc-windows-msvc
- channel: 1.22.0 # Oldest supported version. Keep in sync with README.md.
- channel: 1.27.0 # Oldest supported version. Keep in sync with README.md.
target: x86_64-pc-windows-msvc
# Build a release build on master to make sure it builds.
- channel: stable
Expand Down
19 changes: 18 additions & 1 deletion src/compiler/rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,15 @@ fn parse_arguments(arguments: &[OsString], cwd: &Path) -> CompilerArguments<Pars
if let (Some(name), Some(val)) = (name, val) {
match name {
"extra-filename" => extra_filename = Some(val.to_owned()),
// Incremental compilation makes a mess of sccache's entire world
// view. It produces additional compiler outputs that we don't cache,
// and just letting rustc do its work in incremental mode is likely
// to be faster than trying to fetch a result from cache anyway, so
// don't bother caching compiles where it's enabled currently.
// Longer-term we would like to figure out better integration between
// sccache and rustc in the incremental scenario:
// https://github.com/mozilla/sccache/issues/236
"incremental" => return CompilerArguments::CannotCache("incremental"),
_ => {},
}
}
Expand Down Expand Up @@ -768,7 +777,7 @@ mod test {
match _parse_arguments(&[ $( $s.to_string(), )* ]) {
CompilerArguments::Ok(_) => panic!("Should not have parsed ok: `{}`", stringify!($( $s, )*)),

_ => {}
o @ _ => o,
}
}
}
Expand Down Expand Up @@ -815,6 +824,14 @@ mod test {
assert_eq!(h.externs, ovec!["/foo/target/debug/deps/liblibc-89a24418d48d484a.rlib", "/foo/target/debug/deps/liblog-2f7366be74992849.rlib"]);
}

#[test]
fn test_parse_arguments_incremental() {
parses!("--emit", "link", "foo.rs", "--out-dir", "out", "--crate-name", "foo");
let r = fails!("--emit", "link", "foo.rs", "--out-dir", "out", "--crate-name", "foo",
"-C", "incremental=/foo");
assert_eq!(r, CompilerArguments::CannotCache("incremental"))
}

#[test]
fn test_parse_arguments_dep_info_no_extra_filename() {
let h = parses!("--crate-name", "foo", "src/lib.rs",
Expand Down
3 changes: 3 additions & 0 deletions tests/sccache_cargo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ fn test_rust_cargo() {
trace!("cargo build: {:?}", a);
a.unwrap();
// Now get the stats and ensure that we had a cache hit for the second build.
// Ideally we'd check the stats more usefully here--the test crate has one dependency (itoa)
// so there are two separate compilations, but cargo will build the test crate with
// incremental compilation enabled, so sccache will not cache it.
trace!("sccache --show-stats");
Assert::command(&[&sccache.to_string_lossy()])
.with_args(&["--show-stats", "--stats-format=json"])
Expand Down
10 changes: 10 additions & 0 deletions tests/test-crate/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions tests/test-crate/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ version = "0.1.0"
authors = ["Ted Mielczarek <ted@mielczarek.org>"]

[dependencies]
# Arbitrary crate dependency that doesn't pull in any transitive dependencies.
itoa = "0.3.4"