]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_codegen_cranelift/build_system/build_backend.rs
Update snap from `1.0.1` to `1.1.0`
[rust.git] / compiler / rustc_codegen_cranelift / build_system / build_backend.rs
1 use std::env;
2 use std::path::PathBuf;
3
4 use super::path::{Dirs, RelPath};
5 use super::rustc_info::get_file_name;
6 use super::utils::{is_ci, CargoProject, Compiler};
7
8 static CG_CLIF: CargoProject = CargoProject::new(&RelPath::SOURCE, "cg_clif");
9
10 pub(crate) fn build_backend(
11     dirs: &Dirs,
12     channel: &str,
13     host_triple: &str,
14     use_unstable_features: bool,
15 ) -> PathBuf {
16     let mut cmd = CG_CLIF.build(&Compiler::host(), dirs);
17
18     cmd.env("CARGO_BUILD_INCREMENTAL", "true"); // Force incr comp even in release mode
19
20     let mut rustflags = env::var("RUSTFLAGS").unwrap_or_default();
21
22     if is_ci() {
23         // Deny warnings on CI
24         rustflags += " -Dwarnings";
25
26         // Disabling incr comp reduces cache size and incr comp doesn't save as much on CI anyway
27         cmd.env("CARGO_BUILD_INCREMENTAL", "false");
28     }
29
30     if use_unstable_features {
31         cmd.arg("--features").arg("unstable-features");
32     }
33
34     match channel {
35         "debug" => {}
36         "release" => {
37             cmd.arg("--release");
38         }
39         _ => unreachable!(),
40     }
41
42     cmd.env("RUSTFLAGS", rustflags);
43
44     eprintln!("[BUILD] rustc_codegen_cranelift");
45     super::utils::spawn_and_wait(cmd);
46
47     CG_CLIF
48         .target_dir(dirs)
49         .join(host_triple)
50         .join(channel)
51         .join(get_file_name("rustc_codegen_cranelift", "dylib"))
52 }