@@ -10,6 +10,18 @@ pub(crate) fn build_backend(
10
10
let mut cmd = Command :: new ( "cargo" ) ;
11
11
cmd. arg ( "build" ) . arg ( "--target" ) . arg ( host_triple) ;
12
12
13
+ cmd. env ( "CARGO_BUILD_INCREMENTAL" , "true" ) ; // Force incr comp even in release mode
14
+
15
+ let mut rustflags = env:: var ( "RUSTFLAGS" ) . unwrap_or_default ( ) ;
16
+
17
+ if env:: var ( "CI" ) . as_ref ( ) . map ( |val| & * * val) == Ok ( "true" ) {
18
+ // Deny warnings on CI
19
+ rustflags += " -Dwarnings" ;
20
+
21
+ // Disabling incr comp reduces cache size and incr comp doesn't save as much on CI anyway
22
+ cmd. env ( "CARGO_BUILD_INCREMENTAL" , "false" ) ;
23
+ }
24
+
13
25
if use_unstable_features {
14
26
cmd. arg ( "--features" ) . arg ( "unstable-features" ) ;
15
27
}
@@ -22,25 +34,20 @@ pub(crate) fn build_backend(
22
34
_ => unreachable ! ( ) ,
23
35
}
24
36
37
+ // Set the rpath to make the cg_clif executable find librustc_codegen_cranelift without changing
38
+ // LD_LIBRARY_PATH
25
39
if cfg ! ( unix) {
26
40
if cfg ! ( target_os = "macos" ) {
27
- cmd. env (
28
- "RUSTFLAGS" ,
29
- "-Csplit-debuginfo=unpacked \
41
+ rustflags += " -Csplit-debuginfo=unpacked \
30
42
-Clink-arg=-Wl,-rpath,@loader_path/../lib \
31
- -Zosx-rpath-install-name"
32
- . to_string ( )
33
- + env:: var ( "RUSTFLAGS" ) . as_deref ( ) . unwrap_or ( "" ) ,
34
- ) ;
43
+ -Zosx-rpath-install-name";
35
44
} else {
36
- cmd. env (
37
- "RUSTFLAGS" ,
38
- "-Clink-arg=-Wl,-rpath=$ORIGIN/../lib " . to_string ( )
39
- + env:: var ( "RUSTFLAGS" ) . as_deref ( ) . unwrap_or ( "" ) ,
40
- ) ;
45
+ rustflags += " -Clink-arg=-Wl,-rpath=$ORIGIN/../lib " ;
41
46
}
42
47
}
43
48
49
+ cmd. env ( "RUSTFLAGS" , rustflags) ;
50
+
44
51
eprintln ! ( "[BUILD] rustc_codegen_cranelift" ) ;
45
52
crate :: utils:: spawn_and_wait ( cmd) ;
46
53
0 commit comments