Skip to content

Commit e7b7d39

Browse files
committed
Refactor RustcDev dist step
1 parent 502dc8d commit e7b7d39

File tree

2 files changed

+25
-12
lines changed

2 files changed

+25
-12
lines changed

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

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -823,8 +823,9 @@ impl Step for Std {
823823
/// (Don't confuse this with [`RustDev`], without the `c`!)
824824
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
825825
pub struct RustcDev {
826-
pub compiler: Compiler,
827-
pub target: TargetSelection,
826+
/// The compiler that will build rustc which will be shipped in this component.
827+
build_compiler: Compiler,
828+
target: TargetSelection,
828829
}
829830

830831
impl Step for RustcDev {
@@ -838,28 +839,27 @@ impl Step for RustcDev {
838839

839840
fn make_run(run: RunConfig<'_>) {
840841
run.builder.ensure(RustcDev {
841-
compiler: run.builder.compiler_for(
842-
run.builder.top_stage,
843-
run.builder.config.host_target,
844-
run.target,
845-
),
842+
// We currently always ship a stage 2 rustc-dev component, so we build it with the
843+
// stage 1 compiler. This might change in the future.
844+
// The precise stage used here is important, so we hard-code it.
845+
build_compiler: run.builder.compiler(1, run.builder.config.host_target),
846846
target: run.target,
847847
});
848848
}
849849

850850
fn run(self, builder: &Builder<'_>) -> Option<GeneratedTarball> {
851-
let compiler = self.compiler;
851+
let build_compiler = self.build_compiler;
852852
let target = self.target;
853-
if skip_host_target_lib(builder, compiler) {
853+
if skip_host_target_lib(builder, build_compiler) {
854854
return None;
855855
}
856856

857-
builder.ensure(compile::Rustc::new(compiler, target));
857+
// Build the compiler that we will ship
858+
builder.ensure(compile::Rustc::new(build_compiler, target));
858859

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

861-
let compiler_to_use = builder.compiler_for(compiler.stage, compiler.host, target);
862-
let stamp = build_stamp::librustc_stamp(builder, compiler_to_use, target);
862+
let stamp = build_stamp::librustc_stamp(builder, build_compiler, target);
863863
copy_target_libs(builder, target, tarball.image_dir(), &stamp);
864864

865865
let src_files = &["Cargo.lock"];
@@ -883,6 +883,10 @@ impl Step for RustcDev {
883883

884884
Some(tarball.generate())
885885
}
886+
887+
fn metadata(&self) -> Option<StepMetadata> {
888+
Some(StepMetadata::dist("rustc-dev", self.target).built_by(self.build_compiler))
889+
}
886890
}
887891

888892
#[derive(Debug, Clone, Hash, PartialEq, Eq)]

src/bootstrap/src/core/builder/tests.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1134,6 +1134,7 @@ mod snapshot {
11341134
[build] rustc 0 <host> -> GenerateCopyright 1 <host>
11351135
[dist] rustc <host>
11361136
[dist] rustc 1 <host> -> std 1 <host>
1137+
[dist] rustc 1 <host> -> rustc-dev 2 <host>
11371138
[dist] src <>
11381139
"
11391140
);
@@ -1196,6 +1197,7 @@ mod snapshot {
11961197
[build] rustc 0 <host> -> GenerateCopyright 1 <host>
11971198
[dist] rustc <host>
11981199
[dist] rustc 1 <host> -> std 1 <host>
1200+
[dist] rustc 1 <host> -> rustc-dev 2 <host>
11991201
[dist] src <>
12001202
[build] rustc 1 <host> -> cargo 2 <host>
12011203
[build] rustc 1 <host> -> rust-analyzer 2 <host>
@@ -1276,6 +1278,7 @@ mod snapshot {
12761278
[dist] rustc 1 <host> -> std 1 <host>
12771279
[build] rustc 2 <host> -> std 2 <target1>
12781280
[dist] rustc 2 <host> -> std 2 <target1>
1281+
[dist] rustc 1 <host> -> rustc-dev 2 <host>
12791282
[dist] src <>
12801283
"
12811284
);
@@ -1334,6 +1337,8 @@ mod snapshot {
13341337
[build] rustdoc 2 <target1>
13351338
[dist] rustc <target1>
13361339
[dist] rustc 1 <host> -> std 1 <host>
1340+
[dist] rustc 1 <host> -> rustc-dev 2 <host>
1341+
[dist] rustc 1 <host> -> rustc-dev 2 <target1>
13371342
[dist] src <>
13381343
"
13391344
);
@@ -1413,6 +1418,8 @@ mod snapshot {
14131418
[dist] rustc <target1>
14141419
[dist] rustc 1 <host> -> std 1 <host>
14151420
[dist] rustc 1 <host> -> std 1 <target1>
1421+
[dist] rustc 1 <host> -> rustc-dev 2 <host>
1422+
[dist] rustc 1 <host> -> rustc-dev 2 <target1>
14161423
[dist] src <>
14171424
"
14181425
);
@@ -1518,6 +1525,7 @@ mod snapshot {
15181525
[build] rustc 0 <host> -> GenerateCopyright 1 <host>
15191526
[dist] rustc <target1>
15201527
[dist] rustc 1 <host> -> std 1 <target1>
1528+
[dist] rustc 1 <host> -> rustc-dev 2 <target1>
15211529
[dist] src <>
15221530
[build] rustc 1 <host> -> cargo 2 <target1>
15231531
[build] rustc 1 <host> -> rust-analyzer 2 <target1>
@@ -1581,6 +1589,7 @@ mod snapshot {
15811589
[dist] rustc <host>
15821590
[dist] rustc 1 <host> -> rustc_codegen_cranelift 2 <host>
15831591
[dist] rustc 1 <host> -> std 1 <host>
1592+
[dist] rustc 1 <host> -> rustc-dev 2 <host>
15841593
[dist] src <>
15851594
");
15861595
}

0 commit comments

Comments
 (0)