Repository: mozilla/sccache

Issue #87: Support rustup overrides properly
Created: 2017-03-23T10:46:32Z
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 to rustc and run rustup 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.

Duplicate issue #663: switching from stable to nightly causes compiler version mismatch
Created: 2020-02-12T07:39:50Z
Compiling https://github.com/wisespace-io/u2f-rs
accidentally with cargo +stable build  followed by cargo +nightly build consistently gives:
error[E0514]: found crate `autocfg` compiled by an incompatible version of rustc
 --> /home/bernhard/.cargo/registry/src/github.com-1ecc6299db9ec823/num-traits-0.2.11/build.rs:1:1
  |
1 | extern crate autocfg;
  | ^^^^^^^^^^^^^^^^^^^^^
  |
  = help: please recompile that crate using this compiler (rustc 1.43.0-nightly (58b834344 2020-02-05))
  = note: the following crate versions were found:
          crate `autocfg` compiled by rustc 1.41.0 (5e1a79984 2020-01-27): /home/bernhard/Projects/u2f-rs/example/target/debug/deps/libautocfg-65a01c47eff2b1b4.rlib

error[E0514]: found crate `version_check` compiled by an incompatible version of rustc
 --> /home/bernhard/.cargo/registry/src/github.com-1ecc6299db9ec823/unicase-1.4.2/build.rs:1:1
  |
1 | extern crate version_check as rustc;
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = help: please recompile that crate using this compiler (rustc 1.43.0-nightly (58b834344 2020-02-05))
  = note: the following crate versions were found:
          crate `version_check` compiled by rustc 1.41.0 (5e1a79984 2020-01-27): /home/bernhard/Projects/u2f-rs/example/target/debug/deps/libversion_check-c40121d46ce38ebb.rlib

error: aborting due to previous error

error[E0514]: found crate `yansi` compiled by an incompatible version of rustc
 --> /home/bernhard/.cargo/registry/src/github.com-1ecc6299db9ec823/rocket_codegen-0.4.2/build.rs:3:1
  |
3 | extern crate yansi;
  | ^^^^^^^^^^^^^^^^^^^
  |
  = help: please recompile that crate using this compiler (rustc 1.43.0-nightly (58b834344 2020-02-05))
  = note: the following crate versions were found:
          crate `yansi` compiled by rustc 1.41.0 (5e1a79984 2020-01-27): /home/bernhard/Projects/u2f-rs/example/target/debug/deps/libyansi-94170d1d29303cf0.rlib

error[E0514]: found crate `autocfg` compiled by an incompatible version of rustc
 --> /home/bernhard/.cargo/registry/src/github.com-1ecc6299db9ec823/openssl-sys-0.9.54/build/main.rs:1:1
  |
1 | extern crate autocfg;
  | ^^^^^^^^^^^^^^^^^^^^^
  |
  = help: please recompile that crate using this compiler (rustc 1.43.0-nightly (58b834344 2020-02-05))
  = note: the following crate versions were found:
          crate `autocfg` compiled by rustc 1.41.0 (5e1a79984 2020-01-27): /home/bernhard/Projects/u2f-rs/example/target/debug/deps/libautocfg-65a01c47eff2b1b4.rlib

error: aborting due to previous error

error: aborting due to previous error

error[E0514]: found crate `cc` compiled by an incompatible version of rustc
  --> /home/bernhard/.cargo/registry/src/github.com-1ecc6299db9ec823/ring-0.13.5/build.rs:36:1
   |
36 | extern crate cc;
   | ^^^^^^^^^^^^^^^^
   |
   = help: please recompile that crate using this compiler (rustc 1.43.0-nightly (58b834344 2020-02-05))
   = note: the following crate versions were found:
           crate `cc` compiled by rustc 1.41.0 (5e1a79984 2020-01-27): /home/bernhard/Projects/u2f-rs/example/target/debug/deps/libcc-a44f11a1bf26316e.rlib

error: aborting due to previous error

error: aborting due to previous error

error[E0514]: found crate `yansi` compiled by an incompatible version of rustc
 --> /home/bernhard/.cargo/registry/src/github.com-1ecc6299db9ec823/pear_codegen-0.1.2/build.rs:1:1
  |
