@@ -680,6 +680,14 @@ pub fn std_cargo(builder: &Builder<'_>, target: TargetSelection, cargo: &mut Car
680
680
cargo. rustdocflag ( "-Zcrate-attr=warn(rust_2018_idioms)" ) ;
681
681
}
682
682
683
+ /// Link all libstd rlibs/dylibs into a sysroot of `target_compiler`.
684
+ ///
685
+ /// Links those artifacts generated by `compiler` to the `stage` compiler's
686
+ /// sysroot for the specified `host` and `target`.
687
+ ///
688
+ /// Note that this assumes that `compiler` has already generated the libstd
689
+ /// libraries for `target`, and this method will find them in the relevant
690
+ /// output directory.
683
691
#[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
684
692
pub struct StdLink {
685
693
pub compiler : Compiler ,
@@ -710,14 +718,6 @@ impl Step for StdLink {
710
718
run. never ( )
711
719
}
712
720
713
- /// Link all libstd rlibs/dylibs into the sysroot location.
714
- ///
715
- /// Links those artifacts generated by `compiler` to the `stage` compiler's
716
- /// sysroot for the specified `host` and `target`.
717
- ///
718
- /// Note that this assumes that `compiler` has already generated the libstd
719
- /// libraries for `target`, and this method will find them in the relevant
720
- /// output directory.
721
721
#[ cfg_attr(
722
722
feature = "tracing" ,
723
723
instrument(
@@ -988,14 +988,8 @@ impl Rustc {
988
988
}
989
989
990
990
impl Step for Rustc {
991
- /// We return the stage of the "actual" compiler (not the uplifted one).
992
- ///
993
- /// By "actual" we refer to the uplifting logic where we may not compile the requested stage;
994
- /// instead, we uplift it from the previous stages. Which can lead to bootstrap failures in
995
- /// specific situations where we request stage X from other steps. However we may end up
996
- /// uplifting it from stage Y, causing the other stage to fail when attempting to link with
997
- /// stage X which was never actually built.
998
- type Output = u32 ;
991
+ type Output = ( ) ;
992
+
999
993
const ONLY_HOSTS : bool = true ;
1000
994
const DEFAULT : bool = false ;
1001
995
@@ -1043,7 +1037,7 @@ impl Step for Rustc {
1043
1037
fields( previous_compiler = ?self . build_compiler, target = ?self . target) ,
1044
1038
) ,
1045
1039
) ]
1046
- fn run ( self , builder : & Builder < ' _ > ) -> u32 {
1040
+ fn run ( self , builder : & Builder < ' _ > ) {
1047
1041
let build_compiler = self . build_compiler ;
1048
1042
let target = self . target ;
1049
1043
@@ -1059,7 +1053,7 @@ impl Step for Rustc {
1059
1053
& sysroot,
1060
1054
builder. config . ci_rustc_dev_contents ( ) ,
1061
1055
) ;
1062
- return build_compiler . stage ;
1056
+ return ;
1063
1057
}
1064
1058
1065
1059
// Build a standard library for `target` using the `build_compiler`.
@@ -1073,31 +1067,33 @@ impl Step for Rustc {
1073
1067
builder. info ( "WARNING: Use `--keep-stage-std` if you want to rebuild the compiler when it changes" ) ;
1074
1068
builder. ensure ( RustcLink :: from_rustc ( self , build_compiler) ) ;
1075
1069
1076
- return build_compiler . stage ;
1070
+ return ;
1077
1071
}
1078
1072
1079
- let compiler_to_use =
1080
- builder. compiler_for ( build_compiler. stage , build_compiler. host , target) ;
1081
- if compiler_to_use != build_compiler {
1082
- builder. ensure ( Rustc :: new ( compiler_to_use, target) ) ;
1083
- let msg = if compiler_to_use. host == target {
1084
- format ! (
1085
- "Uplifting rustc (stage{} -> stage{})" ,
1086
- compiler_to_use. stage,
1087
- build_compiler. stage + 1
1088
- )
1073
+ // The stage of the compiler that we're building
1074
+ let stage = build_compiler. stage + 1 ;
1075
+
1076
+ // If we are building a stage3+ compiler, and full bootstrap is disabled, and we have a
1077
+ // previous rustc available, we will uplift a compiler from a previous stage.
1078
+ if build_compiler. stage >= 2
1079
+ && !builder. config . full_bootstrap
1080
+ && ( target == builder. host_target || builder. hosts . contains ( & target) )
1081
+ {
1082
+ // If we're cross-compiling, the earliest rustc that we could have is stage 2.
1083
+ // If we're not cross-compiling, then we should have rustc stage 1.
1084
+ let stage_to_uplift = if target == builder. host_target { 1 } else { 2 } ;
1085
+ let rustc_to_uplift = builder. compiler ( stage_to_uplift, target) ;
1086
+ let msg = if rustc_to_uplift. host == target {
1087
+ format ! ( "Uplifting rustc (stage{} -> stage{stage})" , rustc_to_uplift. stage, )
1089
1088
} else {
1090
1089
format ! (
1091
- "Uplifting rustc (stage{}:{} -> stage{}:{})" ,
1092
- compiler_to_use. stage,
1093
- compiler_to_use. host,
1094
- build_compiler. stage + 1 ,
1095
- target
1090
+ "Uplifting rustc (stage{}:{} -> stage{stage}:{target})" ,
1091
+ rustc_to_uplift. stage, rustc_to_uplift. host,
1096
1092
)
1097
1093
} ;
1098
1094
builder. info ( & msg) ;
1099
- builder. ensure ( RustcLink :: from_rustc ( self , compiler_to_use ) ) ;
1100
- return compiler_to_use . stage ;
1095
+ builder. ensure ( RustcLink :: from_rustc ( self , rustc_to_uplift ) ) ;
1096
+ return ;
1101
1097
}
1102
1098
1103
1099
// Build a standard library for the current host target using the `build_compiler`.
@@ -1174,8 +1170,6 @@ impl Step for Rustc {
1174
1170
self ,
1175
1171
builder. compiler ( build_compiler. stage , builder. config . host_target ) ,
1176
1172
) ) ;
1177
-
1178
- build_compiler. stage
1179
1173
}
1180
1174
1181
1175
fn metadata ( & self ) -> Option < StepMetadata > {
@@ -1984,12 +1978,18 @@ impl Step for Sysroot {
1984
1978
}
1985
1979
}
1986
1980
1981
+ /// Prepare a compiler sysroot.
1982
+ ///
1983
+ /// The sysroot may contain various things useful for running the compiler, like linkers and
1984
+ /// linker wrappers (LLD, LLVM bitcode linker, etc.).
1985
+ ///
1986
+ /// This will assemble a compiler in `build/$target/stage$stage`.
1987
1987
#[ derive( Debug , PartialOrd , Ord , Clone , PartialEq , Eq , Hash ) ]
1988
1988
pub struct Assemble {
1989
1989
/// The compiler which we will produce in this step. Assemble itself will
1990
1990
/// take care of ensuring that the necessary prerequisites to do so exist,
1991
- /// that is, this target can be a stage2 compiler and Assemble will build
1992
- /// previous stages for you.
1991
+ /// that is, this can be e.g. a stage2 compiler and Assemble will build
1992
+ /// the previous stages for you.
1993
1993
pub target_compiler : Compiler ,
1994
1994
}
1995
1995
@@ -2007,11 +2007,6 @@ impl Step for Assemble {
2007
2007
} ) ;
2008
2008
}
2009
2009
2010
- /// Prepare a new compiler from the artifacts in `stage`
2011
- ///
2012
- /// This will assemble a compiler in `build/$host/stage$stage`. The compiler
2013
- /// must have been previously produced by the `stage - 1` builder.build
2014
- /// compiler.
2015
2010
#[ cfg_attr(
2016
2011
feature = "tracing" ,
2017
2012
instrument(
@@ -2149,7 +2144,7 @@ impl Step for Assemble {
2149
2144
target_compiler. stage - 1 ,
2150
2145
builder. config. host_target,
2151
2146
) ;
2152
- let mut build_compiler =
2147
+ let build_compiler =
2153
2148
builder. compiler ( target_compiler. stage - 1 , builder. config . host_target ) ;
2154
2149
2155
2150
// Build enzyme
@@ -2173,24 +2168,13 @@ impl Step for Assemble {
2173
2168
}
2174
2169
2175
2170
// Build the libraries for this compiler to link to (i.e., the libraries
2176
- // it uses at runtime). NOTE: Crates the target compiler compiles don't
2177
- // link to these. (FIXME: Is that correct? It seems to be correct most
2178
- // of the time but I think we do link to these for stage2/bin compilers
2179
- // when not performing a full bootstrap).
2171
+ // it uses at runtime).
2180
2172
debug ! (
2181
2173
?build_compiler,
2182
2174
"target_compiler.host" = ?target_compiler. host,
2183
2175
"building compiler libraries to link to"
2184
2176
) ;
2185
- let actual_stage = builder. ensure ( Rustc :: new ( build_compiler, target_compiler. host ) ) ;
2186
- // Current build_compiler.stage might be uplifted instead of being built; so update it
2187
- // to not fail while linking the artifacts.
2188
- debug ! (
2189
- "(old) build_compiler.stage" = build_compiler. stage,
2190
- "(adjusted) build_compiler.stage" = actual_stage,
2191
- "temporarily adjusting `build_compiler.stage` to account for uplifted libraries"
2192
- ) ;
2193
- build_compiler. stage = actual_stage;
2177
+ builder. ensure ( Rustc :: new ( build_compiler, target_compiler. host ) ) ;
2194
2178
2195
2179
let mut codegen_backend_stamps = vec ! [ ] ;
2196
2180
{
0 commit comments