Skip to content

Commit

Permalink
keep Rustc private and use Assemble instead
Browse files Browse the repository at this point in the history
Signed-off-by: onur-ozkan <[email protected]>
  • Loading branch information
onur-ozkan committed Feb 3, 2025
1 parent 9896694 commit 28d8ac0
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 12 deletions.
16 changes: 11 additions & 5 deletions src/bootstrap/src/core/build_steps/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -839,9 +839,9 @@ fn cp_rustc_component_to_ci_sysroot(builder: &Builder<'_>, sysroot: &Path, conte

#[derive(Debug, PartialOrd, Ord, Clone, PartialEq, Eq, Hash)]
pub struct Rustc {
pub target: TargetSelection,
target: TargetSelection,
/// The **previous** compiler used to compile this compiler.
pub compiler: Compiler,
compiler: Compiler,
/// Whether to build a subset of crates, rather than the whole compiler.
///
/// This should only be requested by the user, not used within bootstrap itself.
Expand All @@ -851,6 +851,7 @@ pub struct Rustc {
}

impl Rustc {
#[cfg(test)]
pub fn new(compiler: Compiler, target: TargetSelection) -> Self {
Self { target, compiler, crates: Default::default() }
}
Expand Down Expand Up @@ -923,7 +924,8 @@ impl Step for Rustc {

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 _ = builder.compiler(compiler_to_use.stage, target);

let msg = if compiler_to_use.host == target {
format!(
"Uplifting rustc (stage{} -> stage{})",
Expand Down Expand Up @@ -1424,7 +1426,7 @@ impl Step for CodegenBackend {
let target = self.target;
let backend = self.backend;

builder.ensure(Rustc::new(compiler, target));
let _ = builder.compiler(compiler.stage, target);

if builder.config.keep_stage.contains(&compiler.stage) {
builder.info(
Expand Down Expand Up @@ -1861,7 +1863,11 @@ impl Step for Assemble {
// link to these. (FIXME: Is that correct? It seems to be correct most
// of the time but I think we do link to these for stage2/bin compilers
// when not performing a full bootstrap).
let actual_stage = builder.ensure(Rustc::new(build_compiler, target_compiler.host));
let actual_stage = builder.ensure(Rustc {
compiler: build_compiler,
target: target_compiler.host,
crates: vec![],
});
// Current build_compiler.stage might be uplifted instead of being built; so update it
// to not fail while linking the artifacts.
build_compiler.stage = actual_stage;
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/src/core/build_steps/dist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,7 @@ impl Step for RustcDev {
return None;
}

builder.ensure(compile::Rustc::new(compiler, target));
let _ = builder.compiler(compiler.stage, target);

let tarball = Tarball::new(builder, "rustc-dev", &target.triple);

Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/src/core/build_steps/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -953,7 +953,7 @@ macro_rules! tool_doc {
// Rustdoc needs the rustc sysroot available to build.
// FIXME: is there a way to only ensure `check::Rustc` here? Last time I tried it failed
// with strange errors, but only on a full bors test ...
builder.ensure(compile::Rustc::new(compiler, target));
let _ = builder.compiler(compiler.stage, target);
}

// Build cargo command.
Expand Down
9 changes: 4 additions & 5 deletions src/bootstrap/src/core/build_steps/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,6 @@ impl Step for Cargotest {
/// test` to ensure that we don't regress the test suites there.
fn run(self, builder: &Builder<'_>) {
let compiler = builder.compiler(self.stage, self.host);
builder.ensure(compile::Rustc::new(compiler, compiler.host));
let cargo = builder.ensure(tool::Cargo { compiler, target: compiler.host });

// Note that this is a short, cryptic, and not scoped directory name. This
Expand Down Expand Up @@ -369,7 +368,7 @@ impl Step for RustAnalyzer {

// We don't need to build the whole Rust Analyzer for the proc-macro-srv test suite,
// but we do need the standard library to be present.
builder.ensure(compile::Rustc::new(compiler, host));
let _ = builder.compiler(compiler.stage, host);

let workspace_path = "src/tools/rust-analyzer";
// until the whole RA test suite runs on `i686`, we only run
Expand Down Expand Up @@ -1662,7 +1661,7 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the
};

if suite.ends_with("fulldeps") {
builder.ensure(compile::Rustc::new(compiler, target));
let _ = builder.compiler(compiler.stage, target);
}

if suite == "debuginfo" {
Expand Down Expand Up @@ -2813,7 +2812,7 @@ impl Step for CrateRustdoc {
// the target rustdoc (`ci-rustc-sysroot` vs `stage2`). In that case, we need to ensure this
// explicitly to make sure it ends up in the stage2 sysroot.
builder.ensure(compile::Std::new(compiler, target));
builder.ensure(compile::Rustc::new(compiler, target));
let _ = builder.compiler(compiler.stage, target);

let mut cargo = tool::prepare_tool_cargo(
builder,
Expand Down Expand Up @@ -2904,7 +2903,7 @@ impl Step for CrateRustdocJsonTypes {
// `compiler`, then it would cause rustdoc to be built *again*, which
// isn't really necessary.
let compiler = builder.compiler_for(builder.top_stage, target, target);
builder.ensure(compile::Rustc::new(compiler, target));
let _ = builder.compiler(compiler.stage, target);

let cargo = tool::prepare_tool_cargo(
builder,
Expand Down

0 comments on commit 28d8ac0

Please sign in to comment.