Skip to content

Commit c4fef48

Browse files
committed
Make build compiler explicit in dist::Cargo
1 parent b6274c4 commit c4fef48

File tree

4 files changed

+25
-16
lines changed

4 files changed

+25
-16
lines changed

src/bootstrap/src/core/build_steps/dist.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1171,7 +1171,7 @@ impl Step for PlainSourceTarball {
11711171

11721172
#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)]
11731173
pub struct Cargo {
1174-
pub compiler: Compiler,
1174+
pub build_compiler: Compiler,
11751175
pub target: TargetSelection,
11761176
}
11771177

@@ -1187,7 +1187,7 @@ impl Step for Cargo {
11871187

11881188
fn make_run(run: RunConfig<'_>) {
11891189
run.builder.ensure(Cargo {
1190-
compiler: run.builder.compiler_for(
1190+
build_compiler: run.builder.compiler_for(
11911191
run.builder.top_stage,
11921192
run.builder.config.host_target,
11931193
run.target,
@@ -1197,12 +1197,10 @@ impl Step for Cargo {
11971197
}
11981198

11991199
fn run(self, builder: &Builder<'_>) -> Option<GeneratedTarball> {
1200-
let compiler = self.compiler;
1200+
let build_compiler = self.build_compiler;
12011201
let target = self.target;
12021202

1203-
builder.ensure(compile::Rustc::new(compiler, target));
1204-
1205-
let cargo = builder.ensure(tool::Cargo { compiler, target });
1203+
let cargo = builder.ensure(tool::Cargo::from_build_compiler(build_compiler, target));
12061204
let src = builder.src.join("src/tools/cargo");
12071205
let etc = src.join("src/etc");
12081206

@@ -1559,7 +1557,7 @@ impl Step for Extended {
15591557

15601558
add_component!("rust-docs" => Docs { host: target });
15611559
add_component!("rust-json-docs" => JsonDocs { host: target });
1562-
add_component!("cargo" => Cargo { compiler, target });
1560+
add_component!("cargo" => Cargo { build_compiler: compiler, target });
15631561
add_component!("rustfmt" => Rustfmt { build_compiler: compiler, target });
15641562
add_component!("rust-analyzer" => RustAnalyzer { build_compiler: compiler, target });
15651563
add_component!("llvm-components" => LlvmTools { target });

src/bootstrap/src/core/build_steps/install.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ install!((self, builder, _config),
215215
};
216216
Cargo, alias = "cargo", Self::should_build(_config), only_hosts: true, {
217217
let tarball = builder
218-
.ensure(dist::Cargo { compiler: self.compiler, target: self.target })
218+
.ensure(dist::Cargo { build_compiler: self.compiler, target: self.target })
219219
.expect("missing cargo");
220220
install_sh(builder, "cargo", self.compiler.stage, Some(self.target), &tarball);
221221
};

src/bootstrap/src/core/build_steps/test.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ impl Step for Cargotest {
255255
// both their behavior together.
256256
// We can build cargo with the earlier stage compiler though.
257257
let cargo =
258-
builder.ensure(tool::Cargo { compiler: self.build_compiler, target: self.host });
258+
builder.ensure(tool::Cargo::from_build_compiler(self.build_compiler, self.host));
259259
let tested_compiler = builder.compiler(self.build_compiler.stage + 1, self.host);
260260
builder.std(tested_compiler, self.host);
261261

@@ -329,7 +329,7 @@ impl Step for Cargo {
329329

330330
let compiler = builder.compiler(stage, self.host);
331331

332-
let cargo = builder.ensure(tool::Cargo { compiler, target: self.host });
332+
let cargo = builder.ensure(tool::Cargo::from_build_compiler(compiler, self.host));
333333
let compiler = cargo.build_compiler;
334334

335335
let cargo = tool::prepare_tool_cargo(
@@ -1729,7 +1729,7 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the
17291729
// If we're using `--stage 0`, we should provide the bootstrap cargo.
17301730
builder.initial_cargo.clone()
17311731
} else {
1732-
builder.ensure(tool::Cargo { compiler, target: compiler.host }).tool_path
1732+
builder.ensure(tool::Cargo::from_build_compiler(compiler, compiler.host)).tool_path
17331733
};
17341734

17351735
cmd.arg("--cargo-path").arg(cargo_path);

src/bootstrap/src/core/build_steps/tool.rs

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -806,8 +806,16 @@ impl Step for Rustdoc {
806806
/// Note that it can be built using a stable compiler.
807807
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
808808
pub struct Cargo {
809-
pub compiler: Compiler,
810-
pub target: TargetSelection,
809+
build_compiler: Compiler,
810+
target: TargetSelection,
811+
}
812+
813+
impl Cargo {
814+
/// Returns `Cargo` that will be **compiled** by the passed compiler, for the given
815+
/// `target`.
816+
pub fn from_build_compiler(build_compiler: Compiler, target: TargetSelection) -> Self {
817+
Self { build_compiler, target }
818+
}
811819
}
812820

813821
impl Step for Cargo {
@@ -822,7 +830,10 @@ impl Step for Cargo {
822830

823831
fn make_run(run: RunConfig<'_>) {
824832
run.builder.ensure(Cargo {
825-
compiler: get_tool_target_compiler(run.builder, ToolTargetBuildMode::Build(run.target)),
833+
build_compiler: get_tool_target_compiler(
834+
run.builder,
835+
ToolTargetBuildMode::Build(run.target),
836+
),
826837
target: run.target,
827838
});
828839
}
@@ -831,7 +842,7 @@ impl Step for Cargo {
831842
builder.build.require_submodule("src/tools/cargo", None);
832843

833844
builder.ensure(ToolBuild {
834-
build_compiler: self.compiler,
845+
build_compiler: self.build_compiler,
835846
target: self.target,
836847
tool: "cargo",
837848
mode: Mode::ToolTarget,
@@ -845,7 +856,7 @@ impl Step for Cargo {
845856
}
846857

847858
fn metadata(&self) -> Option<StepMetadata> {
848-
Some(StepMetadata::build("cargo", self.target).built_by(self.compiler))
859+
Some(StepMetadata::build("cargo", self.target).built_by(self.build_compiler))
849860
}
850861
}
851862

0 commit comments

Comments
 (0)