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