]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_codegen_cranelift/build_system/build_backend.rs
Auto merge of #106938 - GuillaumeGomez:normalize-projection-field-ty, r=oli-obk
[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 pub(crate) static CG_CLIF: CargoProject = CargoProject::new(&RelPath::SOURCE, "cg_clif");
9
10 pub(crate) fn build_backend(
11     dirs: &Dirs,
12     channel: &str,
13     bootstrap_host_compiler: &Compiler,
14     use_unstable_features: bool,
15 ) -> PathBuf {
16     let mut cmd = CG_CLIF.build(&bootstrap_host_compiler, 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         cmd.env("CARGO_PROFILE_RELEASE_DEBUG_ASSERTIONS", "true");
30     }
31
32     if use_unstable_features {
33         cmd.arg("--features").arg("unstable-features");
34     }
35
36     match channel {
37         "debug" => {}
38         "release" => {
39             cmd.arg("--release");
40         }
41         _ => unreachable!(),
42     }
43
44     cmd.env("RUSTFLAGS", rustflags);
45
46     eprintln!("[BUILD] rustc_codegen_cranelift");
47     super::utils::spawn_and_wait(cmd);
48
49     CG_CLIF
50         .target_dir(dirs)
51         .join(&bootstrap_host_compiler.triple)
52         .join(channel)
53         .join(get_file_name("rustc_codegen_cranelift", "dylib"))
54 }