Skip to content

complicated build stages #119946

Open
Open
@onur-ozkan

Description

@onur-ozkan

Current approach on bootstrap stages adds too much complexity on the bootstrap codebase; the complexity continues to grow with the additional changes made on bootstrap and it's not even functioning correctly (like writing incorrect stages to stdout on certain commands).

One possible solution could be to handle stage behaviours as part of the Step trait individually on Step implementation.

Some references to why current implementation of step calculations is making things so difficult/complicated:

impl Step for Rustc {
// We return the stage of the "actual" compiler (not the uplifted one).
//
// By "actual" we refer to the uplifting logic where we may not compile the requested stage;
// instead, we uplift it from the previous stages. Which can lead to bootstrap failures in
// specific situations where we request stage X from other steps. However we may end up
// uplifting it from stage Y, causing the other stage to fail when attempting to link with
// stage X which was never actually built.
type Output = u32;

let compiler_to_use = builder.compiler_for(compiler.stage, compiler.host, target);
if compiler_to_use != compiler {
builder.ensure(Rustc::new(compiler_to_use, target));
let msg = if compiler_to_use.host == target {
format!(
"Uplifting rustc (stage{} -> stage{})",
compiler_to_use.stage,
compiler.stage + 1
)
} else {
format!(
"Uplifting rustc (stage{}:{} -> stage{}:{})",
compiler_to_use.stage,
compiler_to_use.host,
compiler.stage + 1,
target
)
};
builder.info(&msg);
builder.ensure(RustcLink::from_rustc(self, compiler_to_use));
return compiler_to_use.stage;
}

Particularly, the behaviors of the force_use_stage function are not really useful for all use cases (for instance, see #118233 and #118918)

rust/src/bootstrap/src/lib.rs

Lines 1403 to 1417 in ef32456

fn force_use_stage1(&self, stage: u32, target: TargetSelection) -> bool {
!self.config.full_bootstrap
&& !self.config.download_rustc()
&& stage >= 2
&& (self.hosts.iter().any(|h| *h == target) || target == self.build)
}
/// Checks whether the `compiler` compiling for `target` should be forced to
/// use a stage2 compiler instead.
///
/// When we download the pre-compiled version of rustc and compiler stage is >= 2,
/// it should be forced to use a stage2 compiler.
fn force_use_stage2(&self, stage: u32) -> bool {
self.config.download_rustc() && stage >= 2
}

@rustbot label +T-bootstrap

Metadata

Metadata

Assignees

No one assigned

    Labels

    T-bootstrapRelevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions