@@ -26,14 +26,14 @@ use build_helper::output;
26
26
use filetime:: FileTime ;
27
27
28
28
use util:: { exe, staticlib, libdir, mtime, is_dylib, copy} ;
29
- use { Build , Compiler , Mode } ;
29
+ use { Build , Compiler , Mode , Triple } ;
30
30
31
31
/// Build the standard library.
32
32
///
33
33
/// This will build the standard library for a particular stage of the build
34
34
/// using the `compiler` targeting the `target` architecture. The artifacts
35
35
/// created will also be linked into the sysroot directory.
36
- pub fn std < ' a > ( build : & ' a Build , target : & str , compiler : & Compiler < ' a > ) {
36
+ pub fn std < ' a > ( build : & ' a Build , target : & Triple , compiler : & Compiler < ' a > ) {
37
37
println ! ( "Building stage{} std artifacts ({} -> {})" , compiler. stage,
38
38
compiler. host, target) ;
39
39
@@ -71,7 +71,7 @@ pub fn std<'a>(build: &'a Build, target: &str, compiler: &Compiler<'a>) {
71
71
cargo. env ( "JEMALLOC_OVERRIDE" , jemalloc) ;
72
72
}
73
73
}
74
- if target. contains ( "musl" ) {
74
+ if target. is_musl ( ) {
75
75
if let Some ( p) = build. musl_root ( target) {
76
76
cargo. env ( "MUSL_ROOT" , p) ;
77
77
}
@@ -87,9 +87,9 @@ pub fn std<'a>(build: &'a Build, target: &str, compiler: &Compiler<'a>) {
87
87
/// Links those artifacts generated in the given `stage` for `target` produced
88
88
/// by `compiler` into `host`'s sysroot.
89
89
pub fn std_link ( build : & Build ,
90
- target : & str ,
90
+ target : & Triple ,
91
91
compiler : & Compiler ,
92
- host : & str ) {
92
+ host : & Triple ) {
93
93
let target_compiler = Compiler :: new ( compiler. stage , host) ;
94
94
let libdir = build. sysroot_libdir ( & target_compiler, target) ;
95
95
let out_dir = build. cargo_out ( compiler, Mode :: Libstd , target) ;
@@ -103,7 +103,7 @@ pub fn std_link(build: &Build,
103
103
}
104
104
add_to_sysroot ( & out_dir, & libdir) ;
105
105
106
- if target. contains ( "musl" ) && !target. contains ( "mips" ) {
106
+ if target. is_musl ( ) && !target. is_mips ( ) {
107
107
copy_musl_third_party_objects ( build, & libdir) ;
108
108
}
109
109
}
@@ -123,8 +123,8 @@ fn copy_musl_third_party_objects(build: &Build, into: &Path) {
123
123
/// They don't require any library support as they're just plain old object
124
124
/// files, so we just use the nightly snapshot compiler to always build them (as
125
125
/// no other compilers are guaranteed to be available).
126
- fn build_startup_objects ( build : & Build , target : & str , into : & Path ) {
127
- if !target. contains ( "pc-windows-gnu" ) {
126
+ fn build_startup_objects ( build : & Build , target : & Triple , into : & Path ) {
127
+ if !target. is_pc_windows_gnu ( ) {
128
128
return
129
129
}
130
130
let compiler = Compiler :: new ( 0 , & build. config . build ) ;
@@ -150,7 +150,8 @@ fn build_startup_objects(build: &Build, target: &str, into: &Path) {
150
150
/// This will build libtest and supporting libraries for a particular stage of
151
151
/// the build using the `compiler` targeting the `target` architecture. The
152
152
/// artifacts created will also be linked into the sysroot directory.
153
- pub fn test < ' a > ( build : & ' a Build , target : & str , compiler : & Compiler < ' a > ) {
153
+ pub fn test < ' a > ( build : & ' a Build , target : & Triple ,
154
+ compiler : & Compiler < ' a > ) {
154
155
println ! ( "Building stage{} test artifacts ({} -> {})" , compiler. stage,
155
156
compiler. host, target) ;
156
157
let out_dir = build. cargo_out ( compiler, Mode :: Libtest , target) ;
@@ -168,9 +169,9 @@ pub fn test<'a>(build: &'a Build, target: &str, compiler: &Compiler<'a>) {
168
169
/// Links those artifacts generated in the given `stage` for `target` produced
169
170
/// by `compiler` into `host`'s sysroot.
170
171
pub fn test_link ( build : & Build ,
171
- target : & str ,
172
+ target : & Triple ,
172
173
compiler : & Compiler ,
173
- host : & str ) {
174
+ host : & Triple ) {
174
175
let target_compiler = Compiler :: new ( compiler. stage , host) ;
175
176
let libdir = build. sysroot_libdir ( & target_compiler, target) ;
176
177
let out_dir = build. cargo_out ( compiler, Mode :: Libtest , target) ;
@@ -182,7 +183,7 @@ pub fn test_link(build: &Build,
182
183
/// This will build the compiler for a particular stage of the build using
183
184
/// the `compiler` targeting the `target` architecture. The artifacts
184
185
/// created will also be linked into the sysroot directory.
185
- pub fn rustc < ' a > ( build : & ' a Build , target : & str , compiler : & Compiler < ' a > ) {
186
+ pub fn rustc < ' a > ( build : & ' a Build , target : & Triple , compiler : & Compiler < ' a > ) {
186
187
println ! ( "Building stage{} compiler artifacts ({} -> {})" ,
187
188
compiler. stage, compiler. host, target) ;
188
189
@@ -241,9 +242,9 @@ pub fn rustc<'a>(build: &'a Build, target: &str, compiler: &Compiler<'a>) {
241
242
/// Links those artifacts generated in the given `stage` for `target` produced
242
243
/// by `compiler` into `host`'s sysroot.
243
244
pub fn rustc_link ( build : & Build ,
244
- target : & str ,
245
+ target : & Triple ,
245
246
compiler : & Compiler ,
246
- host : & str ) {
247
+ host : & Triple ) {
247
248
let target_compiler = Compiler :: new ( compiler. stage , host) ;
248
249
let libdir = build. sysroot_libdir ( & target_compiler, target) ;
249
250
let out_dir = build. cargo_out ( compiler, Mode :: Librustc , target) ;
@@ -252,13 +253,15 @@ pub fn rustc_link(build: &Build,
252
253
253
254
/// Cargo's output path for the standard library in a given stage, compiled
254
255
/// by a particular compiler for the specified target.
255
- fn libstd_stamp ( build : & Build , compiler : & Compiler , target : & str ) -> PathBuf {
256
+ fn libstd_stamp ( build : & Build , compiler : & Compiler ,
257
+ target : & Triple ) -> PathBuf {
256
258
build. cargo_out ( compiler, Mode :: Libstd , target) . join ( ".libstd.stamp" )
257
259
}
258
260
259
261
/// Cargo's output path for libtest in a given stage, compiled by a particular
260
262
/// compiler for the specified target.
261
- fn libtest_stamp ( build : & Build , compiler : & Compiler , target : & str ) -> PathBuf {
263
+ fn libtest_stamp ( build : & Build , compiler : & Compiler ,
264
+ target : & Triple ) -> PathBuf {
262
265
build. cargo_out ( compiler, Mode :: Libtest , target) . join ( ".libtest.stamp" )
263
266
}
264
267
@@ -273,7 +276,7 @@ fn compiler_file(compiler: &Path, file: &str) -> PathBuf {
273
276
/// This will assemble a compiler in `build/$host/stage$stage`. The compiler
274
277
/// must have been previously produced by the `stage - 1` build.config.build
275
278
/// compiler.
276
- pub fn assemble_rustc ( build : & Build , stage : u32 , host : & str ) {
279
+ pub fn assemble_rustc ( build : & Build , stage : u32 , host : & Triple ) {
277
280
assert ! ( stage > 0 , "the stage0 compiler isn't assembled, it's downloaded" ) ;
278
281
// The compiler that we're assembling
279
282
let target_compiler = Compiler :: new ( stage, host) ;
@@ -360,7 +363,7 @@ fn add_to_sysroot(out_dir: &Path, sysroot_dst: &Path) {
360
363
///
361
364
/// This will build the specified tool with the specified `host` compiler in
362
365
/// `stage` into the normal cargo output directory.
363
- pub fn tool ( build : & Build , stage : u32 , host : & str , tool : & str ) {
366
+ pub fn tool ( build : & Build , stage : u32 , host : & Triple , tool : & str ) {
364
367
println ! ( "Building stage{} tool {} ({})" , stage, tool, host) ;
365
368
366
369
let compiler = Compiler :: new ( stage, host) ;
0 commit comments