Use std uplifting more often
This commit is contained in:
parent
41563c7d4a
commit
6864a5bf42
5 changed files with 20 additions and 40 deletions
|
|
@ -99,28 +99,12 @@ impl Std {
|
|||
deps
|
||||
}
|
||||
|
||||
/// Returns true if the standard library will be uplifted from stage 1 for the given
|
||||
/// `build_compiler` (which determines the stdlib stage) and `target`.
|
||||
/// Returns true if the standard library should be uplifted from stage 1.
|
||||
///
|
||||
/// Uplifting is enabled if we're building a stage2+ libstd, full bootstrap is
|
||||
/// disabled and we have a stage1 libstd already compiled for the given target.
|
||||
pub fn should_be_uplifted_from_stage_1(
|
||||
builder: &Builder<'_>,
|
||||
stage: u32,
|
||||
target: TargetSelection,
|
||||
) -> bool {
|
||||
stage > 1
|
||||
&& !builder.config.full_bootstrap
|
||||
// This estimates if a stage1 libstd exists for the given target. If we're not
|
||||
// cross-compiling, it should definitely exist by the time we're building a stage2
|
||||
// libstd.
|
||||
// Or if we are cross-compiling, and we are building a cross-compiled rustc, then that
|
||||
// rustc needs to link to a cross-compiled libstd, so again we should have a stage1
|
||||
// libstd for the given target prepared.
|
||||
// Even if we guess wrong in the cross-compiled case, the worst that should happen is
|
||||
// that we build a fresh stage1 libstd below, and then we immediately uplift it, so we
|
||||
// don't pay the libstd build cost twice.
|
||||
&& (target == builder.host_target || builder.config.hosts.contains(&target))
|
||||
/// Uplifting is enabled if we're building a stage2+ libstd and full bootstrap is
|
||||
/// disabled.
|
||||
pub fn should_be_uplifted_from_stage_1(builder: &Builder<'_>, stage: u32) -> bool {
|
||||
stage > 1 && !builder.config.full_bootstrap
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -228,7 +212,7 @@ impl Step for Std {
|
|||
// Stage of the stdlib that we're building
|
||||
let stage = build_compiler.stage;
|
||||
|
||||
if Self::should_be_uplifted_from_stage_1(builder, build_compiler.stage, target) {
|
||||
if Self::should_be_uplifted_from_stage_1(builder, build_compiler.stage) {
|
||||
let build_compiler_for_std_to_uplift = builder.compiler(1, builder.host_target);
|
||||
let stage_1_stamp = builder.std(build_compiler_for_std_to_uplift, target);
|
||||
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ impl Step for JsonDocs {
|
|||
|
||||
fn make_run(run: RunConfig<'_>) {
|
||||
run.builder.ensure(JsonDocs {
|
||||
build_compiler: run.builder.compiler_for_std(run.builder.top_stage, run.target),
|
||||
build_compiler: run.builder.compiler_for_std(run.builder.top_stage),
|
||||
target: run.target,
|
||||
});
|
||||
}
|
||||
|
|
@ -769,7 +769,7 @@ pub struct Std {
|
|||
|
||||
impl Std {
|
||||
pub fn new(builder: &Builder<'_>, target: TargetSelection) -> Self {
|
||||
Std { build_compiler: builder.compiler_for_std(builder.top_stage, target), target }
|
||||
Std { build_compiler: builder.compiler_for_std(builder.top_stage), target }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -616,9 +616,7 @@ impl Step for Std {
|
|||
return;
|
||||
}
|
||||
run.builder.ensure(Std {
|
||||
build_compiler: run
|
||||
.builder
|
||||
.compiler_for_std(run.builder.top_stage, run.builder.host_target),
|
||||
build_compiler: run.builder.compiler_for_std(run.builder.top_stage),
|
||||
target: run.target,
|
||||
format: if run.builder.config.cmd.json() {
|
||||
DocumentationFormat::Json
|
||||
|
|
|
|||
|
|
@ -1373,10 +1373,11 @@ impl<'a> Builder<'a> {
|
|||
/// we need:
|
||||
/// - stage 2 libstd for target2 (uplifted from stage 1, where it was built by target1 rustc)
|
||||
/// - stage 2 rustc for target2
|
||||
///
|
||||
/// However, without this optimization, we would also build stage 2 rustc for **target1**,
|
||||
/// which is completely wasteful.
|
||||
pub fn compiler_for_std(&self, stage: u32, target: TargetSelection) -> Compiler {
|
||||
if compile::Std::should_be_uplifted_from_stage_1(self, stage, target) {
|
||||
pub fn compiler_for_std(&self, stage: u32) -> Compiler {
|
||||
if compile::Std::should_be_uplifted_from_stage_1(self, stage) {
|
||||
self.compiler(1, self.host_target)
|
||||
} else {
|
||||
self.compiler(stage, self.host_target)
|
||||
|
|
|
|||
|
|
@ -1066,6 +1066,7 @@ mod snapshot {
|
|||
[build] rustc 1 <host> -> rustc 2 <target1>
|
||||
[build] rustc 2 <host> -> std 2 <host>
|
||||
[build] rustc 2 <host> -> std 2 <target1>
|
||||
[build] rustc 1 <host> -> std 1 <target2>
|
||||
[build] rustc 2 <host> -> std 2 <target2>
|
||||
");
|
||||
}
|
||||
|
|
@ -1295,16 +1296,15 @@ mod snapshot {
|
|||
[dist] docs <target1>
|
||||
[doc] rustc 1 <host> -> std 1 <host> crates=[]
|
||||
[dist] rustc 1 <host> -> json-docs 2 <host>
|
||||
[build] rustdoc 2 <host>
|
||||
[doc] rustc 2 <host> -> std 2 <target1> crates=[]
|
||||
[dist] rustc 2 <host> -> json-docs 3 <target1>
|
||||
[doc] rustc 1 <host> -> std 1 <target1> crates=[]
|
||||
[dist] rustc 1 <host> -> json-docs 2 <target1>
|
||||
[dist] mingw <host>
|
||||
[dist] mingw <target1>
|
||||
[build] rustdoc 2 <host>
|
||||
[build] rustc 0 <host> -> GenerateCopyright 1 <host>
|
||||
[dist] rustc <host>
|
||||
[dist] rustc 1 <host> -> std 1 <host>
|
||||
[build] rustc 2 <host> -> std 2 <target1>
|
||||
[dist] rustc 2 <host> -> std 2 <target1>
|
||||
[dist] rustc 1 <host> -> std 1 <target1>
|
||||
[dist] rustc 1 <host> -> rustc-dev 2 <host>
|
||||
[dist] src <>
|
||||
[dist] reproducible-artifacts <host>
|
||||
|
|
@ -1495,13 +1495,10 @@ mod snapshot {
|
|||
[doc] rustc 1 <host> -> releases 2 <target1>
|
||||
[build] rustc 0 <host> -> RustInstaller 1 <host>
|
||||
[dist] docs <target1>
|
||||
[build] rustc 1 <host> -> rustc 2 <host>
|
||||
[build] rustdoc 2 <host>
|
||||
[doc] rustc 2 <host> -> std 2 <target1> crates=[]
|
||||
[dist] rustc 2 <host> -> json-docs 3 <target1>
|
||||
[doc] rustc 1 <host> -> std 1 <target1> crates=[]
|
||||
[dist] rustc 1 <host> -> json-docs 2 <target1>
|
||||
[dist] mingw <target1>
|
||||
[build] rustc 2 <host> -> std 2 <target1>
|
||||
[dist] rustc 2 <host> -> std 2 <target1>
|
||||
[dist] rustc 1 <host> -> std 1 <target1>
|
||||
");
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue