Skip to content

support MIRI_HOST_SYSROOT env var for stage 0 builds #2415

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

Merged
merged 1 commit into from
Jul 22, 2022
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: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,8 @@ binaries, and as such worth documenting:
crate currently being compiled.
* `MIRI_VERBOSE` when set to any value tells the various `cargo-miri` phases to
perform verbose logging.
* `MIRI_HOST_SYSROOT` is set by bootstrap to tell `cargo-miri` which sysroot to use for *host*
operations.

[testing-miri]: CONTRIBUTING.md#testing-the-miri-driver

Expand Down
10 changes: 6 additions & 4 deletions cargo-miri/bin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,9 @@ fn phase_cargo_miri(mut args: impl Iterator<Item = String>) {
// hope that all they do is ask for the version number -- things could quickly go downhill from here.
// In `main`, we need the value of `RUSTC` to distinguish RUSTC_WRAPPER invocations from rustdoc
// or TARGET_RUNNER invocations, so we canonicalize it here to make it exceedingly unlikely that
// there would be a collision.
// there would be a collision with other invocations of cargo-miri (as rustdoc or as runner).
// We explicitly do this even if RUSTC_STAGE is set, since for these builds we do *not* want the
// bootstrap `rustc` thing in our way! Instead, we have MIRI_HOST_SYSROOT to use for host builds.
cmd.env("RUSTC", &fs::canonicalize(find_miri()).unwrap());

let runner_env_name =
Expand Down Expand Up @@ -929,9 +931,9 @@ fn phase_rustc(mut args: impl Iterator<Item = String>, phase: RustcPhase) {
} else {
// For host crates (but not when we are printing), we might still have to set the sysroot.
if !print {
// When we're running `cargo-miri` from `x.py` we need to pass the sysroot explicitly as rustc
// can't figure out the sysroot on its own unless it's from rustup.
if let Some(sysroot) = std::env::var_os("SYSROOT") {
// When we're running `cargo-miri` from `x.py` we need to pass the sysroot explicitly
// due to bootstrap complications.
if let Some(sysroot) = std::env::var_os("MIRI_HOST_SYSROOT") {
cmd.arg("--sysroot").arg(sysroot);
}
}
Expand Down