@@ -99,7 +99,6 @@ pub fn rustc<'a>(build: &'a Build, stage: u32, target: &str,
9999 host, target) ;
100100
101101 let out_dir = build. cargo_out ( stage, & host, false , target) ;
102- let rustc = out_dir. join ( exe ( "rustc" , target) ) ;
103102 build. clear_if_dirty ( & out_dir, & libstd_shim ( build, stage, & host, target) ) ;
104103
105104 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,
153152
154153 let sysroot_libdir = build. sysroot_libdir ( stage, host, target) ;
155154 add_to_sysroot ( & out_dir, & sysroot_libdir) ;
156-
157- if host == target {
158- assemble_compiler ( build, stage, target, & rustc) ;
159- }
160155}
161156
162157/// 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 {
172167
173168/// Prepare a new compiler from the artifacts in `stage`
174169///
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+
181176 // Clear out old files
182- let sysroot = build. sysroot ( stage + 1 , host) ;
177+ let sysroot = build. sysroot ( stage, host) ;
183178 let _ = fs:: remove_dir_all ( & sysroot) ;
184179 t ! ( fs:: create_dir_all( & sysroot) ) ;
185180
186181 // Link in all dylibs to the libdir
187182 let sysroot_libdir = sysroot. join ( libdir ( host) ) ;
188183 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) ;
190185 for f in t ! ( fs:: read_dir( & src_libdir) ) . map ( |f| t ! ( f) ) {
191186 let filename = f. file_name ( ) . into_string ( ) . unwrap ( ) ;
192187 if is_dylib ( & filename) {
193188 t ! ( fs:: hard_link( & f. path( ) , sysroot_libdir. join( & filename) ) ) ;
194189 }
195190 }
196191
192+ let out_dir = build. cargo_out ( stage - 1 , & build. config . build , false , host) ;
193+
197194 // Link the compiler binary itself into place
195+ let rustc = out_dir. join ( exe ( "rustc" , host) ) ;
198196 let bindir = sysroot. join ( "bin" ) ;
199197 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) ) ;
201199 let _ = fs:: remove_file ( & compiler) ;
202200 t ! ( fs:: hard_link( rustc, compiler) ) ;
203201
204202 // 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 ) ;
208206 if fs:: metadata ( & rustdoc_src) . is_ok ( ) {
209207 let _ = fs:: remove_file ( & rustdoc_dst) ;
210208 t ! ( fs:: hard_link( & rustdoc_src, & rustdoc_dst) ) ;
0 commit comments