@@ -16,6 +16,7 @@ use build_helper::{output, t};
16
16
use crate :: cache:: { Cache , Interned , INTERNER } ;
17
17
use crate :: check;
18
18
use crate :: compile;
19
+ use crate :: config:: TargetSelection ;
19
20
use crate :: dist;
20
21
use crate :: doc;
21
22
use crate :: flags:: Subcommand ;
@@ -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
@@ -576,7 +577,7 @@ impl<'a> Builder<'a> {
576
577
/// not take `Compiler` since all `Compiler` instances are meant to be
577
578
/// obtained through this function, since it ensures that they are valid
578
579
/// (i.e., built and assembled).
579
- pub fn compiler ( & self , stage : u32 , host : Interned < String > ) -> Compiler {
580
+ pub fn compiler ( & self , stage : u32 , host : TargetSelection ) -> Compiler {
580
581
self . ensure ( compile:: Assemble { target_compiler : Compiler { stage, host } } )
581
582
}
582
583
@@ -594,8 +595,8 @@ impl<'a> Builder<'a> {
594
595
pub fn compiler_for (
595
596
& self ,
596
597
stage : u32 ,
597
- host : Interned < String > ,
598
- target : Interned < String > ,
598
+ host : TargetSelection ,
599
+ target : TargetSelection ,
599
600
) -> Compiler {
600
601
if self . build . force_use_stage1 ( Compiler { stage, host } , target) {
601
602
self . compiler ( 1 , self . config . build )
@@ -610,15 +611,11 @@ impl<'a> Builder<'a> {
610
611
611
612
/// Returns the libdir where the standard library and other artifacts are
612
613
/// found for a compiler's sysroot.
613
- pub fn sysroot_libdir (
614
- & self ,
615
- compiler : Compiler ,
616
- target : Interned < String > ,
617
- ) -> Interned < PathBuf > {
614
+ pub fn sysroot_libdir ( & self , compiler : Compiler , target : TargetSelection ) -> Interned < PathBuf > {
618
615
#[ derive( Debug , Copy , Clone , Hash , PartialEq , Eq ) ]
619
616
struct Libdir {
620
617
compiler : Compiler ,
621
- target : Interned < String > ,
618
+ target : TargetSelection ,
622
619
}
623
620
impl Step for Libdir {
624
621
type Output = Interned < PathBuf > ;
@@ -633,7 +630,7 @@ impl<'a> Builder<'a> {
633
630
. sysroot ( self . compiler )
634
631
. join ( lib)
635
632
. join ( "rustlib" )
636
- . join ( self . target )
633
+ . join ( self . target . triple )
637
634
. join ( "lib" ) ;
638
635
let _ = fs:: remove_dir_all ( & sysroot) ;
639
636
t ! ( fs:: create_dir_all( & sysroot) ) ;
@@ -656,7 +653,7 @@ impl<'a> Builder<'a> {
656
653
Some ( relative_libdir) if compiler. stage >= 1 => {
657
654
self . sysroot ( compiler) . join ( relative_libdir)
658
655
}
659
- _ => self . sysroot ( compiler) . join ( libdir ( & compiler. host ) ) ,
656
+ _ => self . sysroot ( compiler) . join ( libdir ( compiler. host ) ) ,
660
657
}
661
658
}
662
659
}
@@ -668,11 +665,11 @@ impl<'a> Builder<'a> {
668
665
/// Windows.
669
666
pub fn libdir_relative ( & self , compiler : Compiler ) -> & Path {
670
667
if compiler. is_snapshot ( self ) {
671
- libdir ( & self . config . build ) . as_ref ( )
668
+ libdir ( self . config . build ) . as_ref ( )
672
669
} else {
673
670
match self . config . libdir_relative ( ) {
674
671
Some ( relative_libdir) if compiler. stage >= 1 => relative_libdir,
675
- _ => libdir ( & compiler. host ) . as_ref ( ) ,
672
+ _ => libdir ( compiler. host ) . as_ref ( ) ,
676
673
}
677
674
}
678
675
}
@@ -707,7 +704,7 @@ impl<'a> Builder<'a> {
707
704
if compiler. is_snapshot ( self ) {
708
705
self . initial_rustc . clone ( )
709
706
} else {
710
- self . sysroot ( compiler) . join ( "bin" ) . join ( exe ( "rustc" , & compiler. host ) )
707
+ self . sysroot ( compiler) . join ( "bin" ) . join ( exe ( "rustc" , compiler. host ) )
711
708
}
712
709
}
713
710
@@ -741,7 +738,7 @@ impl<'a> Builder<'a> {
741
738
///
742
739
/// Note that this returns `None` if LLVM is disabled, or if we're in a
743
740
/// 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 > {
741
+ fn llvm_config ( & self , target : TargetSelection ) -> Option < PathBuf > {
745
742
if self . config . llvm_enabled ( ) && self . kind != Kind :: Check && !self . config . dry_run {
746
743
let llvm_config = self . ensure ( native:: Llvm { target } ) ;
747
744
if llvm_config. is_file ( ) {
@@ -763,7 +760,7 @@ impl<'a> Builder<'a> {
763
760
compiler : Compiler ,
764
761
mode : Mode ,
765
762
source_type : SourceType ,
766
- target : Interned < String > ,
763
+ target : TargetSelection ,
767
764
cmd : & str ,
768
765
) -> Cargo {
769
766
let mut cargo = Command :: new ( & self . initial_cargo ) ;
@@ -794,7 +791,7 @@ impl<'a> Builder<'a> {
794
791
}
795
792
796
793
if cmd != "install" {
797
- cargo. arg ( "--target" ) . arg ( target) ;
794
+ cargo. arg ( "--target" ) . arg ( target. rustc_target_arg ( ) ) ;
798
795
} else {
799
796
assert_eq ! ( target, compiler. host) ;
800
797
}
@@ -820,7 +817,7 @@ impl<'a> Builder<'a> {
820
817
compiler. stage
821
818
} ;
822
819
823
- let mut rustflags = Rustflags :: new ( & target) ;
820
+ let mut rustflags = Rustflags :: new ( target) ;
824
821
if stage != 0 {
825
822
if let Ok ( s) = env:: var ( "CARGOFLAGS_NOT_BOOTSTRAP" ) {
826
823
cargo. args ( s. split_whitespace ( ) ) ;
@@ -993,7 +990,7 @@ impl<'a> Builder<'a> {
993
990
// argument manually via `-C link-args=-Wl,-rpath,...`. Plus isn't it
994
991
// fun to pass a flag to a tool to pass a flag to pass a flag to a tool
995
992
// to change a flag in a binary?
996
- if self . config . rust_rpath && util:: use_host_linker ( & target) {
993
+ if self . config . rust_rpath && util:: use_host_linker ( target) {
997
994
let rpath = if target. contains ( "apple" ) {
998
995
// Note that we need to take one extra step on macOS to also pass
999
996
// `-Wl,-instal_name,@rpath/...` to get things to work right. To
@@ -1021,7 +1018,7 @@ impl<'a> Builder<'a> {
1021
1018
}
1022
1019
1023
1020
if let Some ( target_linker) = self . linker ( target, can_use_lld) {
1024
- let target = crate :: envify ( & target) ;
1021
+ let target = crate :: envify ( & target. triple ) ;
1025
1022
cargo. env ( & format ! ( "CARGO_TARGET_{}_LINKER" , target) , target_linker) ;
1026
1023
}
1027
1024
if !( [ "build" , "check" , "clippy" , "fix" , "rustc" ] . contains ( & cmd) ) && want_rustdoc {
@@ -1192,21 +1189,23 @@ impl<'a> Builder<'a> {
1192
1189
}
1193
1190
} ;
1194
1191
let cc = ccacheify ( & self . cc ( target) ) ;
1195
- cargo. env ( format ! ( "CC_{}" , target) , & cc) ;
1192
+ cargo. env ( format ! ( "CC_{}" , target. triple ) , & cc) ;
1196
1193
1197
1194
let cflags = self . cflags ( target, GitRepo :: Rustc ) . join ( " " ) ;
1198
- cargo. env ( format ! ( "CFLAGS_{}" , target) , cflags. clone ( ) ) ;
1195
+ cargo. env ( format ! ( "CFLAGS_{}" , target. triple ) , cflags. clone ( ) ) ;
1199
1196
1200
1197
if let Some ( ar) = self . ar ( target) {
1201
1198
let ranlib = format ! ( "{} s" , ar. display( ) ) ;
1202
- cargo. env ( format ! ( "AR_{}" , target) , ar) . env ( format ! ( "RANLIB_{}" , target) , ranlib) ;
1199
+ cargo
1200
+ . env ( format ! ( "AR_{}" , target. triple) , ar)
1201
+ . env ( format ! ( "RANLIB_{}" , target. triple) , ranlib) ;
1203
1202
}
1204
1203
1205
1204
if let Ok ( cxx) = self . cxx ( target) {
1206
1205
let cxx = ccacheify ( & cxx) ;
1207
1206
cargo
1208
- . env ( format ! ( "CXX_{}" , target) , & cxx)
1209
- . env ( format ! ( "CXXFLAGS_{}" , target) , cflags) ;
1207
+ . env ( format ! ( "CXX_{}" , target. triple ) , & cxx)
1208
+ . env ( format ! ( "CXXFLAGS_{}" , target. triple ) , cflags) ;
1210
1209
}
1211
1210
}
1212
1211
@@ -1240,7 +1239,7 @@ impl<'a> Builder<'a> {
1240
1239
// Environment variables *required* throughout the build
1241
1240
//
1242
1241
// FIXME: should update code to not require this env var
1243
- cargo. env ( "CFG_COMPILER_HOST_TRIPLE" , target) ;
1242
+ cargo. env ( "CFG_COMPILER_HOST_TRIPLE" , target. triple ) ;
1244
1243
1245
1244
// Set this for all builds to make sure doc builds also get it.
1246
1245
cargo. env ( "CFG_RELEASE_CHANNEL" , & self . config . channel ) ;
@@ -1396,15 +1395,15 @@ mod tests;
1396
1395
struct Rustflags ( String ) ;
1397
1396
1398
1397
impl Rustflags {
1399
- fn new ( target : & str ) -> Rustflags {
1398
+ fn new ( target : TargetSelection ) -> Rustflags {
1400
1399
let mut ret = Rustflags ( String :: new ( ) ) ;
1401
1400
1402
1401
// Inherit `RUSTFLAGS` by default ...
1403
1402
ret. env ( "RUSTFLAGS" ) ;
1404
1403
1405
1404
// ... and also handle target-specific env RUSTFLAGS if they're
1406
1405
// configured.
1407
- let target_specific = format ! ( "CARGO_TARGET_{}_RUSTFLAGS" , crate :: envify( target) ) ;
1406
+ let target_specific = format ! ( "CARGO_TARGET_{}_RUSTFLAGS" , crate :: envify( & target. triple ) ) ;
1408
1407
ret. env ( & target_specific) ;
1409
1408
1410
1409
ret
0 commit comments