diff options
| author | Jakub Beránek <berykubik@gmail.com> | 2025-07-28 15:01:14 +0200 |
|---|---|---|
| committer | Jakub Beránek <berykubik@gmail.com> | 2025-08-01 15:46:25 +0200 |
| commit | 528e7dc9aec150250097e5918879023051f06249 (patch) | |
| tree | 4f837f2508a930ede74c1ce5c291bdd942b38d96 | |
| parent | 3e6aa8169115ed1f9a3474ab45284561a30d780a (diff) | |
| download | rust-528e7dc9aec150250097e5918879023051f06249.tar.gz rust-528e7dc9aec150250097e5918879023051f06249.zip | |
Make build compiler explicit in `dist::Cargo`
| -rw-r--r-- | src/bootstrap/src/core/build_steps/dist.rs | 12 | ||||
| -rw-r--r-- | src/bootstrap/src/core/build_steps/install.rs | 2 | ||||
| -rw-r--r-- | src/bootstrap/src/core/build_steps/test.rs | 6 | ||||
| -rw-r--r-- | src/bootstrap/src/core/build_steps/tool.rs | 21 |
4 files changed, 25 insertions, 16 deletions
diff --git a/src/bootstrap/src/core/build_steps/dist.rs b/src/bootstrap/src/core/build_steps/dist.rs index 2d504cbd55a..0465a071159 100644 --- a/src/bootstrap/src/core/build_steps/dist.rs +++ b/src/bootstrap/src/core/build_steps/dist.rs @@ -1173,7 +1173,7 @@ impl Step for PlainSourceTarball { #[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)] pub struct Cargo { - pub compiler: Compiler, + pub build_compiler: Compiler, pub target: TargetSelection, } @@ -1189,7 +1189,7 @@ impl Step for Cargo { fn make_run(run: RunConfig<'_>) { run.builder.ensure(Cargo { - compiler: run.builder.compiler_for( + build_compiler: run.builder.compiler_for( run.builder.top_stage, run.builder.config.host_target, run.target, @@ -1199,12 +1199,10 @@ impl Step for Cargo { } fn run(self, builder: &Builder<'_>) -> Option<GeneratedTarball> { - let compiler = self.compiler; + let build_compiler = self.build_compiler; let target = self.target; - builder.ensure(compile::Rustc::new(compiler, target)); - - let cargo = builder.ensure(tool::Cargo { compiler, target }); + let cargo = builder.ensure(tool::Cargo::from_build_compiler(build_compiler, target)); let src = builder.src.join("src/tools/cargo"); let etc = src.join("src/etc"); @@ -1563,7 +1561,7 @@ impl Step for Extended { add_component!("rust-docs" => Docs { host: target }); add_component!("rust-json-docs" => JsonDocs { host: target }); - add_component!("cargo" => Cargo { compiler, target }); + add_component!("cargo" => Cargo { build_compiler: compiler, target }); add_component!("rustfmt" => Rustfmt { build_compiler: compiler, target }); add_component!("rust-analyzer" => RustAnalyzer { build_compiler: compiler, target }); add_component!("llvm-components" => LlvmTools { target }); diff --git a/src/bootstrap/src/core/build_steps/install.rs b/src/bootstrap/src/core/build_steps/install.rs index 2427b019129..f628330e9ed 100644 --- a/src/bootstrap/src/core/build_steps/install.rs +++ b/src/bootstrap/src/core/build_steps/install.rs @@ -215,7 +215,7 @@ install!((self, builder, _config), }; Cargo, alias = "cargo", Self::should_build(_config), only_hosts: true, { let tarball = builder - .ensure(dist::Cargo { compiler: self.compiler, target: self.target }) + .ensure(dist::Cargo { build_compiler: self.compiler, target: self.target }) .expect("missing cargo"); install_sh(builder, "cargo", self.compiler.stage, Some(self.target), &tarball); }; diff --git a/src/bootstrap/src/core/build_steps/test.rs b/src/bootstrap/src/core/build_steps/test.rs index e542ab7c127..c5e18f61047 100644 --- a/src/bootstrap/src/core/build_steps/test.rs +++ b/src/bootstrap/src/core/build_steps/test.rs @@ -258,7 +258,7 @@ impl Step for Cargotest { // both their behavior together. // We can build cargo with the earlier stage compiler though. let cargo = - builder.ensure(tool::Cargo { compiler: self.build_compiler, target: self.host }); + builder.ensure(tool::Cargo::from_build_compiler(self.build_compiler, self.host)); let tested_compiler = builder.compiler(self.build_compiler.stage + 1, self.host); builder.std(tested_compiler, self.host); @@ -332,7 +332,7 @@ impl Step for Cargo { let compiler = builder.compiler(stage, self.host); - let cargo = builder.ensure(tool::Cargo { compiler, target: self.host }); + let cargo = builder.ensure(tool::Cargo::from_build_compiler(compiler, self.host)); let compiler = cargo.build_compiler; 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 // If we're using `--stage 0`, we should provide the bootstrap cargo. builder.initial_cargo.clone() } else { - builder.ensure(tool::Cargo { compiler, target: compiler.host }).tool_path + builder.ensure(tool::Cargo::from_build_compiler(compiler, compiler.host)).tool_path }; cmd.arg("--cargo-path").arg(cargo_path); diff --git a/src/bootstrap/src/core/build_steps/tool.rs b/src/bootstrap/src/core/build_steps/tool.rs index a2c7c8c65b0..0dc9002d4e4 100644 --- a/src/bootstrap/src/core/build_steps/tool.rs +++ b/src/bootstrap/src/core/build_steps/tool.rs @@ -806,8 +806,16 @@ impl Step for Rustdoc { /// Note that it can be built using a stable compiler. #[derive(Debug, Clone, Hash, PartialEq, Eq)] pub struct Cargo { - pub compiler: Compiler, - pub target: TargetSelection, + build_compiler: Compiler, + target: TargetSelection, +} + +impl Cargo { + /// Returns `Cargo` that will be **compiled** by the passed compiler, for the given + /// `target`. + pub fn from_build_compiler(build_compiler: Compiler, target: TargetSelection) -> Self { + Self { build_compiler, target } + } } impl Step for Cargo { @@ -822,7 +830,10 @@ impl Step for Cargo { fn make_run(run: RunConfig<'_>) { run.builder.ensure(Cargo { - compiler: get_tool_target_compiler(run.builder, ToolTargetBuildMode::Build(run.target)), + build_compiler: get_tool_target_compiler( + run.builder, + ToolTargetBuildMode::Build(run.target), + ), target: run.target, }); } @@ -831,7 +842,7 @@ impl Step for Cargo { builder.build.require_submodule("src/tools/cargo", None); builder.ensure(ToolBuild { - build_compiler: self.compiler, + build_compiler: self.build_compiler, target: self.target, tool: "cargo", mode: Mode::ToolTarget, @@ -845,7 +856,7 @@ impl Step for Cargo { } fn metadata(&self) -> Option<StepMetadata> { - Some(StepMetadata::build("cargo", self.target).built_by(self.compiler)) + Some(StepMetadata::build("cargo", self.target).built_by(self.build_compiler)) } } |
