]> git.lizzy.rs Git - rust.git/blob - build_system/abi_cafe.rs
c2944ce62623a600b36ffbdf2e97bbfbb8ab73ed
[rust.git] / build_system / abi_cafe.rs
1 use std::env;
2 use std::path::Path;
3
4 use super::build_sysroot;
5 use super::config;
6 use super::utils::{cargo_command, spawn_and_wait};
7 use super::SysrootKind;
8
9 pub(crate) fn run(
10     channel: &str,
11     sysroot_kind: SysrootKind,
12     target_dir: &Path,
13     cg_clif_dylib: &Path,
14     host_triple: &str,
15     target_triple: &str,
16 ) {
17     if !config::get_bool("testsuite.abi-cafe") {
18         eprintln!("[SKIP] abi-cafe");
19         return;
20     }
21
22     if host_triple != target_triple {
23         eprintln!("[SKIP] abi-cafe (cross-compilation not supported)");
24         return;
25     }
26
27     eprintln!("Building sysroot for abi-cafe");
28     build_sysroot::build_sysroot(
29         channel,
30         sysroot_kind,
31         target_dir,
32         cg_clif_dylib,
33         host_triple,
34         target_triple,
35     );
36
37     eprintln!("Running abi-cafe");
38     let mut abi_cafe_path = env::current_dir().unwrap();
39     abi_cafe_path.push("abi-cafe");
40     env::set_current_dir(&abi_cafe_path.clone()).unwrap();
41
42     let pairs = ["rustc_calls_cgclif", "cgclif_calls_rustc", "cgclif_calls_cc", "cc_calls_cgclif"];
43
44     let mut cmd = cargo_command("cargo", "run", Some(target_triple), &abi_cafe_path);
45     cmd.arg("--");
46     cmd.arg("--pairs");
47     cmd.args(pairs);
48     cmd.arg("--add-rustc-codegen-backend");
49     cmd.arg(format!("cgclif:{}", cg_clif_dylib.display()));
50
51     spawn_and_wait(cmd);
52 }