@@ -23,26 +23,23 @@ use build::{Build, Compiler, Mode};
23
23
/// This will build the standard library for a particular stage of the build
24
24
/// using the `compiler` targeting the `target` architecture. The artifacts
25
25
/// created will also be linked into the sysroot directory.
26
- pub fn std < ' a > ( build : & ' a Build , stage : u32 , target : & str ,
27
- compiler : & Compiler < ' a > ) {
28
- let host = compiler. host ;
29
- println ! ( "Building stage{} std artifacts ({} -> {})" , stage,
30
- host, target) ;
26
+ pub fn std < ' a > ( build : & ' a Build , target : & str , compiler : & Compiler < ' a > ) {
27
+ println ! ( "Building stage{} std artifacts ({} -> {})" , compiler. stage,
28
+ compiler. host, target) ;
31
29
32
30
// Move compiler-rt into place as it'll be required by the compiler when
33
31
// building the standard library to link the dylib of libstd
34
- let libdir = build. sysroot_libdir ( stage , & host , target) ;
32
+ let libdir = build. sysroot_libdir ( compiler , target) ;
35
33
let _ = fs:: remove_dir_all ( & libdir) ;
36
34
t ! ( fs:: create_dir_all( & libdir) ) ;
37
35
t ! ( fs:: hard_link( & build. compiler_rt_built. borrow( ) [ target] ,
38
36
libdir. join( staticlib( "compiler-rt" , target) ) ) ) ;
39
37
40
38
build_startup_objects ( build, target, & libdir) ;
41
39
42
- let out_dir = build. cargo_out ( stage , & host , Mode :: Libstd , target) ;
40
+ let out_dir = build. cargo_out ( compiler , Mode :: Libstd , target) ;
43
41
build. clear_if_dirty ( & out_dir, & build. compiler_path ( compiler) ) ;
44
- let mut cargo = build. cargo ( stage, compiler, Mode :: Libstd , Some ( target) ,
45
- "build" ) ;
42
+ let mut cargo = build. cargo ( compiler, Mode :: Libstd , target, "build" ) ;
46
43
cargo. arg ( "--features" ) . arg ( build. std_features ( ) )
47
44
. arg ( "--manifest-path" )
48
45
. arg ( build. src . join ( "src/rustc/std_shim/Cargo.toml" ) ) ;
@@ -59,20 +56,20 @@ pub fn std<'a>(build: &'a Build, stage: u32, target: &str,
59
56
}
60
57
61
58
build. run ( & mut cargo) ;
62
- std_link ( build, stage , target, compiler, host) ;
59
+ std_link ( build, target, compiler, compiler . host ) ;
63
60
}
64
61
65
62
/// Link all libstd rlibs/dylibs into the sysroot location.
66
63
///
67
64
/// Links those artifacts generated in the given `stage` for `target` produced
68
65
/// by `compiler` into `host`'s sysroot.
69
66
pub fn std_link ( build : & Build ,
70
- stage : u32 ,
71
67
target : & str ,
72
68
compiler : & Compiler ,
73
69
host : & str ) {
74
- let libdir = build. sysroot_libdir ( stage, host, target) ;
75
- let out_dir = build. cargo_out ( stage, compiler. host , Mode :: Libstd , target) ;
70
+ let target_compiler = Compiler :: new ( compiler. stage , host) ;
71
+ let libdir = build. sysroot_libdir ( & target_compiler, target) ;
72
+ let out_dir = build. cargo_out ( compiler, Mode :: Libstd , target) ;
76
73
77
74
// If we're linking one compiler host's output into another, then we weren't
78
75
// called from the `std` method above. In that case we clean out what's
@@ -85,7 +82,8 @@ pub fn std_link(build: &Build,
85
82
}
86
83
add_to_sysroot ( & out_dir, & libdir) ;
87
84
88
- if target. contains ( "musl" ) && ( target. contains ( "x86_64" ) || target. contains ( "i686" ) ) {
85
+ if target. contains ( "musl" ) &&
86
+ ( target. contains ( "x86_64" ) || target. contains ( "i686" ) ) {
89
87
copy_third_party_objects ( build, target, & libdir) ;
90
88
}
91
89
}
@@ -130,17 +128,14 @@ fn build_startup_objects(build: &Build, target: &str, into: &Path) {
130
128
/// This will build the compiler for a particular stage of the build using
131
129
/// the `compiler` targeting the `target` architecture. The artifacts
132
130
/// created will also be linked into the sysroot directory.
133
- pub fn rustc < ' a > ( build : & ' a Build , stage : u32 , target : & str ,
134
- compiler : & Compiler < ' a > ) {
135
- let host = compiler. host ;
136
- println ! ( "Building stage{} compiler artifacts ({} -> {})" , stage,
137
- host, target) ;
131
+ pub fn rustc < ' a > ( build : & ' a Build , target : & str , compiler : & Compiler < ' a > ) {
132
+ println ! ( "Building stage{} compiler artifacts ({} -> {})" ,
133
+ compiler. stage, compiler. host, target) ;
138
134
139
- let out_dir = build. cargo_out ( stage , & host , Mode :: Librustc , target) ;
140
- build. clear_if_dirty ( & out_dir, & libstd_shim ( build, stage , & host , target) ) ;
135
+ let out_dir = build. cargo_out ( compiler , Mode :: Librustc , target) ;
136
+ build. clear_if_dirty ( & out_dir, & libstd_shim ( build, compiler , target) ) ;
141
137
142
- let mut cargo = build. cargo ( stage, compiler, Mode :: Librustc , Some ( target) ,
143
- "build" ) ;
138
+ let mut cargo = build. cargo ( compiler, Mode :: Librustc , target, "build" ) ;
144
139
cargo. arg ( "--features" ) . arg ( build. rustc_features ( ) )
145
140
. arg ( "--manifest-path" )
146
141
. arg ( build. src . join ( "src/rustc/Cargo.toml" ) ) ;
@@ -184,27 +179,27 @@ pub fn rustc<'a>(build: &'a Build, stage: u32, target: &str,
184
179
}
185
180
build. run ( & mut cargo) ;
186
181
187
- rustc_link ( build, stage , target, compiler, compiler. host ) ;
182
+ rustc_link ( build, target, compiler, compiler. host ) ;
188
183
}
189
184
190
185
/// Link all librustc rlibs/dylibs into the sysroot location.
191
186
///
192
187
/// Links those artifacts generated in the given `stage` for `target` produced
193
188
/// by `compiler` into `host`'s sysroot.
194
189
pub fn rustc_link ( build : & Build ,
195
- stage : u32 ,
196
190
target : & str ,
197
191
compiler : & Compiler ,
198
192
host : & str ) {
199
- let libdir = build. sysroot_libdir ( stage, host, target) ;
200
- let out_dir = build. cargo_out ( stage, compiler. host , Mode :: Librustc , target) ;
193
+ let target_compiler = Compiler :: new ( compiler. stage , host) ;
194
+ let libdir = build. sysroot_libdir ( & target_compiler, target) ;
195
+ let out_dir = build. cargo_out ( compiler, Mode :: Librustc , target) ;
201
196
add_to_sysroot ( & out_dir, & libdir) ;
202
197
}
203
198
204
199
/// Cargo's output path for the standard library in a given stage, compiled
205
200
/// by a particular compiler for the specified target.
206
- fn libstd_shim ( build : & Build , stage : u32 , host : & str , target : & str ) -> PathBuf {
207
- build. cargo_out ( stage , host , Mode :: Libstd , target) . join ( "libstd_shim.rlib" )
201
+ fn libstd_shim ( build : & Build , compiler : & Compiler , target : & str ) -> PathBuf {
202
+ build. cargo_out ( compiler , Mode :: Libstd , target) . join ( "libstd_shim.rlib" )
208
203
}
209
204
210
205
fn compiler_file ( compiler : & Path , file : & str ) -> String {
@@ -219,25 +214,29 @@ fn compiler_file(compiler: &Path, file: &str) -> String {
219
214
/// compiler.
220
215
pub fn assemble_rustc ( build : & Build , stage : u32 , host : & str ) {
221
216
assert ! ( stage > 0 , "the stage0 compiler isn't assembled, it's downloaded" ) ;
217
+ // The compiler that we're assembling
218
+ let target_compiler = Compiler :: new ( stage, host) ;
219
+
220
+ // The compiler that compiled the compiler we're assembling
221
+ let build_compiler = Compiler :: new ( stage - 1 , & build. config . build ) ;
222
222
223
223
// Clear out old files
224
- let sysroot = build. sysroot ( stage , host ) ;
224
+ let sysroot = build. sysroot ( & target_compiler ) ;
225
225
let _ = fs:: remove_dir_all ( & sysroot) ;
226
226
t ! ( fs:: create_dir_all( & sysroot) ) ;
227
227
228
228
// Link in all dylibs to the libdir
229
229
let sysroot_libdir = sysroot. join ( libdir ( host) ) ;
230
230
t ! ( fs:: create_dir_all( & sysroot_libdir) ) ;
231
- let src_libdir = build. sysroot_libdir ( stage - 1 , & build . config . build , host) ;
231
+ let src_libdir = build. sysroot_libdir ( & build_compiler , host) ;
232
232
for f in t ! ( fs:: read_dir( & src_libdir) ) . map ( |f| t ! ( f) ) {
233
233
let filename = f. file_name ( ) . into_string ( ) . unwrap ( ) ;
234
234
if is_dylib ( & filename) {
235
235
t ! ( fs:: hard_link( & f. path( ) , sysroot_libdir. join( & filename) ) ) ;
236
236
}
237
237
}
238
238
239
- let out_dir = build. cargo_out ( stage - 1 , & build. config . build ,
240
- Mode :: Librustc , host) ;
239
+ let out_dir = build. cargo_out ( & build_compiler, Mode :: Librustc , host) ;
241
240
242
241
// Link the compiler binary itself into place
243
242
let rustc = out_dir. join ( exe ( "rustc" , host) ) ;
@@ -315,7 +314,7 @@ pub fn tool(build: &Build, stage: u32, host: &str, tool: &str) {
315
314
// let out_dir = build.cargo_out(stage, &host, Mode::Librustc, target);
316
315
// build.clear_if_dirty(&out_dir, &libstd_shim(build, stage, &host, target));
317
316
318
- let mut cargo = build. cargo ( stage , & compiler, Mode :: Tool , None , "build" ) ;
317
+ let mut cargo = build. cargo ( & compiler, Mode :: Tool , host , "build" ) ;
319
318
cargo. arg ( "--manifest-path" )
320
319
. arg ( build. src . join ( format ! ( "src/tools/{}/Cargo.toml" , tool) ) ) ;
321
320
build. run ( & mut cargo) ;
0 commit comments