Skip to content

Commit be9771b

Browse files
committed
Auto merge of rust-lang#2564 - RalfJung:no-more-xargo, r=oli-obk
2 parents 4023c87 + a773d47 commit be9771b

File tree

10 files changed

+166
-219
lines changed

10 files changed

+166
-219
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,14 @@ jobs:
5757
# contains package information of crates installed via `cargo install`.
5858
~/.cargo/.crates.toml
5959
~/.cargo/.crates2.json
60-
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock', 'cargo-miri/src/version.rs') }}
60+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
6161
restore-keys: ${{ runner.os }}-cargo
6262

63-
- name: Install rustup-toolchain-install-master and xargo
63+
- name: Install rustup-toolchain-install-master
6464
if: ${{ steps.cache.outputs.cache-hit == 'false' }}
6565
shell: bash
6666
run: |
6767
cargo install -f rustup-toolchain-install-master
68-
cargo install -f xargo
6968
7069
- name: Install "master" toolchain
7170
shell: bash

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ for you. If you don't want all of these to happen, you can add individual `.auto
3838
## Building and testing Miri
3939

4040
Invoking Miri requires getting a bunch of flags right and setting up a custom
41-
sysroot with xargo. The `miri` script takes care of that for you. With the
41+
sysroot. The `miri` script takes care of that for you. With the
4242
build environment prepared, compiling Miri is just one command away:
4343

4444
```

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ binaries, and as such worth documenting:
450450
some compiler flags to prepare the code for interpretation; with `host`, this is not done.
451451
This environment variable is useful to be sure that the compiled `rlib`s are compatible
452452
with Miri.
453-
* `MIRI_CALLED_FROM_XARGO` is set during the Miri-induced `xargo` sysroot build,
453+
* `MIRI_CALLED_FROM_SETUP` is set during the Miri sysroot build,
454454
which will re-invoke `cargo-miri` as the `rustc` to use for this build.
455455
* `MIRI_CALLED_FROM_RUSTDOC` when set to any value tells `cargo-miri` that it is
456456
running as a child process of `rustdoc`, which invokes it twice for each doc-test

cargo-miri/Cargo.lock

Lines changed: 74 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cargo-miri/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ directories = "3"
1818
rustc_version = "0.4"
1919
serde_json = "1.0.40"
2020
cargo_metadata = "0.15.0"
21+
rustc-build-sysroot = "0.2.1"
2122

2223
# A noop dependency that changes in the Rust repository, it's a bit of a hack.
2324
# See the `src/tools/rustc-workspace-hack/README.md` file in `rust-lang/rust`

cargo-miri/src/main.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ mod util;
66
mod arg;
77
mod phases;
88
mod setup;
9-
mod version;
109

1110
use std::{env, iter};
1211

@@ -22,8 +21,8 @@ fn main() {
2221
// Dispatch to `cargo-miri` phase. Here is a rough idea of "who calls who".
2322
//
2423
// Initially, we are invoked as `cargo-miri miri run/test`. We first run the setup phase:
25-
// - We call `xargo`, and set `RUSTC` back to us, together with `MIRI_CALLED_FROM_XARGO`,
26-
// so that xargo's rustc invocations end up in `phase_rustc` with `RustcPhase::Setup`.
24+
// - We use `rustc-build-sysroot`, and set `RUSTC` back to us, together with `MIRI_CALLED_FROM_SETUP`,
25+
// so that the sysroot build rustc invocations end up in `phase_rustc` with `RustcPhase::Setup`.
2726
// There we then call the Miri driver with `MIRI_BE_RUSTC` to perform the actual build.
2827
//
2928
// Then we call `cargo run/test`, exactly forwarding all user flags, plus some configuration so
@@ -52,7 +51,7 @@ fn main() {
5251
// the Miri driver for interpretation.
5352

5453
// Dispatch running as part of sysroot compilation.
55-
if env::var_os("MIRI_CALLED_FROM_XARGO").is_some() {
54+
if env::var_os("MIRI_CALLED_FROM_SETUP").is_some() {
5655
phase_rustc(args, RustcPhase::Setup);
5756
return;
5857
}

cargo-miri/src/phases.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ use std::io::BufReader;
77
use std::path::PathBuf;
88
use std::process::Command;
99

10+
use rustc_version::VersionMeta;
11+
1012
use crate::{setup::*, util::*};
1113

1214
const CARGO_MIRI_HELP: &str = r#"Runs binary crates and tests in Miri
@@ -90,12 +92,14 @@ pub fn phase_cargo_miri(mut args: impl Iterator<Item = String>) {
9092
let verbose = num_arg_flag("-v");
9193

9294
// Determine the involved architectures.
93-
let host = version_info().host;
95+
let rustc_version = VersionMeta::for_command(miri_for_host())
96+
.expect("failed to determine underlying rustc version of Miri");
97+
let host = &rustc_version.host;
9498
let target = get_arg_flag_value("--target");
95-
let target = target.as_ref().unwrap_or(&host);
99+
let target = target.as_ref().unwrap_or(host);
96100

97101
// We always setup.
98-
setup(&subcommand, &host, target);
102+
setup(&subcommand, target, &rustc_version);
99103

100104
// Invoke actual cargo for the job, but with different flags.
101105
// We re-use `cargo test` and `cargo run`, which makes target and binary handling very easy but
@@ -146,7 +150,7 @@ pub fn phase_cargo_miri(mut args: impl Iterator<Item = String>) {
146150
if get_arg_flag_value("--target").is_none() {
147151
// No target given. Explicitly pick the host.
148152
cmd.arg("--target");
149-
cmd.arg(&host);
153+
cmd.arg(host);
150154
}
151155

152156
// Set ourselves as runner for al binaries invoked by cargo.
@@ -204,7 +208,7 @@ pub fn phase_cargo_miri(mut args: impl Iterator<Item = String>) {
204208

205209
#[derive(Debug, Copy, Clone, PartialEq)]
206210
pub enum RustcPhase {
207-
/// `rustc` called via `xargo` for sysroot build.
211+
/// `rustc` called during sysroot build.
208212
Setup,
209213
/// `rustc` called by `cargo` for regular build.
210214
Build,
@@ -264,7 +268,7 @@ pub fn phase_rustc(mut args: impl Iterator<Item = String>, phase: RustcPhase) {
264268
let verbose = std::env::var("MIRI_VERBOSE")
265269
.map_or(0, |verbose| verbose.parse().expect("verbosity flag must be an integer"));
266270
let target_crate = is_target_crate();
267-
// Determine whether this is cargo/xargo invoking rustc to get some infos.
271+
// Determine whether this is cargo invoking rustc to get some infos.
268272
let info_query = get_arg_flag_value("--print").is_some() || has_arg_flag("-vV");
269273

270274
let store_json = |info: CrateRunInfo| {

0 commit comments

Comments
 (0)