Skip to content

Commit 528e7dc

Browse files
committed
Make build compiler explicit in dist::Cargo
1 parent 3e6aa81 commit 528e7dc

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
@@ -1173,7 +1173,7 @@ impl Step for PlainSourceTarball {
11731173

11741174
#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)]
11751175
pub struct Cargo {
1176-
pub compiler: Compiler,
1176+
pub build_compiler: Compiler,
11771177
pub target: TargetSelection,
11781178
}
11791179

@@ -1189,7 +1189,7 @@ impl Step for Cargo {
11891189

11901190
fn make_run(run: RunConfig<'_>) {
11911191
run.builder.ensure(Cargo {
1192-
compiler: run.builder.compiler_for(
1192+
build_compiler: run.builder.compiler_for(
11931193
run.builder.top_stage,
11941194
run.builder.config.host_target,
11951195
run.target,
@@ -1199,12 +1199,10 @@ impl Step for Cargo {
11991199
}
12001200

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

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

@@ -1563,7 +1561,7 @@ impl Step for Extended {
15631561

15641562
add_component!("rust-docs" => Docs { host: target });
15651563
add_component!("rust-json-docs" => JsonDocs { host: target });
1566-
add_component!("cargo" => Cargo { compiler, target });
1564+
add_component!("cargo" => Cargo { build_compiler: compiler, target });
15671565
add_component!("rustfmt" => Rustfmt { build_compiler: compiler, target });
15681566
add_component!("rust-analyzer" => RustAnalyzer { build_compiler: compiler, target });
15691567
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
@@ -258,7 +258,7 @@ impl Step for Cargotest {
258258
// both their behavior together.
259259
// We can build cargo with the earlier stage compiler though.
260260
let cargo =
261-
builder.ensure(tool::Cargo { compiler: self.build_compiler, target: self.host });
261+
builder.ensure(tool::Cargo::from_build_compiler(self.build_compiler, self.host));
262262
let tested_compiler = builder.compiler(self.build_compiler.stage + 1, self.host);
263263
builder.std(tested_compiler, self.host);
264264

@@ -332,7 +332,7 @@ impl Step for Cargo {
332332

333333
let compiler = builder.compiler(stage, self.host);
334334

335-
let cargo = builder.ensure(tool::Cargo { compiler, target: self.host });
335+
let cargo = builder.ensure(tool::Cargo::from_build_compiler(compiler, self.host));
336336
let compiler = cargo.build_compiler;
337337

338338
let cargo = tool::prepare_tool_cargo(
@@ -1751,7 +1751,7 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the
17511751
// If we're using `--stage 0`, we should provide the bootstrap cargo.
17521752
builder.initial_cargo.clone()
17531753
} else {
1754-
builder.ensure(tool::Cargo { compiler, target: compiler.host }).tool_path
1754+
builder.ensure(tool::Cargo::from_build_compiler(compiler, compiler.host)).tool_path
17551755
};
17561756

17571757
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)