@@ -661,6 +661,14 @@ pub fn std_cargo(builder: &Builder<'_>, target: TargetSelection, cargo: &mut Car
661
661
cargo. rustdocflag ( "-Zcrate-attr=warn(rust_2018_idioms)" ) ;
662
662
}
663
663
664
+ /// Link all libstd rlibs/dylibs into a sysroot of `target_compiler`.
665
+ ///
666
+ /// Links those artifacts generated by `compiler` to the `stage` compiler's
667
+ /// sysroot for the specified `host` and `target`.
668
+ ///
669
+ /// Note that this assumes that `compiler` has already generated the libstd
670
+ /// libraries for `target`, and this method will find them in the relevant
671
+ /// output directory.
664
672
#[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
665
673
pub struct StdLink {
666
674
pub compiler : Compiler ,
@@ -691,14 +699,6 @@ impl Step for StdLink {
691
699
run. never ( )
692
700
}
693
701
694
- /// Link all libstd rlibs/dylibs into the sysroot location.
695
- ///
696
- /// Links those artifacts generated by `compiler` to the `stage` compiler's
697
- /// sysroot for the specified `host` and `target`.
698
- ///
699
- /// Note that this assumes that `compiler` has already generated the libstd
700
- /// libraries for `target`, and this method will find them in the relevant
701
- /// output directory.
702
702
#[ cfg_attr(
703
703
feature = "tracing" ,
704
704
instrument(
@@ -969,14 +969,8 @@ impl Rustc {
969
969
}
970
970
971
971
impl Step for Rustc {
972
- /// We return the stage of the "actual" compiler (not the uplifted one).
973
- ///
974
- /// By "actual" we refer to the uplifting logic where we may not compile the requested stage;
975
- /// instead, we uplift it from the previous stages. Which can lead to bootstrap failures in
976
- /// specific situations where we request stage X from other steps. However we may end up
977
- /// uplifting it from stage Y, causing the other stage to fail when attempting to link with
978
- /// stage X which was never actually built.
979
- type Output = u32 ;
972
+ type Output = ( ) ;
973
+
980
974
const ONLY_HOSTS : bool = true ;
981
975
const DEFAULT : bool = false ;
982
976
@@ -1024,7 +1018,7 @@ impl Step for Rustc {
1024
1018
fields( previous_compiler = ?self . build_compiler, target = ?self . target) ,
1025
1019
) ,
1026
1020
) ]
1027
- fn run ( self , builder : & Builder < ' _ > ) -> u32 {
1021
+ fn run ( self , builder : & Builder < ' _ > ) {
1028
1022
let build_compiler = self . build_compiler ;
1029
1023
let target = self . target ;
1030
1024
@@ -1040,7 +1034,7 @@ impl Step for Rustc {
1040
1034
& sysroot,
1041
1035
builder. config . ci_rustc_dev_contents ( ) ,
1042
1036
) ;
1043
- return build_compiler . stage ;
1037
+ return ;
1044
1038
}
1045
1039
1046
1040
// Build a standard library for `target` using the `build_compiler`.
@@ -1054,31 +1048,23 @@ impl Step for Rustc {
1054
1048
builder. info ( "WARNING: Use `--keep-stage-std` if you want to rebuild the compiler when it changes" ) ;
1055
1049
builder. ensure ( RustcLink :: from_rustc ( self , build_compiler) ) ;
1056
1050
1057
- return build_compiler . stage ;
1051
+ return ;
1058
1052
}
1059
1053
1060
- let compiler_to_use =
1061
- builder. compiler_for ( build_compiler. stage , build_compiler. host , target) ;
1062
- if compiler_to_use != build_compiler {
1063
- builder. ensure ( Rustc :: new ( compiler_to_use, target) ) ;
1064
- let msg = if compiler_to_use. host == target {
1065
- format ! (
1066
- "Uplifting rustc (stage{} -> stage{})" ,
1067
- compiler_to_use. stage,
1068
- build_compiler. stage + 1
1069
- )
1070
- } else {
1071
- format ! (
1072
- "Uplifting rustc (stage{}:{} -> stage{}:{})" ,
1073
- compiler_to_use. stage,
1074
- compiler_to_use. host,
1075
- build_compiler. stage + 1 ,
1076
- target
1077
- )
1078
- } ;
1079
- builder. info ( & msg) ;
1080
- builder. ensure ( RustcLink :: from_rustc ( self , compiler_to_use) ) ;
1081
- return compiler_to_use. stage ;
1054
+ // The stage of the compiler that we're building
1055
+ let stage = build_compiler. stage + 1 ;
1056
+
1057
+ // If we are building a stage3+ compiler, and full bootstrap is disabled, and we're not
1058
+ // cross-compiling, we will uplift a compiler from stage1.
1059
+ if build_compiler. stage >= 2
1060
+ && !builder. config . full_bootstrap
1061
+ && target == builder. host_target
1062
+ {
1063
+ let rustc_to_uplift = builder. compiler ( 1 , target) ;
1064
+ builder
1065
+ . info ( & format ! ( "Uplifting rustc (stage{} -> stage{stage})" , rustc_to_uplift. stage) ) ;
1066
+ builder. ensure ( RustcLink :: from_rustc ( self , rustc_to_uplift) ) ;
1067
+ return ;
1082
1068
}
1083
1069
1084
1070
// Build a standard library for the current host target using the `build_compiler`.
@@ -1155,8 +1141,6 @@ impl Step for Rustc {
1155
1141
self ,
1156
1142
builder. compiler ( build_compiler. stage , builder. config . host_target ) ,
1157
1143
) ) ;
1158
-
1159
- build_compiler. stage
1160
1144
}
1161
1145
1162
1146
fn metadata ( & self ) -> Option < StepMetadata > {
@@ -1970,12 +1954,18 @@ impl Step for Sysroot {
1970
1954
}
1971
1955
}
1972
1956
1957
+ /// Prepare a compiler sysroot.
1958
+ ///
1959
+ /// The sysroot may contain various things useful for running the compiler, like linkers and
1960
+ /// linker wrappers (LLD, LLVM bitcode linker, etc.).
1961
+ ///
1962
+ /// This will assemble a compiler in `build/$target/stage$stage`.
1973
1963
#[ derive( Debug , PartialOrd , Ord , Clone , PartialEq , Eq , Hash ) ]
1974
1964
pub struct Assemble {
1975
1965
/// The compiler which we will produce in this step. Assemble itself will
1976
1966
/// take care of ensuring that the necessary prerequisites to do so exist,
1977
- /// that is, this target can be a stage2 compiler and Assemble will build
1978
- /// previous stages for you.
1967
+ /// that is, this can be e.g. a stage2 compiler and Assemble will build
1968
+ /// the previous stages for you.
1979
1969
pub target_compiler : Compiler ,
1980
1970
}
1981
1971
@@ -1993,11 +1983,6 @@ impl Step for Assemble {
1993
1983
} ) ;
1994
1984
}
1995
1985
1996
- /// Prepare a new compiler from the artifacts in `stage`
1997
- ///
1998
- /// This will assemble a compiler in `build/$host/stage$stage`. The compiler
1999
- /// must have been previously produced by the `stage - 1` builder.build
2000
- /// compiler.
2001
1986
#[ cfg_attr(
2002
1987
feature = "tracing" ,
2003
1988
instrument(
@@ -2135,7 +2120,7 @@ impl Step for Assemble {
2135
2120
target_compiler. stage - 1 ,
2136
2121
builder. config. host_target,
2137
2122
) ;
2138
- let mut build_compiler =
2123
+ let build_compiler =
2139
2124
builder. compiler ( target_compiler. stage - 1 , builder. config . host_target ) ;
2140
2125
2141
2126
// Build enzyme
@@ -2159,24 +2144,13 @@ impl Step for Assemble {
2159
2144
}
2160
2145
2161
2146
// Build the libraries for this compiler to link to (i.e., the libraries
2162
- // it uses at runtime). NOTE: Crates the target compiler compiles don't
2163
- // link to these. (FIXME: Is that correct? It seems to be correct most
2164
- // of the time but I think we do link to these for stage2/bin compilers
2165
- // when not performing a full bootstrap).
2147
+ // it uses at runtime).
2166
2148
debug ! (
2167
2149
?build_compiler,
2168
2150
"target_compiler.host" = ?target_compiler. host,
2169
2151
"building compiler libraries to link to"
2170
2152
) ;
2171
- let actual_stage = builder. ensure ( Rustc :: new ( build_compiler, target_compiler. host ) ) ;
2172
- // Current build_compiler.stage might be uplifted instead of being built; so update it
2173
- // to not fail while linking the artifacts.
2174
- debug ! (
2175
- "(old) build_compiler.stage" = build_compiler. stage,
2176
- "(adjusted) build_compiler.stage" = actual_stage,
2177
- "temporarily adjusting `build_compiler.stage` to account for uplifted libraries"
2178
- ) ;
2179
- build_compiler. stage = actual_stage;
2153
+ builder. ensure ( Rustc :: new ( build_compiler, target_compiler. host ) ) ;
2180
2154
2181
2155
let mut codegen_backend_stamps = vec ! [ ] ;
2182
2156
{
0 commit comments