diff --git a/src/bin/miri.rs b/src/bin/miri.rs index 379f25ef757..56c2e433d06 100644 --- a/src/bin/miri.rs +++ b/src/bin/miri.rs @@ -21,7 +21,10 @@ impl<'a> CompilerCalls<'a> for MiriCompilerCalls { let mut control = CompileController::basic(); control.after_hir_lowering.callback = Box::new(after_hir_lowering); control.after_analysis.callback = Box::new(after_analysis); - control.after_analysis.stop = Compilation::Stop; + if std::env::var("MIRI_HOST_TARGET") != Ok("yes".to_owned()) { + // only fully compile targets on the host + control.after_analysis.stop = Compilation::Stop; + } control } } @@ -136,6 +139,12 @@ fn main() { args.push(sysroot_flag); args.push(find_sysroot()); } + // we run the optimization passes inside miri + // if we ran them twice we'd get funny failures due to borrowck ElaborateDrops only working on + // unoptimized MIR + // FIXME: add an after-mir-passes hook to rustc driver + args.push("-Zmir-opt-level=0".to_owned()); + // for auxilary builds in unit tests args.push("-Zalways-encode-mir".to_owned()); rustc_driver::run_compiler(&args, &mut MiriCompilerCalls, None, None); diff --git a/tests/compiletest.rs b/tests/compiletest.rs index 50970086ee5..90a40d8e39b 100644 --- a/tests/compiletest.rs +++ b/tests/compiletest.rs @@ -27,13 +27,20 @@ fn run_pass() { compiletest::run_tests(&config); } -fn miri_pass(path: &str, target: &str) { +fn miri_pass(path: &str, target: &str, host: &str) { let mut config = compiletest::default_config(); config.mode = "mir-opt".parse().expect("Invalid mode"); config.src_base = PathBuf::from(path); config.target = target.to_owned(); config.rustc_path = PathBuf::from("target/debug/miri"); + // don't actually execute the final binary, it might be for other targets and we only care + // about running miri, not the binary. + config.runtool = Some("echo \"\" || ".to_owned()); + if target == host { + std::env::set_var("MIRI_HOST_TARGET", "yes"); + } compiletest::run_tests(&config); + std::env::set_var("MIRI_HOST_TARGET", ""); } fn is_target_dir>(path: P) -> bool { @@ -65,10 +72,11 @@ fn compile_test() { .to_owned(), }; run_pass(); + let host = toolchain.unwrap().splitn(2, '-').skip(1).next().unwrap(); for_all_targets(&sysroot, |target| { - miri_pass("tests/run-pass", &target); + miri_pass("tests/run-pass", &target, host); if let Ok(path) = std::env::var("MIRI_RUSTC_TEST") { - miri_pass(&path, &target); + miri_pass(&path, &target, host); } }); compile_fail(&sysroot); diff --git a/tests/run-pass/aux_test.rs b/tests/run-pass/aux_test.rs index 5510582e87a..1b1dbaa6838 100644 --- a/tests/run-pass/aux_test.rs +++ b/tests/run-pass/aux_test.rs @@ -1,9 +1,8 @@ // aux-build:dep.rs +// ignore-cross-compile -// FIXME: Auxiliary builds are currently broken. -// extern crate dep; +extern crate dep; fn main() { - // FIXME: Auxiliary builds are currently broken. - // dep::foo(); + dep::foo(); }