1 use super::build_sysroot;
2 use super::utils::spawn_and_wait_with_input;
3 use build_system::SysrootKind;
6 use std::process::Command;
10 sysroot_kind: SysrootKind,
12 cg_clif_build_dir: &Path,
17 host_triple, target_triple,
18 "abi-checker not supported on cross-compilation scenarios"
21 eprintln!("Building sysroot for abi-checker");
22 build_sysroot::build_sysroot(
31 eprintln!("Running abi-checker");
32 let mut abi_checker_path = env::current_dir().unwrap();
33 abi_checker_path.push("abi-checker");
34 env::set_current_dir(abi_checker_path.clone()).unwrap();
36 let build_dir = abi_checker_path.parent().unwrap().join("build");
37 let cg_clif_dylib_path = build_dir.join(if cfg!(windows) { "bin" } else { "lib" }).join(
38 env::consts::DLL_PREFIX.to_string() + "rustc_codegen_cranelift" + env::consts::DLL_SUFFIX,
40 println!("cg_clif_dylib_path: {}", cg_clif_dylib_path.display());
42 let pairs = ["rustc_calls_cgclif", "cgclif_calls_rustc", "cgclif_calls_cc", "cc_calls_cgclif"];
45 eprintln!("[ABI-CHECKER] Running pair {pair}");
47 let mut cmd = Command::new("cargo");
50 cmd.arg(target_triple);
54 cmd.arg("--add-rustc-codegen-backend");
55 cmd.arg(format!("cgclif:{}", cg_clif_dylib_path.display()));
57 let output = spawn_and_wait_with_input(cmd, "".to_string());
59 // TODO: The correct thing to do here is to check the exit code, but abi-checker
60 // currently doesn't return 0 on success, so check for the test fail count.
61 // See: https://github.com/Gankra/abi-checker/issues/10
62 let failed = !(output.contains("0 failed") && output.contains("0 completely failed"));
64 panic!("abi-checker for pair {} failed!", pair);