@@ -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" ) ;
@@ -65,6 +71,9 @@ pub(crate) fn build_sysroot(
65
71
. env ( "RUSTC" , & bootstrap_host_compiler. rustc )
66
72
. env ( "RUSTDOC" , & bootstrap_host_compiler. rustdoc ) ;
67
73
}
74
+ if let CodegenBackend :: Builtin ( name) = cg_clif_dylib_src {
75
+ build_cargo_wrapper_cmd. env ( "BUILTIN_BACKEND" , name) ;
76
+ }
68
77
spawn_and_wait ( build_cargo_wrapper_cmd) ;
69
78
try_hard_link ( wrapper_path, BIN_DIR . to_path ( dirs) . join ( wrapper_name) ) ;
70
79
}
@@ -159,15 +168,15 @@ fn build_sysroot_for_triple(
159
168
dirs : & Dirs ,
160
169
channel : & str ,
161
170
compiler : Compiler ,
162
- cg_clif_dylib_path : & Path ,
171
+ cg_clif_dylib_path : & CodegenBackend ,
163
172
sysroot_kind : SysrootKind ,
164
173
) -> SysrootTarget {
165
174
match sysroot_kind {
166
175
SysrootKind :: None => build_rtstartup ( dirs, & compiler)
167
176
. unwrap_or ( SysrootTarget { triple : compiler. triple , libs : vec ! [ ] } ) ,
168
177
SysrootKind :: Llvm => build_llvm_sysroot_for_triple ( compiler) ,
169
178
SysrootKind :: Clif => {
170
- build_clif_sysroot_for_triple ( dirs, channel, compiler, & cg_clif_dylib_path)
179
+ build_clif_sysroot_for_triple ( dirs, channel, compiler, cg_clif_dylib_path)
171
180
}
172
181
}
173
182
}
@@ -211,7 +220,7 @@ fn build_clif_sysroot_for_triple(
211
220
dirs : & Dirs ,
212
221
channel : & str ,
213
222
mut compiler : Compiler ,
214
- cg_clif_dylib_path : & Path ,
223
+ cg_clif_dylib_path : & CodegenBackend ,
215
224
) -> SysrootTarget {
216
225
match fs:: read_to_string ( SYSROOT_RUSTC_VERSION . to_path ( dirs) ) {
217
226
Err ( e) => {
@@ -249,7 +258,14 @@ fn build_clif_sysroot_for_triple(
249
258
250
259
// Build sysroot
251
260
let mut rustflags = " -Zforce-unstable-if-unmarked -Cpanic=abort" . to_string ( ) ;
252
- rustflags. push_str ( & format ! ( " -Zcodegen-backend={}" , cg_clif_dylib_path. to_str( ) . unwrap( ) ) ) ;
261
+ match cg_clif_dylib_path {
262
+ CodegenBackend :: Local ( path) => {
263
+ rustflags. push_str ( & format ! ( " -Zcodegen-backend={}" , path. to_str( ) . unwrap( ) ) ) ;
264
+ }
265
+ CodegenBackend :: Builtin ( name) => {
266
+ rustflags. push_str ( & format ! ( " -Zcodegen-backend={name}" ) ) ;
267
+ }
268
+ } ;
253
269
// Necessary for MinGW to find rsbegin.o and rsend.o
254
270
rustflags
255
271
. push_str ( & format ! ( " --sysroot {}" , RTSTARTUP_SYSROOT . to_path( dirs) . to_str( ) . unwrap( ) ) ) ;
0 commit comments