mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-21 17:52:12 +03:00
Use std uplifting more often
This commit is contained in:
@@ -99,28 +99,12 @@ fn copy_extra_objects(
|
||||
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 @@ fn run(self, builder: &Builder<'_>) -> Self::Output {
|
||||
// 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 @@ fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
|
||||
|
||||
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 @@ fn make_run(run: RunConfig<'_>) {
|
||||
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 @@ pub fn compiler(&self, stage: u32, host: TargetSelection) -> Compiler {
|
||||
/// 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 @@ fn build_all() {
|
||||
[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 @@ fn dist_with_targets() {
|
||||
[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 @@ fn dist_with_empty_host() {
|
||||
[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>
|
||||
");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user