• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 use super::build_sysroot;
2 use super::path::Dirs;
3 use super::prepare::GitRepo;
4 use super::utils::{spawn_and_wait, CargoProject, Compiler};
5 use super::{CodegenBackend, SysrootKind};
6 
7 static ABI_CAFE_REPO: GitRepo = GitRepo::github(
8     "Gankra",
9     "abi-cafe",
10     "4c6dc8c9c687e2b3a760ff2176ce236872b37212",
11     "588df6d66abbe105",
12     "abi-cafe",
13 );
14 
15 static ABI_CAFE: CargoProject = CargoProject::new(&ABI_CAFE_REPO.source_dir(), "abi_cafe_target");
16 
run( channel: &str, sysroot_kind: SysrootKind, dirs: &Dirs, cg_clif_dylib: &CodegenBackend, rustup_toolchain_name: Option<&str>, bootstrap_host_compiler: &Compiler, )17 pub(crate) fn run(
18     channel: &str,
19     sysroot_kind: SysrootKind,
20     dirs: &Dirs,
21     cg_clif_dylib: &CodegenBackend,
22     rustup_toolchain_name: Option<&str>,
23     bootstrap_host_compiler: &Compiler,
24 ) {
25     ABI_CAFE_REPO.fetch(dirs);
26     ABI_CAFE_REPO.patch(dirs);
27 
28     eprintln!("Building sysroot for abi-cafe");
29     build_sysroot::build_sysroot(
30         dirs,
31         channel,
32         sysroot_kind,
33         cg_clif_dylib,
34         bootstrap_host_compiler,
35         rustup_toolchain_name,
36         bootstrap_host_compiler.triple.clone(),
37     );
38 
39     eprintln!("Running abi-cafe");
40 
41     let pairs = ["rustc_calls_cgclif", "cgclif_calls_rustc", "cgclif_calls_cc", "cc_calls_cgclif"];
42 
43     let mut cmd = ABI_CAFE.run(bootstrap_host_compiler, dirs);
44     cmd.arg("--");
45     cmd.arg("--pairs");
46     cmd.args(pairs);
47     cmd.arg("--add-rustc-codegen-backend");
48     match cg_clif_dylib {
49         CodegenBackend::Local(path) => {
50             cmd.arg(format!("cgclif:{}", path.display()));
51         }
52         CodegenBackend::Builtin(name) => {
53             cmd.arg(format!("cgclif:{name}"));
54         }
55     }
56     cmd.current_dir(ABI_CAFE.source_dir(dirs));
57 
58     spawn_and_wait(cmd);
59 }
60