Skip to content

Commit

Permalink
Auto merge of rust-lang#106256 - matthiaskrgr:rollup-g1ovcqq, r=matth…
Browse files Browse the repository at this point in the history
…iaskrgr

Rollup of 9 pull requests

Successful merges:

 - rust-lang#106208 (Make trait/impl `where` clause mismatch on region error a bit more actionable)
 - rust-lang#106216 (Powershell: Use `WaitForExit` instead of `-Wait`)
 - rust-lang#106217 (rustdoc: remove unnecessary `.tooltip::after { text-align: center }`)
 - rust-lang#106218 (Migrate css var scraped examples)
 - rust-lang#106221 (Rename `Rptr` to `Ref` in AST and HIR)
 - rust-lang#106223 (On unsized locals with explicit types suggest `&`)
 - rust-lang#106225 (Remove CraftSpider from review rotation)
 - rust-lang#106229 (update Miri)
 - rust-lang#106242 (Detect diff markers in the parser)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
  • Loading branch information
bors committed Dec 29, 2022
2 parents 79b6e12 + ca239d9 commit c4ad2d1
Show file tree
Hide file tree
Showing 23 changed files with 340 additions and 239 deletions.
154 changes: 87 additions & 67 deletions Cargo.lock

Large diffs are not rendered by default.

69 changes: 35 additions & 34 deletions cargo-miri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion cargo-miri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ directories = "4"
rustc_version = "0.4"
serde_json = "1.0.40"
cargo_metadata = "0.15.0"
rustc-build-sysroot = "0.4"
rustc-build-sysroot = "0.4.1"

# A noop dependency that changes in the Rust repository, it's a bit of a hack.
# See the `src/tools/rustc-workspace-hack/README.md` file in `rust-lang/rust`
Expand Down
98 changes: 58 additions & 40 deletions cargo-miri/src/phases.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,22 +236,36 @@ pub fn phase_rustc(mut args: impl Iterator<Item = String>, phase: RustcPhase) {
is_bin || is_test
}

