Skip to content

Commit 5ae350d

Browse files
committed
Run Miri and mir-opt tests without a target linker
1 parent e223c41 commit 5ae350d

File tree

4 files changed

+33
-13
lines changed

4 files changed

+33
-13
lines changed

src/bootstrap/src/core/build_steps/compile.rs

+10
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,16 @@ impl Std {
6969
}
7070
}
7171

72+
pub fn new_for_mir_opt_tests(compiler: Compiler, target: TargetSelection) -> Self {
73+
Self {
74+
target,
75+
compiler,
76+
crates: INTERNER.intern_list(vec!["core".to_string(), "alloc".to_string(), "std".to_string()]),
77+
force_recompile: false,
78+
extra_rust_args: &["-Clinker=definitelyalinker"],
79+
}
80+
}
81+
7282
pub fn new_with_extra_rust_args(
7383
compiler: Compiler,
7484
target: TargetSelection,

src/bootstrap/src/core/build_steps/test.rs

+18-9
Original file line numberDiff line numberDiff line change
@@ -1612,16 +1612,23 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the
16121612
.ensure(dist::DebuggerScripts { sysroot: builder.sysroot(compiler), host: target });
16131613
}
16141614

1615-
builder.ensure(compile::Std::new(compiler, target));
1615+
if suite == "mir-opt" {
1616+
builder.ensure(compile::Std::new_for_mir_opt_tests(compiler, target));
1617+
} else {
1618+
builder.ensure(compile::Std::new(compiler, target));
1619+
}
1620+
16161621
// ensure that `libproc_macro` is available on the host.
16171622
builder.ensure(compile::Std::new(compiler, compiler.host));
16181623

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

1622-
// As well as the target, except for plain wasm32, which can't build it
1623-
if !target.contains("wasm") || target.contains("emscripten") {
1624-
builder.ensure(TestHelpers { target });
1627+
if suite != "mir-opt" {
1628+
// As well as the target, except for plain wasm32, which can't build it
1629+
if !target.contains("wasm") || target.contains("emscripten") {
1630+
builder.ensure(TestHelpers { target });
1631+
}
16251632
}
16261633

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

1755-
let mut targetflags = flags;
1756-
targetflags.push(format!("-Lnative={}", builder.test_helpers_out(target).display()));
1757-
targetflags.extend(linker_flags(builder, compiler.host, LldThreads::No));
1758-
for flag in targetflags {
1759-
cmd.arg("--target-rustcflags").arg(flag);
1762+
if mode != "mir-opt" {
1763+
let mut targetflags = flags;
1764+
targetflags.push(format!("-Lnative={}", builder.test_helpers_out(target).display()));
1765+
targetflags.extend(linker_flags(builder, compiler.host, LldThreads::No));
1766+
for flag in targetflags {
1767+
cmd.arg("--target-rustcflags").arg(flag);
1768+
}
17601769
}
17611770

17621771
cmd.arg("--python").arg(builder.python());

src/bootstrap/src/core/sanity.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,13 @@ impl Finder {
6262
}
6363

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

68+
if [std::path::PathBuf::from("mir-opt")].as_slice() == build.config.paths {
69+
skip_target_sanity = true;
70+
}
71+
6872
let path = env::var_os("PATH").unwrap_or_default();
6973
// On Windows, quotes are invalid characters for filename paths, and if
7074
// one is present as part of the PATH then that can lead to the system

tests/mir-opt/remove_never_const.rs

-3
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
// consts in codegen. We also have tests for this that catches the error, see
44
// tests/ui/consts/const-eval/index-out-of-bounds-never-type.rs.
55

6-
// Force generation of optimized mir for functions that do not reach codegen.
7-
// compile-flags: --emit mir,link
8-
96
#![feature(never_type)]
107

118
struct PrintName<T>(T);

0 commit comments

Comments
 (0)