]> git.proxmox.com Git - rustc.git/blame - compiler/rustc_codegen_cranelift/build_system/build_backend.rs
New upstream version 1.68.2+dfsg1
[rustc.git] / compiler / rustc_codegen_cranelift / build_system / build_backend.rs
CommitLineData
136023e0 1use std::env;
2b03887a 2use std::path::PathBuf;
136023e0 3
9c376795 4use super::path::{Dirs, RelPath};
2b03887a 5use super::rustc_info::get_file_name;
9c376795
FG
6use super::utils::{is_ci, CargoProject, Compiler};
7
8static CG_CLIF: CargoProject = CargoProject::new(&RelPath::SOURCE, "cg_clif");
f2b60f7d 9
a2a8927a 10pub(crate) fn build_backend(
9c376795 11 dirs: &Dirs,
a2a8927a
XL
12 channel: &str,
13 host_triple: &str,
14 use_unstable_features: bool,
15) -> PathBuf {
9c376795 16 let mut cmd = CG_CLIF.build(&Compiler::host(), dirs);
a2a8927a
XL
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
f2b60f7d 22 if is_ci() {
a2a8927a
XL
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 }
136023e0
XL
33
34 match channel {
35 "debug" => {}
36 "release" => {
37 cmd.arg("--release");
38 }
39 _ => unreachable!(),
40 }
41
a2a8927a
XL
42 cmd.env("RUSTFLAGS", rustflags);
43
136023e0 44 eprintln!("[BUILD] rustc_codegen_cranelift");
5e7ed085 45 super::utils::spawn_and_wait(cmd);
136023e0 46
9c376795
FG
47 CG_CLIF
48 .target_dir(dirs)
2b03887a
FG
49 .join(host_triple)
50 .join(channel)
51 .join(get_file_name("rustc_codegen_cranelift", "dylib"))
136023e0 52}