1
Fork 0

re-enable auxiliary tests for the host only

This commit is contained in:
Oliver Schneider 2016-12-19 15:46:03 +01:00
parent 3a658e09e8
commit 32cd8efb97
No known key found for this signature in database
GPG key ID: 56D6EEA0FC67AC46
3 changed files with 24 additions and 8 deletions

View file

@ -21,7 +21,10 @@ impl<'a> CompilerCalls<'a> for MiriCompilerCalls {
let mut control = CompileController::basic(); let mut control = CompileController::basic();
control.after_hir_lowering.callback = Box::new(after_hir_lowering); control.after_hir_lowering.callback = Box::new(after_hir_lowering);
control.after_analysis.callback = Box::new(after_analysis); 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 control
} }
} }
@ -136,6 +139,12 @@ fn main() {
args.push(sysroot_flag); args.push(sysroot_flag);
args.push(find_sysroot()); 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()); args.push("-Zalways-encode-mir".to_owned());
rustc_driver::run_compiler(&args, &mut MiriCompilerCalls, None, None); rustc_driver::run_compiler(&args, &mut MiriCompilerCalls, None, None);

View file

@ -27,13 +27,20 @@ fn run_pass() {
compiletest::run_tests(&config); 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(); let mut config = compiletest::default_config();
config.mode = "mir-opt".parse().expect("Invalid mode"); config.mode = "mir-opt".parse().expect("Invalid mode");
config.src_base = PathBuf::from(path); config.src_base = PathBuf::from(path);
config.target = target.to_owned(); config.target = target.to_owned();
config.rustc_path = PathBuf::from("target/debug/miri"); 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); compiletest::run_tests(&config);
std::env::set_var("MIRI_HOST_TARGET", "");
} }
fn is_target_dir<P: Into<PathBuf>>(path: P) -> bool { fn is_target_dir<P: Into<PathBuf>>(path: P) -> bool {
@ -65,10 +72,11 @@ fn compile_test() {
.to_owned(), .to_owned(),
}; };
run_pass(); run_pass();
let host = toolchain.unwrap().splitn(2, '-').skip(1).next().unwrap();
for_all_targets(&sysroot, |target| { 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") { if let Ok(path) = std::env::var("MIRI_RUSTC_TEST") {
miri_pass(&path, &target); miri_pass(&path, &target, host);
} }
}); });
compile_fail(&sysroot); compile_fail(&sysroot);

View file

@ -1,9 +1,8 @@
// aux-build:dep.rs // aux-build:dep.rs
// ignore-cross-compile
// FIXME: Auxiliary builds are currently broken. extern crate dep;
// extern crate dep;
fn main() { fn main() {
// FIXME: Auxiliary builds are currently broken. dep::foo();
// dep::foo();
} }