fn out_filename(prefix: &str, suffix: &str) -> PathBuf {
if let Some(out_dir) = get_arg_flag_value("--out-dir") {
let mut path = PathBuf::from(out_dir);
path.push(format!(
"{}{}{}{}",
prefix,
get_arg_flag_value("--crate-name").unwrap(),
// This is technically a `-C` flag but the prefix seems unique enough...
// (and cargo passes this before the filename so it should be unique)
get_arg_flag_value("extra-filename").unwrap_or_default(),
suffix,
));
path
fn out_filenames() -> Vec<PathBuf> {
if let Some(out_file) = get_arg_flag_value("-o") {
// `-o` has precedence over `--out-dir`.
vec![PathBuf::from(out_file)]
} else {
let out_file = get_arg_flag_value("-o").unwrap();
PathBuf::from(out_file)
let out_dir = get_arg_flag_value("--out-dir").unwrap_or_default();
let path = PathBuf::from(out_dir);
// Ask rustc for the filename (since that is target-dependent).
let mut rustc = miri_for_host(); // sysroot doesn't matter for this so we just use the host
rustc.arg("--print").arg("file-names");
for flag in ["--crate-name", "--crate-type", "--target"] {
for val in get_arg_flag_values(flag) {
rustc.arg(flag).arg(val);
}
}
// This is technically passed as `-C extra-filename=...`, but the prefix seems unique
// enough... (and cargo passes this before the filename so it should be unique)
if let Some(extra) = get_arg_flag_value("extra-filename") {
rustc.arg("-C").arg(format!("extra-filename={extra}"));
}
rustc.arg("-");

let output = rustc.output().expect("cannot run rustc to determine file name");
assert!(
output.status.success(),
"rustc failed when determining file name:\n{output:?}"
);
let output =
String::from_utf8(output.stdout).expect("rustc returned non-UTF-8 filename");
output.lines().filter(|l| !l.is_empty()).map(|l| path.join(l)).collect()
}
}

Expand All @@ -267,24 +281,28 @@ pub fn phase_rustc(mut args: impl Iterator<Item = String>, phase: RustcPhase) {
let info_query = get_arg_flag_value("--print").is_some() || has_arg_flag("-vV");

let store_json = |info: CrateRunInfo| {
// Create a stub .d file to stop Cargo from "rebuilding" the crate:
// https://github.com/rust-lang/miri/issues/1724#issuecomment-787115693
// As we store a JSON file instead of building the crate here, an empty file is fine.
let dep_info_name = out_filename("", ".d");
if verbose > 0 {
eprintln!("[cargo-miri rustc] writing stub dep-info to `{}`", dep_info_name.display());
if get_arg_flag_value("--emit").unwrap_or_default().split(',').any(|e| e == "dep-info") {
// Create a stub .d file to stop Cargo from "rebuilding" the crate:
// https://github.com/rust-lang/miri/issues/1724#issuecomment-787115693
// As we store a JSON file instead of building the crate here, an empty file is fine.
let dep_info_name = format!(
"{}/{}{}.d",
get_arg_flag_value("--out-dir").unwrap(),
get_arg_flag_value("--crate-name").unwrap(),
get_arg_flag_value("extra-filename").unwrap_or_default(),
);
if verbose > 0 {
eprintln!("[cargo-miri rustc] writing stub dep-info to `{dep_info_name}`");
}
File::create(dep_info_name).expect("failed to create fake .d file");
}
File::create(dep_info_name).expect("failed to create fake .d file");

let filename = out_filename("", "");
if verbose > 0 {
eprintln!("[cargo-miri rustc] writing run info to `{}`", filename.display());
for filename in out_filenames() {
if verbose > 0 {
eprintln!("[cargo-miri rustc] writing run info to `{}`", filename.display());
}
info.store(&filename);
}
info.store(&filename);
// For Windows and WASM, do the same thing again with `.exe`/`.wasm` appended to the filename.
// (Need to do this here as cargo moves that "binary" to a different place before running it.)
info.store(&out_filename("", ".exe"));
info.store(&out_filename("", ".wasm"));
};

let runnable_crate = !info_query && is_runnable_crate();
Expand Down Expand Up @@ -323,11 +341,14 @@ pub fn phase_rustc(mut args: impl Iterator<Item = String>, phase: RustcPhase) {

// Alter the `-o` parameter so that it does not overwrite the JSON file we stored above.
let mut args = env.args;
let mut out_filename = None;
for i in 0..args.len() {
if args[i] == "-o" {
out_filename = Some(args[i + 1].clone());
args[i + 1].push_str(".miri");
}
}
let out_filename = out_filename.expect("rustdoc must pass `-o`");

cmd.args(&args);
cmd.env("MIRI_BE_RUSTC", "target");
Expand All @@ -340,7 +361,7 @@ pub fn phase_rustc(mut args: impl Iterator<Item = String>, phase: RustcPhase) {
eprintln!("[cargo-miri rustc inside rustdoc] going to run:\n{cmd:?}");
}

exec_with_pipe(cmd, &env.stdin, format!("{}.stdin", out_filename("", "").display()));
exec_with_pipe(cmd, &env.stdin, format!("{out_filename}.stdin"));
}

return;
Expand Down Expand Up @@ -422,15 +443,12 @@ pub fn phase_rustc(mut args: impl Iterator<Item = String>, phase: RustcPhase) {
// Create a stub .rlib file if "link" was requested by cargo.
// This is necessary to prevent cargo from doing rebuilds all the time.
if emit_link_hack {
// Some platforms prepend "lib", some do not... let's just create both files.
File::create(out_filename("lib", ".rlib")).expect("failed to create fake .rlib file");
File::create(out_filename("", ".rlib")).expect("failed to create fake .rlib file");
// Just in case this is a cdylib or staticlib, also create those fake files.
File::create(out_filename("lib", ".so")).expect("failed to create fake .so file");
File::create(out_filename("lib", ".a")).expect("failed to create fake .a file");
File::create(out_filename("lib", ".dylib")).expect("failed to create fake .dylib file");
File::create(out_filename("", ".dll")).expect("failed to create fake .dll file");
File::create(out_filename("", ".lib")).expect("failed to create fake .lib file");
for filename in out_filenames() {
if verbose > 0 {
eprintln!("[cargo-miri rustc] creating fake lib file at `{}`", filename.display());
}
File::create(filename).expect("failed to create fake lib file");
}
}

debug_cmd("[cargo-miri rustc]", verbose, &cmd);
Expand Down
8 changes: 5 additions & 3 deletions cargo-miri/src/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,11 @@ pub fn setup(subcommand: &MiriCommand, target: &str, rustc_version: &VersionMeta
.rustflags(rustflags)
.cargo(cargo_cmd)
.build_from_source(&rust_src)
.unwrap_or_else(|_| {
if only_setup {
show_error!("failed to build sysroot, see error details above")
.unwrap_or_else(|err| {
if print_sysroot {
show_error!("failed to build sysroot")
} else if only_setup {
show_error!("failed to build sysroot: {err:?}")
} else {
show_error!(
"failed to build sysroot; run `cargo miri setup` to see the error details"
Expand Down
3 changes: 2 additions & 1 deletion ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,9 @@ case $HOST_TARGET in
MIRI_TEST_TARGET=i686-pc-windows-msvc run_tests
MIRI_TEST_TARGET=x86_64-unknown-freebsd run_tests_minimal hello integer vec panic/panic concurrency/simple atomic data_race env/var
MIRI_TEST_TARGET=aarch64-linux-android run_tests_minimal hello integer vec panic/panic
MIRI_TEST_TARGET=wasm32-wasi MIRI_NO_STD=1 run_tests_minimal no_std # supports std but miri doesn't support it
MIRI_TEST_TARGET=wasm32-wasi run_tests_minimal no_std integer
MIRI_TEST_TARGET=thumbv7em-none-eabihf MIRI_NO_STD=1 run_tests_minimal no_std # no_std embedded architecture
MIRI_TEST_TARGET=tests/avr.json MIRI_NO_STD=1 run_tests_minimal no_std # JSON target file
;;
x86_64-apple-darwin)
MIRI_TEST_TARGET=mips64-unknown-linux-gnuabi64 run_tests # big-endian architecture
Expand Down
Loading

0 comments on commit c4ad2d1

Please sign in to comment.