Skip to content

Commit 6c77735

Browse files
committed
Auto merge of rust-lang#2564 - RalfJung:no-more-xargo, r=oli-obk
2 parents 20adc75 + 5f18674 commit 6c77735

File tree

10 files changed

+166
-219
lines changed

10 files changed

+166
-219
lines changed

src/tools/miri/.github/workflows/ci.yml

+2-3
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

src/tools/miri/CONTRIBUTING.md

+1-1
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
```

src/tools/miri/README.md

+1-1
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

src/tools/miri/cargo-miri/Cargo.lock

+74
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ version = "0.1.0"
3535
dependencies = [
3636
"cargo_metadata",
3737
"directories",
38+
"rustc-build-sysroot",
3839
"rustc-workspace-hack",
3940
"rustc_version",
4041
"serde",
@@ -142,6 +143,12 @@ dependencies = [
142143
"percent-encoding",
143144
]
144145

146+
[[package]]
147+
name = "fuchsia-cprng"
148+
version = "0.1.1"
149+
source = "registry+https://github.com/rust-lang/crates.io-index"
150+
checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba"
151+
145152
[[package]]
146153
name = "getrandom"
147154
version = "0.2.3"
@@ -322,6 +329,43 @@ dependencies = [
322329
"proc-macro2",
323330
]
324331

332+
[[package]]
333+
name = "rand"
334+
version = "0.4.6"
335+
source = "registry+https://github.com/rust-lang/crates.io-index"
336+
checksum = "552840b97013b1a26992c11eac34bdd778e464601a4c2054b5f0bff7c6761293"
337+
dependencies = [
338+
"fuchsia-cprng",
339+
"libc",
340+
"rand_core 0.3.1",
341+
"rdrand",
342+
"winapi",
343+
]
344+
345+
[[package]]
346+
name = "rand_core"
347+
version = "0.3.1"
348+
source = "registry+https://github.com/rust-lang/crates.io-index"
349+
checksum = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b"
350+
dependencies = [
351+
"rand_core 0.4.2",
352+
]
353+
354+
[[package]]
355+
name = "rand_core"
356+
version = "0.4.2"
357+
source = "registry+https://github.com/rust-lang/crates.io-index"
358+
checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc"
359+
360+
[[package]]
361+
name = "rdrand"
362+
version = "0.4.0"
363+
source = "registry+https://github.com/rust-lang/crates.io-index"
364+
checksum = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2"
365+
dependencies = [
366+
"rand_core 0.3.1",
367+
]
368+
325369
[[package]]
326370
name = "redox_syscall"
327371
version = "0.2.10"
@@ -341,6 +385,26 @@ dependencies = [
341385
"redox_syscall",
342386
]
343387

388+
[[package]]
389+
name = "remove_dir_all"
390+
version = "0.5.3"
391+
source = "registry+https://github.com/rust-lang/crates.io-index"
392+
checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7"
393+
dependencies = [
394+
"winapi",
395+
]
396+
397+
[[package]]
398+
name = "rustc-build-sysroot"
399+
version = "0.2.1"
400+
source = "registry+https://github.com/rust-lang/crates.io-index"
401+
checksum = "ea9e30aa5a34196fe1b2899704f1e1dccbc91fa0981f6c36b749899f924fcadd"
402+
dependencies = [
403+
"anyhow",
404+
"rustc_version",
405+
"tempdir",
406+
]
407+
344408
[[package]]
345409
name = "rustc-workspace-hack"
346410
version = "1.0.0"
@@ -419,6 +483,16 @@ dependencies = [
419483
"unicode-ident",
420484
]
421485

486+
[[package]]
487+
name = "tempdir"
488+
version = "0.3.7"
489+
source = "registry+https://github.com/rust-lang/crates.io-index"
490+
checksum = "15f2b5fb00ccdf689e0149d1b1b3c03fead81c2b37735d812fa8bddbbf41b6d8"
491+
dependencies = [
492+
"rand",
493+
"remove_dir_all",
494+
]
495+
422496
[[package]]
423497
name = "thiserror"
424498
version = "1.0.30"

src/tools/miri/cargo-miri/Cargo.toml

+1
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`

src/tools/miri/cargo-miri/src/main.rs

+3-4
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
}

src/tools/miri/cargo-miri/src/phases.rs

+10-6
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)