@@ -99,7 +99,6 @@ pub fn rustc<'a>(build: &'a Build, stage: u32, target: &str,
99
99
host, target) ;
100
100
101
101
let out_dir = build. cargo_out ( stage, & host, false , target) ;
102
- let rustc = out_dir. join ( exe ( "rustc" , target) ) ;
103
102
build. clear_if_dirty ( & out_dir, & libstd_shim ( build, stage, & host, target) ) ;
104
103
105
104
let mut cargo = build. cargo ( stage, compiler, false , target, "build" ) ;
@@ -153,10 +152,6 @@ pub fn rustc<'a>(build: &'a Build, stage: u32, target: &str,
153
152
154
153
let sysroot_libdir = build. sysroot_libdir ( stage, host, target) ;
155
154
add_to_sysroot ( & out_dir, & sysroot_libdir) ;
156
-
157
- if host == target {
158
- assemble_compiler ( build, stage, target, & rustc) ;
159
- }
160
155
}
161
156
162
157
/// Cargo's output path for the standard library in a given stage, compiled
@@ -172,39 +167,42 @@ fn compiler_file(compiler: &Path, file: &str) -> String {
172
167
173
168
/// Prepare a new compiler from the artifacts in `stage`
174
169
///
175
- /// This will link the compiler built by ` host` during the stage
176
- /// specified to the sysroot location for `host` to be the official
177
- /// `stage + 1` compiler for that host. This means that the `rustc` binary
178
- /// itself will be linked into place along with all supporting dynamic
179
- /// libraries.
180
- fn assemble_compiler ( build : & Build , stage : u32 , host : & str , rustc : & Path ) {
170
+ /// This will assemble a compiler in `build/$ host/stage$stage`. The compiler
171
+ /// must have been previously produced by the `stage - 1` build.config.build
172
+ /// compiler.
173
+ pub fn assemble_rustc ( build : & Build , stage : u32 , host : & str ) {
174
+ assert ! ( stage > 0 , "the stage0 compiler isn't assembled, it's downloaded" ) ;
175
+
181
176
// Clear out old files
182
- let sysroot = build. sysroot ( stage + 1 , host) ;
177
+ let sysroot = build. sysroot ( stage, host) ;
183
178
let _ = fs:: remove_dir_all ( & sysroot) ;
184
179
t ! ( fs:: create_dir_all( & sysroot) ) ;
185
180
186
181
// Link in all dylibs to the libdir
187
182
let sysroot_libdir = sysroot. join ( libdir ( host) ) ;
188
183
t ! ( fs:: create_dir_all( & sysroot_libdir) ) ;
189
- let src_libdir = build. sysroot_libdir ( stage, host , host) ;
184
+ let src_libdir = build. sysroot_libdir ( stage - 1 , & build . config . build , host) ;
190
185
for f in t ! ( fs:: read_dir( & src_libdir) ) . map ( |f| t ! ( f) ) {
191
186
let filename = f. file_name ( ) . into_string ( ) . unwrap ( ) ;
192
187
if is_dylib ( & filename) {
193
188
t ! ( fs:: hard_link( & f. path( ) , sysroot_libdir. join( & filename) ) ) ;
194
189
}
195
190
}
196
191
192
+ let out_dir = build. cargo_out ( stage - 1 , & build. config . build , false , host) ;
193
+
197
194
// Link the compiler binary itself into place
195
+ let rustc = out_dir. join ( exe ( "rustc" , host) ) ;
198
196
let bindir = sysroot. join ( "bin" ) ;
199
197
t ! ( fs:: create_dir_all( & bindir) ) ;
200
- let compiler = build. compiler_path ( & Compiler :: new ( stage + 1 , host) ) ;
198
+ let compiler = build. compiler_path ( & Compiler :: new ( stage, host) ) ;
201
199
let _ = fs:: remove_file ( & compiler) ;
202
200
t ! ( fs:: hard_link( rustc, compiler) ) ;
203
201
204
202
// See if rustdoc exists to link it into place
205
- let exe = exe ( "rustdoc" , host) ;
206
- let rustdoc_src = rustc . parent ( ) . unwrap ( ) . join ( & exe ) ;
207
- let rustdoc_dst = bindir. join ( exe ) ;
203
+ let rustdoc = exe ( "rustdoc" , host) ;
204
+ let rustdoc_src = out_dir . join ( & rustdoc ) ;
205
+ let rustdoc_dst = bindir. join ( & rustdoc ) ;
208
206
if fs:: metadata ( & rustdoc_src) . is_ok ( ) {
209
207
let _ = fs:: remove_file ( & rustdoc_dst) ;
210
208
t ! ( fs:: hard_link( & rustdoc_src, & rustdoc_dst) ) ;
0 commit comments