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 setup no longer works for locally installed toolchains #3160

Closed
matthiaskrgr opened this issue Nov 12, 2023 · 8 comments
Closed
Labels
A-cargo Area: affects the cargo wrapper (cargo miri) C-bug Category: This is a bug.

Comments

@matthiaskrgr
Copy link
Member

matthiaskrgr commented Nov 12, 2023

I have a locally installed toolchain that I installed m into RUSTUP_HOME via x.py install.

When I now run cargo +mytoolchain miri setup, this no longer works:

at 18:15:47 ❯ RUST_BACKTRACE=1 ~/.cargo/bin/cargo +local-debug-assertions miri setup
Preparing a sysroot for Miri (target: x86_64-unknown-linux-gnu)...
thread 'main' panicked at src/cargo/util/rustc.rs:86:13:
commit hash must be a hex string
stack backtrace:
   0: rust_begin_unwind
             at /home/matthias/vcs/github/rust_debug_assertions/library/std/src/panicking.rs:645:5
   1: core::panicking::panic_fmt
             at /home/matthias/vcs/github/rust_debug_assertions/library/core/src/panicking.rs:72:14
   2: <cargo::util::rustc::Rustc>::new::{closure#2}
   3: <core::option::Option<&str>>::map::<alloc::string::String, <cargo::util::rustc::Rustc>::new::{closure#2}>
             at /home/matthias/vcs/github/rust_debug_assertions/library/core/src/option.rs:1072:29
   4: <cargo::util::rustc::Rustc>::new
             at /home/matthias/vcs/github/rust_debug_assertions/src/tools/cargo/src/cargo/util/rustc.rs:85:57
   5: <cargo::util::config::Config>::load_global_rustc
             at /home/matthias/vcs/github/rust_debug_assertions/src/tools/cargo/src/cargo/util/config/mod.rs:414:9
   6: <cargo::core::compiler::build_context::target_info::RustcTargetData>::new
             at /home/matthias/vcs/github/rust_debug_assertions/src/tools/cargo/src/cargo/core/compiler/build_context/target_info.rs:885:21
   7: cargo::ops::cargo_compile::create_bcx
             at /home/matthias/vcs/github/rust_debug_assertions/src/tools/cargo/src/cargo/ops/cargo_compile/mod.rs:240:27
   8: cargo::ops::cargo_compile::compile_ws
             at /home/matthias/vcs/github/rust_debug_assertions/src/tools/cargo/src/cargo/ops/cargo_compile/mod.rs:151:15
   9: cargo::ops::cargo_compile::compile_with_exec
             at /home/matthias/vcs/github/rust_debug_assertions/src/tools/cargo/src/cargo/ops/cargo_compile/mod.rs:141:5
  10: cargo::ops::cargo_compile::compile
             at /home/matthias/vcs/github/rust_debug_assertions/src/tools/cargo/src/cargo/ops/cargo_compile/mod.rs:128:5
  11: cargo::commands::check::exec
             at /home/matthias/vcs/github/rust_debug_assertions/src/tools/cargo/src/bin/cargo/commands/check.rs:56:5
  12: cargo::cli::main
             at /home/matthias/vcs/github/rust_debug_assertions/src/tools/cargo/src/bin/cargo/cli.rs:184:5
  13: cargo::main
             at /home/matthias/vcs/github/rust_debug_assertions/src/tools/cargo/src/bin/cargo/main.rs:31:9
  14: <fn() as core::ops::function::FnOnce<()>>::call_once
             at /home/matthias/vcs/github/rust_debug_assertions/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
fatal error: failed to build sysroot: sysroot build failed
@matthiaskrgr
Copy link
Member Author

wondering if its related to rust-lang/rust#117797

@RalfJung
Copy link
Member

RalfJung commented Nov 12, 2023

The panic originates here it seems. Unfortunately the panic message doesn't say what it got instead of a hex string.

installed m into RUSTUP_HOME via x.py install.

FWIW I don't know if this ever worked. I usually use a toolchain that's linked to my rustc/build/host directory.

@RalfJung
Copy link
Member

This looks like a cargo or rustc bug to me, Miri doesn't change the output of commit-hash... but it's hard to say. Miri does intercept rustc but when that goes wrong, I'd expect the output to not contain commit-hash: at all any more, and given the codepath this is on, it seems the output was present, it just did not have the expected format.

rust-lang/cargo#12963 should make this easier to debug at least.

@RalfJung RalfJung added C-bug Category: This is a bug. A-cargo Area: affects the cargo wrapper (cargo miri) labels Nov 12, 2023
@RalfJung
Copy link
Member

When I ask that locally built rustc for its commit-hash, I get unknown:

$ rustc +rustc-s1 -vV
rustc 1.76.0-dev
binary: rustc
commit-hash: unknown
commit-date: unknown
host: x86_64-unknown-linux-gnu
release: 1.76.0-dev
LLVM version: 17.0.4

So that would explain why cargo panics. Cc @weihanglo @ehuss (from rust-lang/cargo#12625)

What I don't understand is why this does not fail in ./x.py test miri. Maybe that is still using the bootstrap cargo?

@RalfJung
Copy link
Member

Maybe cargo should recognize unknown and treat it as None (not having a commit-hash already seems to be an option, just having an invalid one is bad).

bors added a commit to rust-lang/cargo that referenced this issue Nov 12, 2023
make some debug assertion failures more informative

In rust-lang/miri#3160, we got a report of a user running into an assertion failure in cargo. Unfortunately the failure message is not very informative. This PR hopefully makes that failure easier to debug.
@ehuss
Copy link
Contributor

ehuss commented Nov 12, 2023

Sorry, I forgot about that situation. @weihanglo, can you follow up on this?

@weihanglo
Copy link
Member

Just posted a PR: rust-lang/cargo#12965

Let me know if it doesn't work.

@RalfJung
Copy link
Member

Fixed by rust-lang/cargo#12965. Thanks!

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-bug Category: This is a bug.
Projects
None yet
Development

No branches or pull requests

4 participants