@@ -13,6 +13,7 @@ use std::time::{Duration, Instant};
13
13
14
14
use build_helper:: { output, t} ;
15
15
16
+ use crate :: config:: TargetSelection ;
16
17
use crate :: cache:: { Cache , Interned , INTERNER } ;
17
18
use crate :: check;
18
19
use crate :: compile;
@@ -86,8 +87,8 @@ pub trait Step: 'static + Clone + Debug + PartialEq + Eq + Hash {
86
87
87
88
pub struct RunConfig < ' a > {
88
89
pub builder : & ' a Builder < ' a > ,
89
- pub host : Interned < String > ,
90
- pub target : Interned < String > ,
90
+ pub host : TargetSelection ,
91
+ pub target : TargetSelection ,
91
92
pub path : PathBuf ,
92
93
}
93
94
@@ -573,7 +574,7 @@ impl<'a> Builder<'a> {
573
574
/// not take `Compiler` since all `Compiler` instances are meant to be
574
575
/// obtained through this function, since it ensures that they are valid
575
576
/// (i.e., built and assembled).
576
- pub fn compiler ( & self , stage : u32 , host : Interned < String > ) -> Compiler {
577
+ pub fn compiler ( & self , stage : u32 , host : TargetSelection ) -> Compiler {
577
578
self . ensure ( compile:: Assemble { target_compiler : Compiler { stage, host } } )
578
579
}
579
580
@@ -591,8 +592,8 @@ impl<'a> Builder<'a> {
591
592
pub fn compiler_for (
592
593
& self ,
593
594
stage : u32 ,
594
- host : Interned < String > ,
595
- target : Interned < String > ,
595
+ host : TargetSelection ,
596
+ target : TargetSelection ,
596
597
) -> Compiler {
597
598
if self . build . force_use_stage1 ( Compiler { stage, host } , target) {
598
599
self . compiler ( 1 , self . config . build )
@@ -610,12 +611,12 @@ impl<'a> Builder<'a> {
610
611
pub fn sysroot_libdir (
611
612
& self ,
612
613
compiler : Compiler ,
613
- target : Interned < String > ,
614
+ target : TargetSelection ,
614
615
) -> Interned < PathBuf > {
615
616
#[ derive( Debug , Copy , Clone , Hash , PartialEq , Eq ) ]
616
617
struct Libdir {
617
618
compiler : Compiler ,
618
- target : Interned < String > ,
619
+ target : TargetSelection ,
619
620
}
620
621
impl Step for Libdir {
621
622
type Output = Interned < PathBuf > ;
@@ -625,14 +626,14 @@ impl<'a> Builder<'a> {
625
626
}
626
627
627
628
fn run ( self , builder : & Builder < ' _ > ) -> Interned < PathBuf > {
628
- let target = crate :: hackit ( & self . target ) ;
629
+ let target = self . target ;
629
630
630
631
let lib = builder. sysroot_libdir_relative ( self . compiler ) ;
631
- let sysroot = dbg ! ( dbg! ( builder
632
- . sysroot( self . compiler) )
632
+ let sysroot = builder
633
+ . sysroot ( self . compiler )
633
634
. join ( lib)
634
- . join( "rustlib" ) )
635
- . join ( target)
635
+ . join ( "rustlib" )
636
+ . join ( target. triple )
636
637
. join ( "lib" ) ;
637
638
let _ = fs:: remove_dir_all ( & sysroot) ;
638
639
eprintln ! ( "{}" , sysroot. display( ) ) ;
@@ -656,7 +657,7 @@ impl<'a> Builder<'a> {
656
657
Some ( relative_libdir) if compiler. stage >= 1 => {
657
658
self . sysroot ( compiler) . join ( relative_libdir)
658
659
}
659
- _ => self . sysroot ( compiler) . join ( libdir ( & compiler. host ) ) ,
660
+ _ => self . sysroot ( compiler) . join ( libdir ( compiler. host ) ) ,
660
661
}
661
662
}
662
663
}
@@ -668,11 +669,11 @@ impl<'a> Builder<'a> {
668
669
/// Windows.
669
670
pub fn libdir_relative ( & self , compiler : Compiler ) -> & Path {
670
671
if compiler. is_snapshot ( self ) {
671
- libdir ( & self . config . build ) . as_ref ( )
672
+ libdir ( self . config . build ) . as_ref ( )
672
673
} else {
673
674
match self . config . libdir_relative ( ) {
674
675
Some ( relative_libdir) if compiler. stage >= 1 => relative_libdir,
675
- _ => libdir ( & compiler. host ) . as_ref ( ) ,
676
+ _ => libdir ( compiler. host ) . as_ref ( ) ,
676
677
}
677
678
}
678
679
}
@@ -707,7 +708,7 @@ impl<'a> Builder<'a> {
707
708
if compiler. is_snapshot ( self ) {
708
709
self . initial_rustc . clone ( )
709
710
} else {
710
- self . sysroot ( compiler) . join ( "bin" ) . join ( exe ( "rustc" , & compiler. host ) )
711
+ self . sysroot ( compiler) . join ( "bin" ) . join ( exe ( "rustc" , compiler. host ) )
711
712
}
712
713
}
713
714
@@ -741,7 +742,7 @@ impl<'a> Builder<'a> {
741
742
///
742
743
/// Note that this returns `None` if LLVM is disabled, or if we're in a
743
744
/// check build or dry-run, where there's no need to build all of LLVM.
744
- fn llvm_config ( & self , target : Interned < String > ) -> Option < PathBuf > {
745
+ fn llvm_config ( & self , target : TargetSelection ) -> Option < PathBuf > {
745
746
if self . config . llvm_enabled ( ) && self . kind != Kind :: Check && !self . config . dry_run {
746
747
let llvm_config = self . ensure ( native:: Llvm { target } ) ;
747
748
if llvm_config. is_file ( ) {
@@ -762,7 +763,7 @@ impl<'a> Builder<'a> {
762
763
& self ,
763
764
compiler : Compiler ,
764
765
mode : Mode ,
765
- target : Interned < String > ,
766
+ target : TargetSelection ,
766
767
cmd : & str ,
767
768
) -> Cargo {
768
769
let mut cargo = Command :: new ( & self . initial_cargo ) ;
@@ -793,7 +794,7 @@ impl<'a> Builder<'a> {
793
794
}
794
795
795
796
if cmd != "install" {
796
- cargo. arg ( "--target" ) . arg ( target) ;
797
+ cargo. arg ( "--target" ) . arg ( target. rustc_target_arg ( ) ) ;
797
798
} else {
798
799
assert_eq ! ( target, compiler. host) ;
799
800
}
@@ -819,7 +820,7 @@ impl<'a> Builder<'a> {
819
820
compiler. stage
820
821
} ;
821
822
822
- let mut rustflags = Rustflags :: new ( & target) ;
823
+ let mut rustflags = Rustflags :: new ( target) ;
823
824
if stage != 0 {
824
825
if let Ok ( s) = env:: var ( "CARGOFLAGS_NOT_BOOTSTRAP" ) {
825
826
cargo. args ( s. split_whitespace ( ) ) ;
@@ -1000,7 +1001,7 @@ impl<'a> Builder<'a> {
1000
1001
// argument manually via `-C link-args=-Wl,-rpath,...`. Plus isn't it
1001
1002
// fun to pass a flag to a tool to pass a flag to pass a flag to a tool
1002
1003
// to change a flag in a binary?
1003
- if self . config . rust_rpath && util:: use_host_linker ( & target) {
1004
+ if self . config . rust_rpath && util:: use_host_linker ( target) {
1004
1005
let rpath = if target. contains ( "apple" ) {
1005
1006
// Note that we need to take one extra step on macOS to also pass
1006
1007
// `-Wl,-instal_name,@rpath/...` to get things to work right. To
@@ -1028,7 +1029,7 @@ impl<'a> Builder<'a> {
1028
1029
}
1029
1030
1030
1031
if let Some ( target_linker) = self . linker ( target, can_use_lld) {
1031
- let target = crate :: envify ( & target) ;
1032
+ let target = crate :: envify ( & target. triple ) ;
1032
1033
cargo. env ( & format ! ( "CARGO_TARGET_{}_LINKER" , target) , target_linker) ;
1033
1034
}
1034
1035
if !( [ "build" , "check" , "clippy" , "fix" , "rustc" ] . contains ( & cmd) ) && want_rustdoc {
@@ -1181,21 +1182,21 @@ impl<'a> Builder<'a> {
1181
1182
}
1182
1183
} ;
1183
1184
let cc = ccacheify ( & self . cc ( target) ) ;
1184
- cargo. env ( format ! ( "CC_{}" , target) , & cc) ;
1185
+ cargo. env ( format ! ( "CC_{}" , target. triple ) , & cc) ;
1185
1186
1186
1187
let cflags = self . cflags ( target, GitRepo :: Rustc ) . join ( " " ) ;
1187
- cargo. env ( format ! ( "CFLAGS_{}" , target) , cflags. clone ( ) ) ;
1188
+ cargo. env ( format ! ( "CFLAGS_{}" , target. triple ) , cflags. clone ( ) ) ;
1188
1189
1189
1190
if let Some ( ar) = self . ar ( target) {
1190
1191
let ranlib = format ! ( "{} s" , ar. display( ) ) ;
1191
- cargo. env ( format ! ( "AR_{}" , target) , ar) . env ( format ! ( "RANLIB_{}" , target) , ranlib) ;
1192
+ cargo. env ( format ! ( "AR_{}" , target. triple ) , ar) . env ( format ! ( "RANLIB_{}" , target. triple ) , ranlib) ;
1192
1193
}
1193
1194
1194
1195
if let Ok ( cxx) = self . cxx ( target) {
1195
1196
let cxx = ccacheify ( & cxx) ;
1196
1197
cargo
1197
- . env ( format ! ( "CXX_{}" , target) , & cxx)
1198
- . env ( format ! ( "CXXFLAGS_{}" , target) , cflags) ;
1198
+ . env ( format ! ( "CXX_{}" , target. triple ) , & cxx)
1199
+ . env ( format ! ( "CXXFLAGS_{}" , target. triple ) , cflags) ;
1199
1200
}
1200
1201
}
1201
1202
@@ -1229,7 +1230,7 @@ impl<'a> Builder<'a> {
1229
1230
// Environment variables *required* throughout the build
1230
1231
//
1231
1232
// FIXME: should update code to not require this env var
1232
- cargo. env ( "CFG_COMPILER_HOST_TRIPLE" , target) ;
1233
+ cargo. env ( "CFG_COMPILER_HOST_TRIPLE" , target. triple ) ;
1233
1234
1234
1235
// Set this for all builds to make sure doc builds also get it.
1235
1236
cargo. env ( "CFG_RELEASE_CHANNEL" , & self . config . channel ) ;
@@ -1385,15 +1386,15 @@ mod tests;
1385
1386
struct Rustflags ( String ) ;
1386
1387
1387
1388
impl Rustflags {
1388
- fn new ( target : & str ) -> Rustflags {
1389
+ fn new ( target : TargetSelection ) -> Rustflags {
1389
1390
let mut ret = Rustflags ( String :: new ( ) ) ;
1390
1391
1391
1392
// Inherit `RUSTFLAGS` by default ...
1392
1393
ret. env ( "RUSTFLAGS" ) ;
1393
1394
1394
1395
// ... and also handle target-specific env RUSTFLAGS if they're
1395
1396
// configured.
1396
- let target_specific = format ! ( "CARGO_TARGET_{}_RUSTFLAGS" , crate :: envify( target) ) ;
1397
+ let target_specific = format ! ( "CARGO_TARGET_{}_RUSTFLAGS" , crate :: envify( & target. triple ) ) ;
1397
1398
ret. env ( & target_specific) ;
1398
1399
1399
1400
ret
0 commit comments