@@ -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
@@ -725,7 +722,11 @@ impl<'a> Builder<'a> {
725
722
. env ( "CFG_RELEASE_CHANNEL" , & self . config . channel )
726
723
. env ( "RUSTDOC_REAL" , self . rustdoc ( compiler) )
727
724
. env ( "RUSTDOC_CRATE_VERSION" , self . rust_version ( ) )
728
- . env ( "RUSTC_BOOTSTRAP" , "1" ) ;
725
+ . env ( "RUSTC_BOOTSTRAP" , "1" )
726
+ . arg ( "-Winvalid_codeblock_attributes" ) ;
727
+ if self . config . deny_warnings {
728
+ cmd. arg ( "-Dwarnings" ) ;
729
+ }
729
730
730
731
// Remove make-related flags that can cause jobserver problems.
731
732
cmd. env_remove ( "MAKEFLAGS" ) ;
@@ -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 ( ) {
@@ -763,7 +764,7 @@ impl<'a> Builder<'a> {
763
764
compiler : Compiler ,
764
765
mode : Mode ,
765
766
source_type : SourceType ,
766
- target : Interned < String > ,
767
+ target : TargetSelection ,
767
768
cmd : & str ,
768
769
) -> Cargo {
769
770
let mut cargo = Command :: new ( & self . initial_cargo ) ;
@@ -773,7 +774,7 @@ impl<'a> Builder<'a> {
773
774
let my_out = match mode {
774
775
// This is the intended out directory for compiler documentation.
775
776
Mode :: Rustc | Mode :: ToolRustc | Mode :: Codegen => self . compiler_doc_out ( target) ,
776
- Mode :: Std => out_dir. join ( target) . join ( "doc" ) ,
777
+ Mode :: Std => out_dir. join ( target. triple ) . join ( "doc" ) ,
777
778
_ => panic ! ( "doc mode {:?} not expected" , mode) ,
778
779
} ;
779
780
let rustdoc = self . rustdoc ( compiler) ;
@@ -795,7 +796,7 @@ impl<'a> Builder<'a> {
795
796
}
796
797
797
798
if cmd != "install" {
798
- cargo. arg ( "--target" ) . arg ( target) ;
799
+ cargo. arg ( "--target" ) . arg ( target. rustc_target_arg ( ) ) ;
799
800
} else {
800
801
assert_eq ! ( target, compiler. host) ;
801
802
}
@@ -821,7 +822,7 @@ impl<'a> Builder<'a> {
821
822
compiler. stage
822
823
} ;
823
824
824
- let mut rustflags = Rustflags :: new ( & target) ;
825
+ let mut rustflags = Rustflags :: new ( target) ;
825
826
if stage != 0 {
826
827
if let Ok ( s) = env:: var ( "CARGOFLAGS_NOT_BOOTSTRAP" ) {
827
828
cargo. args ( s. split_whitespace ( ) ) ;
@@ -838,7 +839,7 @@ impl<'a> Builder<'a> {
838
839
// FIXME: It might be better to use the same value for both `RUSTFLAGS` and `RUSTDOCFLAGS`,
839
840
// but this breaks CI. At the very least, stage0 `rustdoc` needs `--cfg bootstrap`. See
840
841
// #71458.
841
- let rustdocflags = rustflags. clone ( ) ;
842
+ let mut rustdocflags = rustflags. clone ( ) ;
842
843
843
844
if let Ok ( s) = env:: var ( "CARGOFLAGS" ) {
844
845
cargo. args ( s. split_whitespace ( ) ) ;
@@ -994,7 +995,7 @@ impl<'a> Builder<'a> {
994
995
// argument manually via `-C link-args=-Wl,-rpath,...`. Plus isn't it
995
996
// fun to pass a flag to a tool to pass a flag to pass a flag to a tool
996
997
// to change a flag in a binary?
997
- if self . config . rust_rpath && util:: use_host_linker ( & target) {
998
+ if self . config . rust_rpath && util:: use_host_linker ( target) {
998
999
let rpath = if target. contains ( "apple" ) {
999
1000
// Note that we need to take one extra step on macOS to also pass
1000
1001
// `-Wl,-instal_name,@rpath/...` to get things to work right. To
@@ -1022,7 +1023,7 @@ impl<'a> Builder<'a> {
1022
1023
}
1023
1024
1024
1025
if let Some ( target_linker) = self . linker ( target, can_use_lld) {
1025
- let target = crate :: envify ( & target) ;
1026
+ let target = crate :: envify ( & target. triple ) ;
1026
1027
cargo. env ( & format ! ( "CARGO_TARGET_{}_LINKER" , target) , target_linker) ;
1027
1028
}
1028
1029
if !( [ "build" , "check" , "clippy" , "fix" , "rustc" ] . contains ( & cmd) ) && want_rustdoc {
@@ -1140,6 +1141,7 @@ impl<'a> Builder<'a> {
1140
1141
1141
1142
if self . config . deny_warnings {
1142
1143
lint_flags. push ( "-Dwarnings" ) ;
1144
+ rustdocflags. arg ( "-Dwarnings" ) ;
1143
1145
}
1144
1146
1145
1147
// FIXME(#58633) hide "unused attribute" errors in incremental
@@ -1157,6 +1159,8 @@ impl<'a> Builder<'a> {
1157
1159
// are always ignored in dependencies. Eventually this should be
1158
1160
// fixed via better support from Cargo.
1159
1161
cargo. env ( "RUSTC_LINT_FLAGS" , lint_flags. join ( " " ) ) ;
1162
+
1163
+ rustdocflags. arg ( "-Winvalid_codeblock_attributes" ) ;
1160
1164
}
1161
1165
1162
1166
if let Mode :: Rustc | Mode :: Codegen = mode {
@@ -1193,21 +1197,23 @@ impl<'a> Builder<'a> {
1193
1197
}
1194
1198
} ;
1195
1199
let cc = ccacheify ( & self . cc ( target) ) ;
1196
- cargo. env ( format ! ( "CC_{}" , target) , & cc) ;
1200
+ cargo. env ( format ! ( "CC_{}" , target. triple ) , & cc) ;
1197
1201
1198
1202
let cflags = self . cflags ( target, GitRepo :: Rustc ) . join ( " " ) ;
1199
- cargo. env ( format ! ( "CFLAGS_{}" , target) , cflags. clone ( ) ) ;
1203
+ cargo. env ( format ! ( "CFLAGS_{}" , target. triple ) , cflags. clone ( ) ) ;
1200
1204
1201
1205
if let Some ( ar) = self . ar ( target) {
1202
1206
let ranlib = format ! ( "{} s" , ar. display( ) ) ;
1203
- cargo. env ( format ! ( "AR_{}" , target) , ar) . env ( format ! ( "RANLIB_{}" , target) , ranlib) ;
1207
+ cargo
1208
+ . env ( format ! ( "AR_{}" , target. triple) , ar)
1209
+ . env ( format ! ( "RANLIB_{}" , target. triple) , ranlib) ;
1204
1210
}
1205
1211
1206
1212
if let Ok ( cxx) = self . cxx ( target) {
1207
1213
let cxx = ccacheify ( & cxx) ;
1208
1214
cargo
1209
- . env ( format ! ( "CXX_{}" , target) , & cxx)
1210
- . env ( format ! ( "CXXFLAGS_{}" , target) , cflags) ;
1215
+ . env ( format ! ( "CXX_{}" , target. triple ) , & cxx)
1216
+ . env ( format ! ( "CXXFLAGS_{}" , target. triple ) , cflags) ;
1211
1217
}
1212
1218
}
1213
1219
@@ -1241,7 +1247,7 @@ impl<'a> Builder<'a> {
1241
1247
// Environment variables *required* throughout the build
1242
1248
//
1243
1249
// FIXME: should update code to not require this env var
1244
- cargo. env ( "CFG_COMPILER_HOST_TRIPLE" , target) ;
1250
+ cargo. env ( "CFG_COMPILER_HOST_TRIPLE" , target. triple ) ;
1245
1251
1246
1252
// Set this for all builds to make sure doc builds also get it.
1247
1253
cargo. env ( "CFG_RELEASE_CHANNEL" , & self . config . channel ) ;
@@ -1397,15 +1403,15 @@ mod tests;
1397
1403
struct Rustflags ( String ) ;
1398
1404
1399
1405
impl Rustflags {
1400
- fn new ( target : & str ) -> Rustflags {
1406
+ fn new ( target : TargetSelection ) -> Rustflags {
1401
1407
let mut ret = Rustflags ( String :: new ( ) ) ;
1402
1408
1403
1409
// Inherit `RUSTFLAGS` by default ...
1404
1410
ret. env ( "RUSTFLAGS" ) ;
1405
1411
1406
1412
// ... and also handle target-specific env RUSTFLAGS if they're
1407
1413
// configured.
1408
- let target_specific = format ! ( "CARGO_TARGET_{}_RUSTFLAGS" , crate :: envify( target) ) ;
1414
+ let target_specific = format ! ( "CARGO_TARGET_{}_RUSTFLAGS" , crate :: envify( & target. triple ) ) ;
1409
1415
ret. env ( & target_specific) ;
1410
1416
1411
1417
ret
0 commit comments