@@ -5,7 +5,7 @@ use std::process::{self, Command};
5
5
use super :: path:: { Dirs , RelPath } ;
6
6
use super :: rustc_info:: { get_file_name, get_rustc_version} ;
7
7
use super :: utils:: { remove_dir_if_exists, spawn_and_wait, try_hard_link, CargoProject , Compiler } ;
8
- use super :: SysrootKind ;
8
+ use super :: { CodegenBackend , SysrootKind } ;
9
9
10
10
static DIST_DIR : RelPath = RelPath :: DIST ;
11
11
static BIN_DIR : RelPath = RelPath :: DIST . join ( "bin" ) ;
@@ -15,7 +15,7 @@ pub(crate) fn build_sysroot(
15
15
dirs : & Dirs ,
16
16
channel : & str ,
17
17
sysroot_kind : SysrootKind ,
18
- cg_clif_dylib_src : & Path ,
18
+ cg_clif_dylib_src : & CodegenBackend ,
19
19
bootstrap_host_compiler : & Compiler ,
20
20
rustup_toolchain_name : Option < & str > ,
21
21
target_triple : String ,
@@ -28,17 +28,23 @@ pub(crate) fn build_sysroot(
28
28
29
29
let is_native = bootstrap_host_compiler. triple == target_triple;
30
30
31
- // Copy the backend
32
- let cg_clif_dylib_path = if cfg ! ( windows) {
33
- // Windows doesn't have rpath support, so the cg_clif dylib needs to be next to the
34
- // binaries.
35
- BIN_DIR
36
- } else {
37
- LIB_DIR
38
- }
39
- . to_path ( dirs)
40
- . join ( cg_clif_dylib_src. file_name ( ) . unwrap ( ) ) ;
41
- try_hard_link ( cg_clif_dylib_src, & cg_clif_dylib_path) ;
31
+ let cg_clif_dylib_path = match cg_clif_dylib_src {
32
+ CodegenBackend :: Local ( src_path) => {
33
+ // Copy the backend
34
+ let cg_clif_dylib_path = if cfg ! ( windows) {
35
+ // Windows doesn't have rpath support, so the cg_clif dylib needs to be next to the
36
+ // binaries.
37
+ BIN_DIR
38
+ } else {
39
+ LIB_DIR
40
+ }
41
+ . to_path ( dirs)
42
+ . join ( src_path. file_name ( ) . unwrap ( ) ) ;
43
+ try_hard_link ( src_path, & cg_clif_dylib_path) ;
44
+ CodegenBackend :: Local ( cg_clif_dylib_path)
45
+ }
46
+ CodegenBackend :: Builtin ( name) => CodegenBackend :: Builtin ( name. clone ( ) ) ,
47
+ } ;
42
48
43
49
// Build and copy rustc and cargo wrappers
44
50
let wrapper_base_name = get_file_name ( & bootstrap_host_compiler. rustc , "____" , "bin" ) ;
@@ -64,6 +70,9 @@ pub(crate) fn build_sysroot(
64
70
. env ( "RUSTC" , & bootstrap_host_compiler. rustc )
65
71
. env ( "RUSTDOC" , & bootstrap_host_compiler. rustdoc ) ;
66
72
}
73
+ if let CodegenBackend :: Builtin ( name) = cg_clif_dylib_src {
74
+ build_cargo_wrapper_cmd. env ( "BUILTIN_BACKEND" , name) ;
75
+ }
67
76
spawn_and_wait ( build_cargo_wrapper_cmd) ;
68
77
}
69
78
@@ -157,15 +166,15 @@ fn build_sysroot_for_triple(
157
166
dirs : & Dirs ,
158
167
channel : & str ,
159
168
compiler : Compiler ,
160
- cg_clif_dylib_path : & Path ,
169
+ cg_clif_dylib_path : & CodegenBackend ,
161
170
sysroot_kind : SysrootKind ,
162
171
) -> SysrootTarget {
163
172
match sysroot_kind {
164
173
SysrootKind :: None => build_rtstartup ( dirs, & compiler)
165
174
. unwrap_or ( SysrootTarget { triple : compiler. triple , libs : vec ! [ ] } ) ,
166
175
SysrootKind :: Llvm => build_llvm_sysroot_for_triple ( compiler) ,
167
176
SysrootKind :: Clif => {
168
- build_clif_sysroot_for_triple ( dirs, channel, compiler, & cg_clif_dylib_path)
177
+ build_clif_sysroot_for_triple ( dirs, channel, compiler, cg_clif_dylib_path)
169
178
}
170
179
}
171
180
}
@@ -209,7 +218,7 @@ fn build_clif_sysroot_for_triple(
209
218
dirs : & Dirs ,
210
219
channel : & str ,
211
220
mut compiler : Compiler ,
212
- cg_clif_dylib_path : & Path ,
221
+ cg_clif_dylib_path : & CodegenBackend ,
213
222
) -> SysrootTarget {
214
223
match fs:: read_to_string ( SYSROOT_RUSTC_VERSION . to_path ( dirs) ) {
215
224
Err ( e) => {
@@ -247,7 +256,14 @@ fn build_clif_sysroot_for_triple(
247
256
248
257
// Build sysroot
249
258
let mut rustflags = " -Zforce-unstable-if-unmarked -Cpanic=abort" . to_string ( ) ;
250
- rustflags. push_str ( & format ! ( " -Zcodegen-backend={}" , cg_clif_dylib_path. to_str( ) . unwrap( ) ) ) ;
259
+ match cg_clif_dylib_path {
260
+ CodegenBackend :: Local ( path) => {
261
+ rustflags. push_str ( & format ! ( " -Zcodegen-backend={}" , path. to_str( ) . unwrap( ) ) ) ;
262
+ }
263
+ CodegenBackend :: Builtin ( name) => {
264
+ rustflags. push_str ( & format ! ( " -Zcodegen-backend={name}" ) ) ;
265
+ }
266
+ } ;
251
267
// Necessary for MinGW to find rsbegin.o and rsend.o
252
268
rustflags
253
269
. push_str ( & format ! ( " --sysroot {}" , RTSTARTUP_SYSROOT . to_path( dirs) . to_str( ) . unwrap( ) ) ) ;
0 commit comments