@@ -13,6 +13,7 @@ use std::time::{Duration, Instant};
1313
1414use build_helper:: { output, t} ;
1515
16+ use crate :: config:: TargetSelection ;
1617use crate :: cache:: { Cache , Interned , INTERNER } ;
1718use crate :: check;
1819use crate :: compile;
@@ -86,8 +87,8 @@ pub trait Step: 'static + Clone + Debug + PartialEq + Eq + Hash {
8687
8788pub struct RunConfig < ' a > {
8889 pub builder : & ' a Builder < ' a > ,
89- pub host : Interned < String > ,
90- pub target : Interned < String > ,
90+ pub host : TargetSelection ,
91+ pub target : TargetSelection ,
9192 pub path : PathBuf ,
9293}
9394
@@ -573,7 +574,7 @@ impl<'a> Builder<'a> {
573574 /// not take `Compiler` since all `Compiler` instances are meant to be
574575 /// obtained through this function, since it ensures that they are valid
575576 /// (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 {
577578 self . ensure ( compile:: Assemble { target_compiler : Compiler { stage, host } } )
578579 }
579580
@@ -591,8 +592,8 @@ impl<'a> Builder<'a> {
591592 pub fn compiler_for (
592593 & self ,
593594 stage : u32 ,
594- host : Interned < String > ,
595- target : Interned < String > ,
595+ host : TargetSelection ,
596+ target : TargetSelection ,
596597 ) -> Compiler {
597598 if self . build . force_use_stage1 ( Compiler { stage, host } , target) {
598599 self . compiler ( 1 , self . config . build )
@@ -610,12 +611,12 @@ impl<'a> Builder<'a> {
610611 pub fn sysroot_libdir (
611612 & self ,
612613 compiler : Compiler ,
613- target : Interned < String > ,
614+ target : TargetSelection ,
614615 ) -> Interned < PathBuf > {
615616 #[ derive( Debug , Copy , Clone , Hash , PartialEq , Eq ) ]
616617 struct Libdir {
617618 compiler : Compiler ,
618- target : Interned < String > ,
619+ target : TargetSelection ,
619620 }
620621 impl Step for Libdir {
621622 type Output = Interned < PathBuf > ;
@@ -625,14 +626,14 @@ impl<'a> Builder<'a> {
625626 }
626627
627628 fn run ( self , builder : & Builder < ' _ > ) -> Interned < PathBuf > {
628- let target = crate :: hackit ( & self . target ) ;
629+ let target = self . target ;
629630
630631 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 )
633634 . join ( lib)
634- . join( "rustlib" ) )
635- . join ( target)
635+ . join ( "rustlib" )
636+ . join ( target. triple )
636637 . join ( "lib" ) ;
637638 let _ = fs:: remove_dir_all ( & sysroot) ;
638639 eprintln ! ( "{}" , sysroot. display( ) ) ;
@@ -656,7 +657,7 @@ impl<'a> Builder<'a> {
656657 Some ( relative_libdir) if compiler. stage >= 1 => {
657658 self . sysroot ( compiler) . join ( relative_libdir)
658659 }
659- _ => self . sysroot ( compiler) . join ( libdir ( & compiler. host ) ) ,
660+ _ => self . sysroot ( compiler) . join ( libdir ( compiler. host ) ) ,
660661 }
661662 }
662663 }
@@ -668,11 +669,11 @@ impl<'a> Builder<'a> {
668669 /// Windows.
669670 pub fn libdir_relative ( & self , compiler : Compiler ) -> & Path {
670671 if compiler. is_snapshot ( self ) {
671- libdir ( & self . config . build ) . as_ref ( )
672+ libdir ( self . config . build ) . as_ref ( )
672673 } else {
673674 match self . config . libdir_relative ( ) {
674675 Some ( relative_libdir) if compiler. stage >= 1 => relative_libdir,
675- _ => libdir ( & compiler. host ) . as_ref ( ) ,
676+ _ => libdir ( compiler. host ) . as_ref ( ) ,
676677 }
677678 }
678679 }
@@ -707,7 +708,7 @@ impl<'a> Builder<'a> {
707708 if compiler. is_snapshot ( self ) {
708709 self . initial_rustc . clone ( )
709710 } else {
710- self . sysroot ( compiler) . join ( "bin" ) . join ( exe ( "rustc" , & compiler. host ) )
711+ self . sysroot ( compiler) . join ( "bin" ) . join ( exe ( "rustc" , compiler. host ) )
711712 }
712713 }
713714
@@ -741,7 +742,7 @@ impl<'a> Builder<'a> {
741742 ///
742743 /// Note that this returns `None` if LLVM is disabled, or if we're in a
743744 /// 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 > {
745746 if self . config . llvm_enabled ( ) && self . kind != Kind :: Check && !self . config . dry_run {
746747 let llvm_config = self . ensure ( native:: Llvm { target } ) ;
747748 if llvm_config. is_file ( ) {
@@ -762,7 +763,7 @@ impl<'a> Builder<'a> {
762763 & self ,
763764 compiler : Compiler ,
764765 mode : Mode ,
765- target : Interned < String > ,
766+ target : TargetSelection ,
766767 cmd : & str ,
767768 ) -> Cargo {
768769 let mut cargo = Command :: new ( & self . initial_cargo ) ;
@@ -793,7 +794,7 @@ impl<'a> Builder<'a> {
793794 }
794795
795796 if cmd != "install" {
796- cargo. arg ( "--target" ) . arg ( target) ;
797+ cargo. arg ( "--target" ) . arg ( target. rustc_target_arg ( ) ) ;
797798 } else {
798799 assert_eq ! ( target, compiler. host) ;
799800 }
@@ -819,7 +820,7 @@ impl<'a> Builder<'a> {
819820 compiler. stage
820821 } ;
821822
822- let mut rustflags = Rustflags :: new ( & target) ;
823+ let mut rustflags = Rustflags :: new ( target) ;
823824 if stage != 0 {
824825 if let Ok ( s) = env:: var ( "CARGOFLAGS_NOT_BOOTSTRAP" ) {
825826 cargo. args ( s. split_whitespace ( ) ) ;
@@ -1000,7 +1001,7 @@ impl<'a> Builder<'a> {
10001001 // argument manually via `-C link-args=-Wl,-rpath,...`. Plus isn't it
10011002 // fun to pass a flag to a tool to pass a flag to pass a flag to a tool
10021003 // 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) {
10041005 let rpath = if target. contains ( "apple" ) {
10051006 // Note that we need to take one extra step on macOS to also pass
10061007 // `-Wl,-instal_name,@rpath/...` to get things to work right. To
@@ -1028,7 +1029,7 @@ impl<'a> Builder<'a> {
10281029 }
10291030
10301031 if let Some ( target_linker) = self . linker ( target, can_use_lld) {
1031- let target = crate :: envify ( & target) ;
1032+ let target = crate :: envify ( & target. triple ) ;
10321033 cargo. env ( & format ! ( "CARGO_TARGET_{}_LINKER" , target) , target_linker) ;
10331034 }
10341035 if !( [ "build" , "check" , "clippy" , "fix" , "rustc" ] . contains ( & cmd) ) && want_rustdoc {
@@ -1181,21 +1182,21 @@ impl<'a> Builder<'a> {
11811182 }
11821183 } ;
11831184 let cc = ccacheify ( & self . cc ( target) ) ;
1184- cargo. env ( format ! ( "CC_{}" , target) , & cc) ;
1185+ cargo. env ( format ! ( "CC_{}" , target. triple ) , & cc) ;
11851186
11861187 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 ( ) ) ;
11881189
11891190 if let Some ( ar) = self . ar ( target) {
11901191 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) ;
11921193 }
11931194
11941195 if let Ok ( cxx) = self . cxx ( target) {
11951196 let cxx = ccacheify ( & cxx) ;
11961197 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) ;
11991200 }
12001201 }
12011202
@@ -1229,7 +1230,7 @@ impl<'a> Builder<'a> {
12291230 // Environment variables *required* throughout the build
12301231 //
12311232 // 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 ) ;
12331234
12341235 // Set this for all builds to make sure doc builds also get it.
12351236 cargo. env ( "CFG_RELEASE_CHANNEL" , & self . config . channel ) ;
@@ -1385,15 +1386,15 @@ mod tests;
13851386struct Rustflags ( String ) ;
13861387
13871388impl Rustflags {
1388- fn new ( target : & str ) -> Rustflags {
1389+ fn new ( target : TargetSelection ) -> Rustflags {
13891390 let mut ret = Rustflags ( String :: new ( ) ) ;
13901391
13911392 // Inherit `RUSTFLAGS` by default ...
13921393 ret. env ( "RUSTFLAGS" ) ;
13931394
13941395 // ... and also handle target-specific env RUSTFLAGS if they're
13951396 // configured.
1396- let target_specific = format ! ( "CARGO_TARGET_{}_RUSTFLAGS" , crate :: envify( target) ) ;
1397+ let target_specific = format ! ( "CARGO_TARGET_{}_RUSTFLAGS" , crate :: envify( & target. triple ) ) ;
13971398 ret. env ( & target_specific) ;
13981399
13991400 ret
0 commit comments