@@ -18,14 +18,16 @@ pub(crate) fn build_sysroot(
18
18
sysroot_kind : SysrootKind ,
19
19
cg_clif_dylib_src : & Path ,
20
20
bootstrap_host_compiler : & Compiler ,
21
- target_triple : & str ,
22
- ) {
21
+ target_triple : String ,
22
+ ) -> Compiler {
23
23
eprintln ! ( "[BUILD] sysroot {:?}" , sysroot_kind) ;
24
24
25
25
DIST_DIR . ensure_fresh ( dirs) ;
26
26
BIN_DIR . ensure_exists ( dirs) ;
27
27
LIB_DIR . ensure_exists ( dirs) ;
28
28
29
+ let is_native = bootstrap_host_compiler. triple == target_triple;
30
+
29
31
// Copy the backend
30
32
let cg_clif_dylib_path = if cfg ! ( windows) {
31
33
// Windows doesn't have rpath support, so the cg_clif dylib needs to be next to the
@@ -55,20 +57,20 @@ pub(crate) fn build_sysroot(
55
57
56
58
let host_rustlib_lib =
57
59
RUSTLIB_DIR . to_path ( dirs) . join ( & bootstrap_host_compiler. triple ) . join ( "lib" ) ;
58
- let target_rustlib_lib = RUSTLIB_DIR . to_path ( dirs) . join ( target_triple) . join ( "lib" ) ;
60
+ let target_rustlib_lib = RUSTLIB_DIR . to_path ( dirs) . join ( & target_triple) . join ( "lib" ) ;
59
61
fs:: create_dir_all ( & host_rustlib_lib) . unwrap ( ) ;
60
62
fs:: create_dir_all ( & target_rustlib_lib) . unwrap ( ) ;
61
63
62
64
if target_triple == "x86_64-pc-windows-gnu" {
63
- if !default_sysroot. join ( "lib" ) . join ( "rustlib" ) . join ( target_triple) . join ( "lib" ) . exists ( ) {
65
+ if !default_sysroot. join ( "lib" ) . join ( "rustlib" ) . join ( & target_triple) . join ( "lib" ) . exists ( ) {
64
66
eprintln ! (
65
67
"The x86_64-pc-windows-gnu target needs to be installed first before it is possible \
66
68
to compile a sysroot for it.",
67
69
) ;
68
70
process:: exit ( 1 ) ;
69
71
}
70
72
for file in fs:: read_dir (
71
- default_sysroot. join ( "lib" ) . join ( "rustlib" ) . join ( target_triple) . join ( "lib" ) ,
73
+ default_sysroot. join ( "lib" ) . join ( "rustlib" ) . join ( & target_triple) . join ( "lib" ) ,
72
74
)
73
75
. unwrap ( )
74
76
{
@@ -108,9 +110,9 @@ pub(crate) fn build_sysroot(
108
110
try_hard_link ( & file, host_rustlib_lib. join ( file. file_name ( ) . unwrap ( ) ) ) ;
109
111
}
110
112
111
- if target_triple != bootstrap_host_compiler . triple {
113
+ if !is_native {
112
114
for file in fs:: read_dir (
113
- default_sysroot. join ( "lib" ) . join ( "rustlib" ) . join ( target_triple) . join ( "lib" ) ,
115
+ default_sysroot. join ( "lib" ) . join ( "rustlib" ) . join ( & target_triple) . join ( "lib" ) ,
114
116
)
115
117
. unwrap ( )
116
118
{
@@ -127,13 +129,13 @@ pub(crate) fn build_sysroot(
127
129
& cg_clif_dylib_path,
128
130
) ;
129
131
130
- if bootstrap_host_compiler . triple != target_triple {
132
+ if !is_native {
131
133
build_clif_sysroot_for_triple (
132
134
dirs,
133
135
channel,
134
136
{
135
137
let mut bootstrap_target_compiler = bootstrap_host_compiler. clone ( ) ;
136
- bootstrap_target_compiler. triple = target_triple. to_owned ( ) ;
138
+ bootstrap_target_compiler. triple = target_triple. clone ( ) ;
137
139
bootstrap_target_compiler. set_cross_linker_and_runner ( ) ;
138
140
bootstrap_target_compiler
139
141
} ,
@@ -152,6 +154,12 @@ pub(crate) fn build_sysroot(
152
154
}
153
155
}
154
156
}
157
+
158
+ let mut target_compiler = Compiler :: clif_with_triple ( & dirs, target_triple) ;
159
+ if !is_native {
160
+ target_compiler. set_cross_linker_and_runner ( ) ;
161
+ }
162
+ target_compiler
155
163
}
156
164
157
165
pub ( crate ) static ORIG_BUILD_SYSROOT : RelPath = RelPath :: SOURCE . join ( "build_sysroot" ) ;
0 commit comments