Skip to content

Commit ea4e57d

Browse files
Auto merge of #144303 - Kobzol:bootstrap-tool-cleanup, r=<try>
Consolidate staging for `rustc_private` tools try-job: x86_64-gnu-aux try-job: x86_64-msvc-ext1
2 parents c23f07d + c46f42d commit ea4e57d

File tree

12 files changed

+744
-451
lines changed

12 files changed

+744
-451
lines changed

src/bootstrap/src/core/build_steps/compile.rs

Lines changed: 35 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use serde_derive::Deserialize;
1919
use tracing::{instrument, span};
2020

2121
use crate::core::build_steps::gcc::{Gcc, add_cg_gcc_cargo_flags};
22-
use crate::core::build_steps::tool::{SourceType, copy_lld_artifacts};
22+
use crate::core::build_steps::tool::{RustcPrivateCompilers, SourceType, copy_lld_artifacts};
2323
use crate::core::build_steps::{dist, llvm};
2424
use crate::core::builder;
2525
use crate::core::builder::{
@@ -1131,7 +1131,7 @@ impl Step for Rustc {
11311131
cargo.env("RUSTC_BOLT_LINK_FLAGS", "1");
11321132
}
11331133

1134-
let _guard = builder.msg_sysroot_tool(
1134+
let _guard = builder.msg_rustc_tool(
11351135
Kind::Build,
11361136
build_compiler.stage,
11371137
format_args!("compiler artifacts{}", crate_description(&self.crates)),
@@ -1544,9 +1544,8 @@ impl Step for RustcLink {
15441544

15451545
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
15461546
pub struct CodegenBackend {
1547-
pub target: TargetSelection,
1548-
pub compiler: Compiler,
1549-
pub backend: CodegenBackendKind,
1547+
compilers: RustcPrivateCompilers,
1548+
backend: CodegenBackendKind,
15501549
}
15511550

15521551
fn needs_codegen_config(run: &RunConfig<'_>) -> bool {
@@ -1610,8 +1609,11 @@ impl Step for CodegenBackend {
16101609
}
16111610

16121611
run.builder.ensure(CodegenBackend {
1613-
target: run.target,
1614-
compiler: run.builder.compiler(run.builder.top_stage, run.build_triple()),
1612+
compilers: RustcPrivateCompilers::new(
1613+
run.builder,
1614+
run.builder.top_stage,
1615+
run.target,
1616+
),
16151617
backend: backend.clone(),
16161618
});
16171619
}
@@ -1624,20 +1626,17 @@ impl Step for CodegenBackend {
16241626
name = "CodegenBackend::run",
16251627
skip_all,
16261628
fields(
1627-
compiler = ?self.compiler,
1628-
target = ?self.target,
1629-
backend = ?self.target,
1629+
compilers = ?self.compilers,
1630+
backend = ?self.backend,
16301631
),
16311632
),
16321633
)]
16331634
fn run(self, builder: &Builder<'_>) {
1634-
let compiler = self.compiler;
1635-
let target = self.target;
16361635
let backend = self.backend;
1636+
let target = self.compilers.target();
1637+
let build_compiler = self.compilers.build_compiler();
16371638

1638-
builder.ensure(Rustc::new(compiler, target));
1639-
1640-
if builder.config.keep_stage.contains(&compiler.stage) {
1639+
if builder.config.keep_stage.contains(&build_compiler.stage) {
16411640
trace!("`keep-stage` requested");
16421641
builder.info(
16431642
"WARNING: Using a potentially old codegen backend. \
@@ -1648,17 +1647,11 @@ impl Step for CodegenBackend {
16481647
return;
16491648
}
16501649

1651-
let compiler_to_use = builder.compiler_for(compiler.stage, compiler.host, target);
1652-
if compiler_to_use != compiler {
1653-
builder.ensure(CodegenBackend { compiler: compiler_to_use, target, backend });
1654-
return;
1655-
}
1656-
1657-
let out_dir = builder.cargo_out(compiler, Mode::Codegen, target);
1650+
let out_dir = builder.cargo_out(build_compiler, Mode::Codegen, target);
16581651

16591652
let mut cargo = builder::Cargo::new(
16601653
builder,
1661-
compiler,
1654+
build_compiler,
16621655
Mode::Codegen,
16631656
SourceType::InTree,
16641657
target,
@@ -1679,8 +1672,13 @@ impl Step for CodegenBackend {
16791672

16801673
let tmp_stamp = BuildStamp::new(&out_dir).with_prefix("tmp");
16811674

1682-
let _guard =
1683-
builder.msg_build(compiler, format_args!("codegen backend {}", backend.name()), target);
1675+
let _guard = builder.msg_rustc_tool(
1676+
Kind::Build,
1677+
build_compiler.stage,
1678+
format_args!("codegen backend {}", backend.name()),
1679+
build_compiler.host,
1680+
target,
1681+
);
16841682
let files = run_cargo(builder, cargo, vec![], &tmp_stamp, vec![], false, false);
16851683
if builder.config.dry_run() {
16861684
return;
@@ -1700,10 +1698,17 @@ impl Step for CodegenBackend {
17001698
f.display()
17011699
);
17021700
}
1703-
let stamp = build_stamp::codegen_backend_stamp(builder, compiler, target, &backend);
1701+
let stamp = build_stamp::codegen_backend_stamp(builder, build_compiler, target, &backend);
17041702
let codegen_backend = codegen_backend.to_str().unwrap();
17051703
t!(stamp.add_stamp(codegen_backend).write());
17061704
}
1705+
1706+
fn metadata(&self) -> Option<StepMetadata> {
1707+
Some(
1708+
StepMetadata::build(&self.backend.crate_name(), self.compilers.target())
1709+
.built_by(self.compilers.build_compiler()),
1710+
)
1711+
}
17071712
}
17081713

17091714
/// Creates the `codegen-backends` folder for a compiler that's about to be
@@ -2190,8 +2195,10 @@ impl Step for Assemble {
21902195
continue;
21912196
}
21922197
builder.ensure(CodegenBackend {
2193-
compiler: build_compiler,
2194-
target: target_compiler.host,
2198+
compilers: RustcPrivateCompilers::from_build_and_target_compiler(
2199+
build_compiler,
2200+
target_compiler,
2201+
),
21952202
backend: backend.clone(),
21962203
});
21972204
}

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

Lines changed: 46 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use object::read::archive::ArchiveFile;
2020
use tracing::instrument;
2121

2222
use crate::core::build_steps::doc::DocumentationFormat;
23-
use crate::core::build_steps::tool::{self, Tool};
23+
use crate::core::build_steps::tool::{self, RustcPrivateCompilers, Tool};
2424
use crate::core::build_steps::vendor::{VENDOR_DIR, Vendor};
2525
use crate::core::build_steps::{compile, llvm};
2626
use crate::core::builder::{Builder, Kind, RunConfig, ShouldRun, Step, StepMetadata};
@@ -425,19 +425,20 @@ impl Step for Rustc {
425425
.as_ref()
426426
.is_none_or(|tools| tools.iter().any(|tool| tool == "rustdoc"))
427427
{
428-
let rustdoc = builder.rustdoc(compiler);
428+
let rustdoc = builder.rustdoc_for_compiler(compiler);
429429
builder.install(&rustdoc, &image.join("bin"), FileType::Executable);
430430
}
431431

432432
let ra_proc_macro_srv_compiler =
433433
builder.compiler_for(compiler.stage, builder.config.host_target, compiler.host);
434-
builder.ensure(compile::Rustc::new(ra_proc_macro_srv_compiler, compiler.host));
434+
let compilers = RustcPrivateCompilers::from_build_compiler(
435+
builder,
436+
ra_proc_macro_srv_compiler,
437+
compiler.host,
438+
);
435439

436440
if let Some(ra_proc_macro_srv) = builder.ensure_if_default(
437-
tool::RustAnalyzerProcMacroSrv {
438-
compiler: ra_proc_macro_srv_compiler,
439-
target: compiler.host,
440-
},
441+
tool::RustAnalyzerProcMacroSrv::from_compilers(compilers),
441442
builder.kind,
442443
) {
443444
let dst = image.join("libexec");
@@ -1172,7 +1173,7 @@ impl Step for PlainSourceTarball {
11721173

11731174
#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)]
11741175
pub struct Cargo {
1175-
pub compiler: Compiler,
1176+
pub build_compiler: Compiler,
11761177
pub target: TargetSelection,
11771178
}
11781179

@@ -1188,7 +1189,7 @@ impl Step for Cargo {
11881189

11891190
fn make_run(run: RunConfig<'_>) {
11901191
run.builder.ensure(Cargo {
1191-
compiler: run.builder.compiler_for(
1192+
build_compiler: run.builder.compiler_for(
11921193
run.builder.top_stage,
11931194
run.builder.config.host_target,
11941195
run.target,
@@ -1198,12 +1199,10 @@ impl Step for Cargo {
11981199
}
11991200

12001201
fn run(self, builder: &Builder<'_>) -> Option<GeneratedTarball> {
1201-
let compiler = self.compiler;
1202+
let build_compiler = self.build_compiler;
12021203
let target = self.target;
12031204

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

@@ -1228,7 +1227,7 @@ impl Step for Cargo {
12281227

12291228
#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)]
12301229
pub struct RustAnalyzer {
1231-
pub compiler: Compiler,
1230+
pub build_compiler: Compiler,
12321231
pub target: TargetSelection,
12331232
}
12341233

@@ -1244,7 +1243,7 @@ impl Step for RustAnalyzer {
12441243

12451244
fn make_run(run: RunConfig<'_>) {
12461245
run.builder.ensure(RustAnalyzer {
1247-
compiler: run.builder.compiler_for(
1246+
build_compiler: run.builder.compiler_for(
12481247
run.builder.top_stage,
12491248
run.builder.config.host_target,
12501249
run.target,
@@ -1254,12 +1253,11 @@ impl Step for RustAnalyzer {
12541253
}
12551254

12561255
fn run(self, builder: &Builder<'_>) -> Option<GeneratedTarball> {
1257-
let compiler = self.compiler;
12581256
let target = self.target;
1257+
let compilers =
1258+
RustcPrivateCompilers::from_build_compiler(builder, self.build_compiler, self.target);
12591259

1260-
builder.ensure(compile::Rustc::new(compiler, target));
1261-
1262-
let rust_analyzer = builder.ensure(tool::RustAnalyzer { compiler, target });
1260+
let rust_analyzer = builder.ensure(tool::RustAnalyzer::from_compilers(compilers));
12631261

12641262
let mut tarball = Tarball::new(builder, "rust-analyzer", &target.triple);
12651263
tarball.set_overlay(OverlayKind::RustAnalyzer);
@@ -1270,9 +1268,9 @@ impl Step for RustAnalyzer {
12701268
}
12711269
}
12721270

1273-
#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)]
1271+
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
12741272
pub struct Clippy {
1275-
pub compiler: Compiler,
1273+
pub build_compiler: Compiler,
12761274
pub target: TargetSelection,
12771275
}
12781276

@@ -1288,7 +1286,7 @@ impl Step for Clippy {
12881286

12891287
fn make_run(run: RunConfig<'_>) {
12901288
run.builder.ensure(Clippy {
1291-
compiler: run.builder.compiler_for(
1289+
build_compiler: run.builder.compiler_for(
12921290
run.builder.top_stage,
12931291
run.builder.config.host_target,
12941292
run.target,
@@ -1298,16 +1296,15 @@ impl Step for Clippy {
12981296
}
12991297

13001298
fn run(self, builder: &Builder<'_>) -> Option<GeneratedTarball> {
1301-
let compiler = self.compiler;
13021299
let target = self.target;
1303-
1304-
builder.ensure(compile::Rustc::new(compiler, target));
1300+
let compilers =
1301+
RustcPrivateCompilers::from_build_compiler(builder, self.build_compiler, target);
13051302

13061303
// Prepare the image directory
13071304
// We expect clippy to build, because we've exited this step above if tool
13081305
// state for clippy isn't testing.
1309-
let clippy = builder.ensure(tool::Clippy { compiler, target });
1310-
let cargoclippy = builder.ensure(tool::CargoClippy { compiler, target });
1306+
let clippy = builder.ensure(tool::Clippy::from_compilers(compilers));
1307+
let cargoclippy = builder.ensure(tool::CargoClippy::from_compilers(compilers));
13111308

13121309
let mut tarball = Tarball::new(builder, "clippy", &target.triple);
13131310
tarball.set_overlay(OverlayKind::Clippy);
@@ -1319,9 +1316,9 @@ impl Step for Clippy {
13191316
}
13201317
}
13211318

1322-
#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)]
1319+
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
13231320
pub struct Miri {
1324-
pub compiler: Compiler,
1321+
pub build_compiler: Compiler,
13251322
pub target: TargetSelection,
13261323
}
13271324

@@ -1337,7 +1334,7 @@ impl Step for Miri {
13371334

13381335
fn make_run(run: RunConfig<'_>) {
13391336
run.builder.ensure(Miri {
1340-
compiler: run.builder.compiler_for(
1337+
build_compiler: run.builder.compiler_for(
13411338
run.builder.top_stage,
13421339
run.builder.config.host_target,
13431340
run.target,
@@ -1354,15 +1351,12 @@ impl Step for Miri {
13541351
return None;
13551352
}
13561353

1357-
let compiler = self.compiler;
1358-
let target = self.target;
1359-
1360-
builder.ensure(compile::Rustc::new(compiler, target));
1354+
let compilers =
1355+
RustcPrivateCompilers::from_build_compiler(builder, self.build_compiler, self.target);
1356+
let miri = builder.ensure(tool::Miri::from_compilers(compilers));
1357+
let cargomiri = builder.ensure(tool::CargoMiri::from_compilers(compilers));
13611358

1362-
let miri = builder.ensure(tool::Miri { compiler, target });
1363-
let cargomiri = builder.ensure(tool::CargoMiri { compiler, target });
1364-
1365-
let mut tarball = Tarball::new(builder, "miri", &target.triple);
1359+
let mut tarball = Tarball::new(builder, "miri", &self.target.triple);
13661360
tarball.set_overlay(OverlayKind::Miri);
13671361
tarball.is_preview(true);
13681362
tarball.add_file(&miri.tool_path, "bin", FileType::Executable);
@@ -1466,9 +1460,9 @@ impl Step for CodegenBackend {
14661460
}
14671461
}
14681462

1469-
#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)]
1463+
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
14701464
pub struct Rustfmt {
1471-
pub compiler: Compiler,
1465+
pub build_compiler: Compiler,
14721466
pub target: TargetSelection,
14731467
}
14741468

@@ -1484,7 +1478,7 @@ impl Step for Rustfmt {
14841478

14851479
fn make_run(run: RunConfig<'_>) {
14861480
run.builder.ensure(Rustfmt {
1487-
compiler: run.builder.compiler_for(
1481+
build_compiler: run.builder.compiler_for(
14881482
run.builder.top_stage,
14891483
run.builder.config.host_target,
14901484
run.target,
@@ -1494,14 +1488,13 @@ impl Step for Rustfmt {
14941488
}
14951489

14961490
fn run(self, builder: &Builder<'_>) -> Option<GeneratedTarball> {
1497-
let compiler = self.compiler;
1498-
let target = self.target;
1491+
let compilers =
1492+
RustcPrivateCompilers::from_build_compiler(builder, self.build_compiler, self.target);
14991493

1500-
builder.ensure(compile::Rustc::new(compiler, target));
1494+
let rustfmt = builder.ensure(tool::Rustfmt::from_compilers(compilers));
1495+
let cargofmt = builder.ensure(tool::Cargofmt::from_compilers(compilers));
15011496

1502-
let rustfmt = builder.ensure(tool::Rustfmt { compiler, target });
1503-
let cargofmt = builder.ensure(tool::Cargofmt { compiler, target });
1504-
let mut tarball = Tarball::new(builder, "rustfmt", &target.triple);
1497+
let mut tarball = Tarball::new(builder, "rustfmt", &self.target.triple);
15051498
tarball.set_overlay(OverlayKind::Rustfmt);
15061499
tarball.is_preview(true);
15071500
tarball.add_file(&rustfmt.tool_path, "bin", FileType::Executable);
@@ -1548,7 +1541,7 @@ impl Step for Extended {
15481541
let mut built_tools = HashSet::new();
15491542
macro_rules! add_component {
15501543
($name:expr => $step:expr) => {
1551-
if let Some(tarball) = builder.ensure_if_default($step, Kind::Dist) {
1544+
if let Some(Some(tarball)) = builder.ensure_if_default($step, Kind::Dist) {
15521545
tarballs.push(tarball);
15531546
built_tools.insert($name);
15541547
}
@@ -1568,12 +1561,12 @@ impl Step for Extended {
15681561

15691562
add_component!("rust-docs" => Docs { host: target });
15701563
add_component!("rust-json-docs" => JsonDocs { host: target });
1571-
add_component!("cargo" => Cargo { compiler, target });
1572-
add_component!("rustfmt" => Rustfmt { compiler, target });
1573-
add_component!("rust-analyzer" => RustAnalyzer { compiler, target });
1564+
add_component!("cargo" => Cargo { build_compiler: compiler, target });
1565+
add_component!("rustfmt" => Rustfmt { build_compiler: compiler, target });
1566+
add_component!("rust-analyzer" => RustAnalyzer { build_compiler: compiler, target });
15741567
add_component!("llvm-components" => LlvmTools { target });
1575-
add_component!("clippy" => Clippy { compiler, target });
1576-
add_component!("miri" => Miri { compiler, target });
1568+
add_component!("clippy" => Clippy { build_compiler: compiler, target });
1569+
add_component!("miri" => Miri { build_compiler: compiler, target });
15771570
add_component!("analysis" => Analysis { compiler, target });
15781571
add_component!("rustc-codegen-cranelift" => CodegenBackend {
15791572
compiler: builder.compiler(stage, target),

0 commit comments

Comments
 (0)