diff --git a/src/bootstrap/src/core/build_steps/compile.rs b/src/bootstrap/src/core/build_steps/compile.rs index 11e789a996af0..7a271c6a4fb15 100644 --- a/src/bootstrap/src/core/build_steps/compile.rs +++ b/src/bootstrap/src/core/build_steps/compile.rs @@ -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, diff --git a/src/bootstrap/src/core/build_steps/test.rs b/src/bootstrap/src/core/build_steps/test.rs index d0f36f99342fe..572f3d31a6599 100644 --- a/src/bootstrap/src/core/build_steps/test.rs +++ b/src/bootstrap/src/core/build_steps/test.rs @@ -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 }); @@ -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()); diff --git a/src/bootstrap/src/core/sanity.rs b/src/bootstrap/src/core/sanity.rs index 9101d94ea881e..9be60f896495d 100644 --- a/src/bootstrap/src/core/sanity.rs +++ b/src/bootstrap/src/core/sanity.rs @@ -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 diff --git a/tests/mir-opt/remove_never_const.rs b/tests/mir-opt/remove_never_const.rs index c144edaffafb6..81562058d808f 100644 --- a/tests/mir-opt/remove_never_const.rs +++ b/tests/mir-opt/remove_never_const.rs @@ -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);