1 | extern crate yansi;
  | ^^^^^^^^^^^^^^^^^^^
  |
  = help: please recompile that crate using this compiler (rustc 1.43.0-nightly (58b834344 2020-02-05))
  = note: the following crate versions were found:
          crate `yansi` compiled by rustc 1.41.0 (5e1a79984 2020-01-27): /home/bernhard/Projects/u2f-rs/example/target/debug/deps/libyansi-c82656b56c0bde2d.rlib

error: aborting due to previous error

error: could not compile `rocket_codegen`.
warning: build failed, waiting for other jobs to finish...
error[E0514]: found crate `autocfg` compiled by an incompatible version of rustc
 --> /home/bernhard/.cargo/registry/src/github.com-1ecc6299db9ec823/indexmap-1.3.2/build.rs:1:1
  |
1 | extern crate autocfg;
  | ^^^^^^^^^^^^^^^^^^^^^
  |
  = help: please recompile that crate using this compiler (rustc 1.43.0-nightly (58b834344 2020-02-05))
  = note: the following crate versions were found:
          crate `autocfg` compiled by rustc 1.41.0 (5e1a79984 2020-01-27): /home/bernhard/Projects/u2f-rs/example/target/debug/deps/libautocfg-65a01c47eff2b1b4.rlib

error: could not compile `num-traits`.
warning: build failed, waiting for other jobs to finish...
error: could not compile `unicase`.
warning: build failed, waiting for other jobs to finish...
error: aborting due to previous error

error[E0514]: found crate `autocfg` compiled by an incompatible version of rustc
 --> /home/bernhard/.cargo/registry/src/github.com-1ecc6299db9ec823/num-integer-0.1.42/build.rs:1:1
  |
1 | extern crate autocfg;
  | ^^^^^^^^^^^^^^^^^^^^^
  |
  = help: please recompile that crate using this compiler (rustc 1.43.0-nightly (58b834344 2020-02-05))
  = note: the following crate versions were found:
          crate `autocfg` compiled by rustc 1.41.0 (5e1a79984 2020-01-27): /home/bernhard/Projects/u2f-rs/example/target/debug/deps/libautocfg-65a01c47eff2b1b4.rlib

error: could not compile `openssl-sys`.
warning: build failed, waiting for other jobs to finish...
error: aborting due to previous error

error[E0514]: found crate `yansi` compiled by an incompatible version of rustc
 --> /home/bernhard/.cargo/registry/src/github.com-1ecc6299db9ec823/rocket-0.4.2/build.rs:3:1
  |
3 | extern crate yansi;
  | ^^^^^^^^^^^^^^^^^^^
  |
  = help: please recompile that crate using this compiler (rustc 1.43.0-nightly (58b834344 2020-02-05))
  = note: the following crate versions were found:
          crate `yansi` compiled by rustc 1.41.0 (5e1a79984 2020-01-27): /home/bernhard/Projects/u2f-rs/example/target/debug/deps/libyansi-94170d1d29303cf0.rlib

error: aborting due to previous error

error: could not compile `pear_codegen`.
warning: build failed, waiting for other jobs to finish...
error: could not compile `ring`.
warning: build failed, waiting for other jobs to finish...
error: could not compile `num-integer`.
warning: build failed, waiting for other jobs to finish...
error: could not compile `indexmap`.
warning: build failed, waiting for other jobs to finish...
error: could not compile `rocket`.
warning: build failed, waiting for other jobs to finish...
error[E0514]: found crate `cfg_if` compiled by an incompatible version of rustc
   --> /home/bernhard/.cargo/registry/src/github.com-1ecc6299db9ec823/log-0.4.8/src/lib.rs:284:1
    |
284 | extern crate cfg_if;
    | ^^^^^^^^^^^^^^^^^^^^
    |
    = help: please recompile that crate using this compiler (rustc 1.43.0-nightly (58b834344 2020-02-05))
    = note: the following crate versions were found:
            crate `cfg_if` compiled by rustc 1.41.0 (5e1a79984 2020-01-27): /home/bernhard/Projects/u2f-rs/example/target/debug/deps/libcfg_if-3870ce3f32a9348c.rmeta

error: aborting due to previous error

error: could not compile `log`.
warning: build failed, waiting for other jobs to finish...
error[E0514]: found crate `unicode_xid` compiled by an incompatible version of rustc
  --> /home/bernhard/.cargo/registry/src/github.com-1ecc6299db9ec823/proc-macro2-0.4.30/src/lib.rs:88:1
   |
