Skip to content

Commit

Permalink
Run Miri and mir-opt tests without a target linker
Browse files Browse the repository at this point in the history
  • Loading branch information
saethlin committed Dec 17, 2023
1 parent e223c41 commit 5ae350d
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 13 deletions.
10 changes: 10 additions & 0 deletions src/bootstrap/src/core/build_steps/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,16 @@ impl Std {
}
}

pub fn new_for_mir_opt_tests(compiler: Compiler, target: TargetSelection) -> Self {
Self {
target,
compiler,
crates: INTERNER.intern_list(vec!["core".to_string(), "alloc".to_string(), "std".to_string()]),
force_recompile: false,
extra_rust_args: &["-Clinker=definitelyalinker"],
}
}

pub fn new_with_extra_rust_args(
compiler: Compiler,
target: TargetSelection,
Expand Down
27 changes: 18 additions & 9 deletions src/bootstrap/src/core/build_steps/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1612,16 +1612,23 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the
.ensure(dist::DebuggerScripts { sysroot: builder.sysroot(compiler), host: target });
}

builder.ensure(compile::Std::new(compiler, target));
if suite == "mir-opt" {
builder.ensure(compile::Std::new_for_mir_opt_tests(compiler, target));
} else {
builder.ensure(compile::Std::new(compiler, target));
}

// ensure that `libproc_macro` is available on the host.
builder.ensure(compile::Std::new(compiler, compiler.host));

// Also provide `rust_test_helpers` for the host.
builder.ensure(TestHelpers { target: compiler.host });

// As well as the target, except for plain wasm32, which can't build it
if !target.contains("wasm") || target.contains("emscripten") {
builder.ensure(TestHelpers { target });
if suite != "mir-opt" {
// As well as the target, except for plain wasm32, which can't build it
if !target.contains("wasm") || target.contains("emscripten") {
builder.ensure(TestHelpers { target });
}
}

builder.ensure(RemoteCopyLibs { compiler, target });
Expand Down Expand Up @@ -1752,11 +1759,13 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the
cmd.arg("--host-rustcflags").arg(flag);
}

let mut targetflags = flags;
targetflags.push(format!("-Lnative={}", builder.test_helpers_out(target).display()));
targetflags.extend(linker_flags(builder, compiler.host, LldThreads::No));
for flag in targetflags {
cmd.arg("--target-rustcflags").arg(flag);
if mode != "mir-opt" {
let mut targetflags = flags;
targetflags.push(format!("-Lnative={}", builder.test_helpers_out(target).display()));
targetflags.extend(linker_flags(builder, compiler.host, LldThreads::No));
for flag in targetflags {
cmd.arg("--target-rustcflags").arg(flag);
}
}

cmd.arg("--python").arg(builder.python());
Expand Down
6 changes: 5 additions & 1 deletion src/bootstrap/src/core/sanity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,13 @@ impl Finder {
}

pub fn check(build: &mut Build) {
let skip_target_sanity =
let mut skip_target_sanity =
env::var_os("BOOTSTRAP_SKIP_TARGET_SANITY").is_some_and(|s| s == "1" || s == "true");

if [std::path::PathBuf::from("mir-opt")].as_slice() == build.config.paths {
skip_target_sanity = true;
}

let path = env::var_os("PATH").unwrap_or_default();
// On Windows, quotes are invalid characters for filename paths, and if
// one is present as part of the PATH then that can lead to the system
Expand Down
3 changes: 0 additions & 3 deletions tests/mir-opt/remove_never_const.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
// consts in codegen. We also have tests for this that catches the error, see
// tests/ui/consts/const-eval/index-out-of-bounds-never-type.rs.

// Force generation of optimized mir for functions that do not reach codegen.
// compile-flags: --emit mir,link

#![feature(never_type)]

struct PrintName<T>(T);
Expand Down

0 comments on commit 5ae350d

Please sign in to comment.