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

cargo-miri does not work with sccache #1421

Closed
TriplEight opened this issue May 20, 2020 · 7 comments · Fixed by #1426
Closed

cargo-miri does not work with sccache #1421

TriplEight opened this issue May 20, 2020 · 7 comments · Fixed by #1426
Labels
A-cargo Area: affects the cargo wrapper (cargo miri) C-support Category: Not necessarily a bug, but someone asking for support

Comments

@TriplEight
Copy link

Must be related to #573

<>build log<>
$ cargo -vV
cargo 1.45.0-nightly (cb06cb269 2020-05-08)
release: 1.45.0
commit-hash: cb06cb2696df2567ce06d1a39b1b40612a29f853
commit-date: 2020-05-08
$ rustc -vV
rustc 1.45.0-nightly (75e1463c5 2020-05-13)
binary: rustc
commit-hash: 75e1463c52aaea25bd32ed53c73797357e561cce
commit-date: 2020-05-13
host: x86_64-unknown-linux-gnu
release: 1.45.0-nightly
LLVM version: 9.0
$ rustup show
Default host: x86_64-unknown-linux-gnu
rustup home:  /usr/local/rustup
installed toolchains
--------------------
stable-x86_64-unknown-linux-gnu
nightly-2020-05-14-x86_64-unknown-linux-gnu (default)
nightly-x86_64-unknown-linux-gnu
installed targets for active toolchain
--------------------------------------
wasm32-unknown-unknown
x86_64-unknown-linux-gnu
active toolchain
----------------
nightly-2020-05-14-x86_64-unknown-linux-gnu (default)
rustc 1.45.0-nightly (75e1463c5 2020-05-13)
$ bash --version
GNU bash, version 5.0.3(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2019 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
$ cargo miri --version; rustup component add rust-src; pushd core; cargo miri test --verbose -- -- storage2; popd
miri 0.1.0 (10419b3 2020-05-11)
info: downloading component 'rust-src'
info: installing component 'rust-src'
/builds/parity/ink/core /builds/parity/ink
Running `"/usr/local/rustup/toolchains/nightly-2020-05-14-x86_64-unknown-linux-gnu/bin/cargo" "install" "xargo" "-f"` to install a recent enough xargo.
    Updating crates.io index
 Downloading crates ...
  Downloaded xargo v0.3.20
  Installing xargo v0.3.20
 Downloading crates ...
  Downloaded addr2line v0.12.1
  Downloaded tempdir v0.3.7
  Downloaded walkdir v1.0.7
  Downloaded num-traits v0.2.11
  Downloaded serde v0.8.23
  Downloaded rand v0.4.6
  Downloaded object v0.19.0
  Downloaded libc v0.2.70
  Downloaded rustc-serialize v0.3.24
  Downloaded rustc-demangle v0.1.16
  Downloaded remove_dir_all v0.5.2
  Downloaded num-traits v0.1.43
  Downloaded dtoa v0.2.2
  Downloaded gimli v0.21.0
  Downloaded fs2 v0.4.3
  Downloaded error-chain v0.7.2
  Downloaded dirs v1.0.5
  Downloaded cfg-if v0.1.10
  Downloaded backtrace v0.3.48
  Downloaded autocfg v1.0.0
  Downloaded toml v0.2.1
  Downloaded rustc_version v0.1.7
  Downloaded serde_json v0.8.6
  Downloaded same-file v0.1.3
  Downloaded itoa v0.1.1
  Downloaded semver v0.1.20
   Compiling libc v0.2.70
   Compiling autocfg v1.0.0
   Compiling gimli v0.21.0
   Compiling cfg-if v0.1.10
   Compiling object v0.19.0
   Compiling rustc-demangle v0.1.16
   Compiling xargo v0.3.20
   Compiling same-file v0.1.3
   Compiling semver v0.1.20
   Compiling serde v0.8.23
   Compiling itoa v0.1.1
   Compiling rustc-serialize v0.3.24
   Compiling remove_dir_all v0.5.2
   Compiling dtoa v0.2.2
   Compiling walkdir v1.0.7
   Compiling num-traits v0.2.11
   Compiling rustc_version v0.1.7
   Compiling rand v0.4.6
   Compiling dirs v1.0.5
   Compiling fs2 v0.4.3
   Compiling num-traits v0.1.43
   Compiling tempdir v0.3.7
   Compiling serde_json v0.8.6
   Compiling addr2line v0.12.1
   Compiling toml v0.2.1
   Compiling backtrace v0.3.48
   Compiling error-chain v0.7.2
    Finished release [optimized] target(s) in 24.83s
  Installing /usr/local/cargo/bin/xargo
  Installing /usr/local/cargo/bin/xargo-check
   Installed package `xargo v0.3.20` (executables `xargo`, `xargo-check`)
error: failed to run `rustc` to learn about target-specific information
Caused by:
  process didn't exit successfully: `sccache /usr/local/rustup/toolchains/nightly-2020-05-14-x86_64-unknown-linux-gnu/bin/miri - --crate-name ___ --print=file-names --crate-type bin --crate-type rlib --crate-type dylib --crate-type cdylib --crate-type staticlib --crate-type proc-macro --print=sysroot --print=cfg` (exit code: 2)
--- stderr
error: failed to execute compile
caused by: Compiler not supported: "error: Unrecognized option: \'E\'\n\n"
error: `"/usr/local/rustup/toolchains/nightly-2020-05-14-x86_64-unknown-linux-gnu/bin/cargo" "check" "--release" "--manifest-path" "/tmp/xargo.fvDL6G47j2QU/Cargo.toml" "--target" "x86_64-unknown-linux-gnu" "-p" "std"` failed with exit code: Some(101)
   0: error_chain::make_backtrace
   1: <error_chain::State as core::default::Default>::default
   2: <std::process::Command as xargo::extensions::CommandExt>::run
   3: xargo::sysroot::build
   4: xargo::sysroot::update
   5: xargo::main_inner
   6: std::rt::lang_start::{{closure}}
   7: std::rt::lang_start_internal::{{closure}}
             at /rustc/75e1463c52aaea25bd32ed53c73797357e561cce/src/libstd/rt.rs:52
      std::panicking::try::do_call
             at /rustc/75e1463c52aaea25bd32ed53c73797357e561cce/src/libstd/panicking.rs:297
      std::panicking::try
             at /rustc/75e1463c52aaea25bd32ed53c73797357e561cce/src/libstd/panicking.rs:274
      std::panic::catch_unwind
             at /rustc/75e1463c52aaea25bd32ed53c73797357e561cce/src/libstd/panic.rs:394
      std::rt::lang_start_internal
             at /rustc/75e1463c52aaea25bd32ed53c73797357e561cce/src/libstd/rt.rs:51
   8: main
   9: __libc_start_main
  10: _start
fatal error: Failed to run xargo

so in CI, where I use sccache everywhere by default it helps me to

unset RUSTC_WRAPPER
cargo miri setup # to avoid if it asks for sudden new dependencies
cargo miri test ...
@bjorn3
Copy link
Member

bjorn3 commented May 20, 2020

process didn't exit successfully: sccache /usr/local/rustup/toolchains/nightly-2020-05-14-x86_64-unknown-linux-gnu/bin/miri - --crate-name ___ --print=file-names --crate-type bin --crate-type rlib --crate-type dylib --crate-type cdylib --crate-type staticlib --crate-type proc-macro --print=sysroot --print=cfg (exit code: 2)
[...]
caused by: Compiler not supported: "error: Unrecognized option: 'E'\n\n"

The problem here is that sccache doesn't support using miri as compiler. It only checks for rustc and clippy-driver as rustc compilers. In all other cases it assumes that it is a C compiler and passes -E as argument, which miri doesn't support.

https://github.com/mozilla/sccache/blob/f50207525810c12f9dbad2b9e92892d055b1b38a/src/compiler/compiler.rs#L906

https://github.com/mozilla/sccache/blob/f50207525810c12f9dbad2b9e92892d055b1b38a/src/compiler/compiler.rs#L1052

@RalfJung
Copy link
Member

RalfJung commented May 20, 2020

Must be related to #573

I don't think so. That is us overwriting RUSTC_WRAPPER. The error you see happens when we call xargo, which is before we do anything with RUST_WRAPPER.

I have no experience with sccache, so I am not sure if the better solution is to add "miri" as a rustc name in sccache, or to unset RUSTC_WRAPPER in cargo miri. We already effectively unset it for the actual project compilation anyway, just not for xargo.

@RalfJung RalfJung added A-cargo Area: affects the cargo wrapper (cargo miri) C-support Category: Not necessarily a bug, but someone asking for support labels May 20, 2020
@RalfJung RalfJung changed the title have to unset RUSTC_WRAPPER to bypass fatal error: Failed to run xargo cargo-miri dos not work with sccache May 21, 2020
@RalfJung RalfJung changed the title cargo-miri dos not work with sccache cargo-miri does not work with sccache May 21, 2020
@RalfJung
Copy link
Member

I proposed a fix in #1426.
@TriplEight would that work for you, or do you require Miri builds to actually be sccache'd? I'm afraid I wouldn't know what it takes to achieve that.

@TriplEight
Copy link
Author

Thanks for mentioning!
It would be really great to have it cached (both with sccache and CARGO_TARGET_DIR), because it takes a really long time on heavy projects.

But currently it seems to break my CI completely.
The setup is: I have everything needed installed in docker image and CI just checkouts the commit and runs the cargo command. It uses sccache and CARGO_TARGET_DIR. And what happened is I've added miri, xargo and rust-src to the CI docker image and started having failures all over CI (not just in miri job).

I believe this fix is going to fix what I've just described. Can share logs and whatever code is needed, but tomorrow.

@RalfJung
Copy link
Member

It would be really great to have it cached (both with sccache and CARGO_TARGET_DIR), because it takes a really long time on heavy projects.

What is taking long is likely the actual evaluation -- as in, running the program. I don't think it makes any sense to cache that.^^

CARGO_TARGET_DIR is a separate problem, see #1311.

@inflation
Copy link

inflation commented Jan 16, 2021

It seems if I set the rustc-wrapper in ~/.cargo/config, it didn't get fixed. 😕

@RalfJung
Copy link
Member

RalfJung commented Jul 23, 2022

@inflation

It seems if I set the rustc-wrapper in ~/.cargo/config, it didn't get fixed.

Ah, sorry I missed this. It's usually better to open a new issue rather than commenting in an existing closed one.
A new issue for this has just been created: #2429.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-cargo Area: affects the cargo wrapper (cargo miri) C-support Category: Not necessarily a bug, but someone asking for support
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants