@@ -58,30 +58,6 @@ pub fn std<'a>(build: &'a Build, stage: u32, target: &str,
58
58
}
59
59
60
60
build. run ( & mut cargo) ;
61
- std_link ( build, stage, target, compiler, host) ;
62
- }
63
-
64
- /// Link all libstd rlibs/dylibs into the sysroot location.
65
- ///
66
- /// Links those artifacts generated in the given `stage` for `target` produced
67
- /// by `compiler` into `host`'s sysroot.
68
- pub fn std_link ( build : & Build ,
69
- stage : u32 ,
70
- target : & str ,
71
- compiler : & Compiler ,
72
- host : & str ) {
73
- let libdir = build. sysroot_libdir ( stage, host, target) ;
74
- let out_dir = build. cargo_out ( stage, compiler. host , true , target) ;
75
-
76
- // If we're linking one compiler host's output into another, then we weren't
77
- // called from the `std` method above. In that case we clean out what's
78
- // already there and then also link compiler-rt into place.
79
- if host != compiler. host {
80
- let _ = fs:: remove_dir_all ( & libdir) ;
81
- t ! ( fs:: create_dir_all( & libdir) ) ;
82
- t ! ( fs:: hard_link( & build. compiler_rt_built. borrow( ) [ target] ,
83
- libdir. join( staticlib( "compiler-rt" , target) ) ) ) ;
84
- }
85
61
add_to_sysroot ( & out_dir, & libdir) ;
86
62
}
87
63
@@ -123,6 +99,7 @@ pub fn rustc<'a>(build: &'a Build, stage: u32, target: &str,
123
99
host, target) ;
124
100
125
101
let out_dir = build. cargo_out ( stage, & host, false , target) ;
102
+ let rustc = out_dir. join ( exe ( "rustc" , target) ) ;
126
103
build. clear_if_dirty ( & out_dir, & libstd_shim ( build, stage, & host, target) ) ;
127
104
128
105
let mut cargo = build. cargo ( stage, compiler, false , target, "build" ) ;
@@ -154,13 +131,10 @@ pub fn rustc<'a>(build: &'a Build, stage: u32, target: &str,
154
131
if !build. unstable_features {
155
132
cargo. env ( "CFG_DISABLE_UNSTABLE_FEATURES" , "1" ) ;
156
133
}
157
- let target_config = build. config . target_config . get ( target) ;
158
- if let Some ( ref s) = target_config. and_then ( |c| c. llvm_config . as_ref ( ) ) {
159
- cargo. env ( "LLVM_CONFIG" , s) ;
160
- } else {
161
- let llvm_config = build. llvm_out ( & build. config . build ) . join ( "bin" )
162
- . join ( exe ( "llvm-config" , target) ) ;
163
- cargo. env ( "LLVM_CONFIG" , llvm_config) ;
134
+ if let Some ( config) = build. config . target_config . get ( target) {
135
+ if let Some ( ref s) = config. llvm_config {
136
+ cargo. env ( "LLVM_CONFIG" , s) ;
137
+ }
164
138
}
165
139
if build. config . llvm_static_stdcpp {
166
140
cargo. env ( "LLVM_STATIC_STDCPP" ,
@@ -174,21 +148,12 @@ pub fn rustc<'a>(build: &'a Build, stage: u32, target: &str,
174
148
}
175
149
build. run ( & mut cargo) ;
176
150
177
- rustc_link ( build , stage , target , compiler , compiler . host ) ;
178
- }
151
+ let sysroot_libdir = build . sysroot_libdir ( stage , host, target ) ;
152
+ add_to_sysroot ( & out_dir , & sysroot_libdir ) ;
179
153
180
- /// Link all librustc rlibs/dylibs into the sysroot location.
181
- ///
182
- /// Links those artifacts generated in the given `stage` for `target` produced
183
- /// by `compiler` into `host`'s sysroot.
184
- pub fn rustc_link ( build : & Build ,
185
- stage : u32 ,
186
- target : & str ,
187
- compiler : & Compiler ,
188
- host : & str ) {
189
- let libdir = build. sysroot_libdir ( stage, host, target) ;
190
- let out_dir = build. cargo_out ( stage, compiler. host , false , target) ;
191
- add_to_sysroot ( & out_dir, & libdir) ;
154
+ if host == target {
155
+ assemble_compiler ( build, stage, target, & rustc) ;
156
+ }
192
157
}
193
158
194
159
/// Cargo's output path for the standard library in a given stage, compiled
@@ -204,42 +169,39 @@ fn compiler_file(compiler: &Path, file: &str) -> String {
204
169
205
170
/// Prepare a new compiler from the artifacts in `stage`
206
171
///
207
- /// This will assemble a compiler in `build/$ host/stage$stage`. The compiler
208
- /// must have been previously produced by the `stage - 1` build.config.build
209
- /// compiler.
210
- pub fn assemble_rustc ( build : & Build , stage : u32 , host : & str ) {
211
- assert ! ( stage > 0 , "the stage0 compiler isn't assembled, it's downloaded" ) ;
212
-
172
+ /// This will link the compiler built by ` host` during the stage
173
+ /// specified to the sysroot location for `host` to be the official
174
+ /// `stage + 1` compiler for that host. This means that the `rustc` binary
175
+ /// itself will be linked into place along with all supporting dynamic
176
+ /// libraries.
177
+ fn assemble_compiler ( build : & Build , stage : u32 , host : & str , rustc : & Path ) {
213
178
// Clear out old files
214
- let sysroot = build. sysroot ( stage, host) ;
179
+ let sysroot = build. sysroot ( stage + 1 , host) ;
215
180
let _ = fs:: remove_dir_all ( & sysroot) ;
216
181
t ! ( fs:: create_dir_all( & sysroot) ) ;
217
182
218
183
// Link in all dylibs to the libdir
219
184
let sysroot_libdir = sysroot. join ( libdir ( host) ) ;
220
185
t ! ( fs:: create_dir_all( & sysroot_libdir) ) ;
221
- let src_libdir = build. sysroot_libdir ( stage - 1 , & build . config . build , host) ;
186
+ let src_libdir = build. sysroot_libdir ( stage, host , host) ;
222
187
for f in t ! ( fs:: read_dir( & src_libdir) ) . map ( |f| t ! ( f) ) {
223
188
let filename = f. file_name ( ) . into_string ( ) . unwrap ( ) ;
224
189
if is_dylib ( & filename) {
225
190
t ! ( fs:: hard_link( & f. path( ) , sysroot_libdir. join( & filename) ) ) ;
226
191
}
227
192
}
228
193
229
- let out_dir = build. cargo_out ( stage - 1 , & build. config . build , false , host) ;
230
-
231
194
// Link the compiler binary itself into place
232
- let rustc = out_dir. join ( exe ( "rustc" , host) ) ;
233
195
let bindir = sysroot. join ( "bin" ) ;
234
196
t ! ( fs:: create_dir_all( & bindir) ) ;
235
- let compiler = build. compiler_path ( & Compiler :: new ( stage, host) ) ;
197
+ let compiler = build. compiler_path ( & Compiler :: new ( stage + 1 , host) ) ;
236
198
let _ = fs:: remove_file ( & compiler) ;
237
199
t ! ( fs:: hard_link( rustc, compiler) ) ;
238
200
239
201
// See if rustdoc exists to link it into place
240
- let rustdoc = exe ( "rustdoc" , host) ;
241
- let rustdoc_src = out_dir . join ( & rustdoc ) ;
242
- let rustdoc_dst = bindir. join ( & rustdoc ) ;
202
+ let exe = exe ( "rustdoc" , host) ;
203
+ let rustdoc_src = rustc . parent ( ) . unwrap ( ) . join ( & exe ) ;
204
+ let rustdoc_dst = bindir. join ( exe ) ;
243
205
if fs:: metadata ( & rustdoc_src) . is_ok ( ) {
244
206
let _ = fs:: remove_file ( & rustdoc_dst) ;
245
207
t ! ( fs:: hard_link( & rustdoc_src, & rustdoc_dst) ) ;
0 commit comments