88 | extern crate unicode_xid;
   | ^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = help: please recompile that crate using this compiler (rustc 1.43.0-nightly (58b834344 2020-02-05))
   = note: the following crate versions were found:
           crate `unicode_xid` compiled by rustc 1.41.0 (5e1a79984 2020-01-27): /home/bernhard/Projects/u2f-rs/example/target/debug/deps/libunicode_xid-fd70fbf6e9195813.rmeta

error: aborting due to previous error

error: could not compile `proc-macro2`.
warning: build failed, waiting for other jobs to finish...
error[E0514]: found crate `foreign_types_shared` compiled by an incompatible version of rustc
   --> /home/bernhard/.cargo/registry/src/github.com-1ecc6299db9ec823/foreign-types-0.3.2/src/lib.rs:181:1
    |
181 | extern crate foreign_types_shared;
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = help: please recompile that crate using this compiler (rustc 1.43.0-nightly (58b834344 2020-02-05))
    = note: the following crate versions were found:
            crate `foreign_types_shared` compiled by rustc 1.41.0 (5e1a79984 2020-01-27): /home/bernhard/Projects/u2f-rs/example/target/debug/deps/libforeign_types_shared-59a8d0e5c1b75bb4.rmeta

error: aborting due to previous error

error: could not compile `foreign-types`.
warning: build failed, waiting for other jobs to finish...
error[E0514]: found crate `matches` compiled by an incompatible version of rustc
  --> /home/bernhard/.cargo/registry/src/github.com-1ecc6299db9ec823/unicode-bidi-0.3.4/src/lib.rs:65:1
   |
65 | extern crate matches;
   | ^^^^^^^^^^^^^^^^^^^^^
   |
   = help: please recompile that crate using this compiler (rustc 1.43.0-nightly (58b834344 2020-02-05))
   = note: the following crate versions were found:
           crate `matches` compiled by rustc 1.41.0 (5e1a79984 2020-01-27): /home/bernhard/Projects/u2f-rs/example/target/debug/deps/libmatches-67ead5aec7e2754f.rmeta

error: aborting due to previous error

error: could not compile `unicode-bidi`.
warning: build failed, waiting for other jobs to finish...
error[E0514]: found crate `same_file` compiled by an incompatible version of rustc
   --> /home/bernhard/.cargo/registry/src/github.com-1ecc6299db9ec823/walkdir-2.3.1/src/lib.rs:120:5
    |
120 | use same_file::Handle;
    |     ^^^^^^^^^
    |
    = help: please recompile that crate using this compiler (rustc 1.43.0-nightly (58b834344 2020-02-05))
    = note: the following crate versions were found:
            crate `same_file` compiled by rustc 1.41.0 (5e1a79984 2020-01-27): /home/bernhard/Projects/u2f-rs/example/target/debug/deps/libsame_file-e3096f16f9f7f776.rmeta

error: aborting due to previous error

error: could not compile `walkdir`.
warning: build failed, waiting for other jobs to finish...
error[E0514]: found crate `smallvec` compiled by an incompatible version of rustc
  --> /home/bernhard/.cargo/registry/src/github.com-1ecc6299db9ec823/unicode-normalization-0.1.12/src/lib.rs:44:1
   |
44 | extern crate smallvec;
   | ^^^^^^^^^^^^^^^^^^^^^^
   |
   = help: please recompile that crate using this compiler (rustc 1.43.0-nightly (58b834344 2020-02-05))
   = note: the following crate versions were found:
           crate `smallvec` compiled by rustc 1.41.0 (5e1a79984 2020-01-27): /home/bernhard/Projects/u2f-rs/example/target/debug/deps/libsmallvec-8787173a1221911e.rmeta

error: aborting due to previous error

error: could not compile `unicode-normalization`.
warning: build failed, waiting for other jobs to finish...
error: build failed

Expected:
Graceful expunging cache entries OR being able to distinguish between compiler versions as part of the key.
Backend:
redis
dist-client/dist-server

Closing comment (2020-02-12T14:31:06Z): I'm going to close this as a dup of #87.  I agree that the underlying issue makes a shared compilation cache very difficult, but given that determining the actual underlying binary is hard, and the underlying binary isn't fixed because of toolchain overrides that crates can specify, I'm not sure how to fix it.  Firefox has fixed it by resolving the "real" rustc prior to invoking cargo and ignoring toolchain overrides, but I understand that's not feasible for everybody.