Skip to content

Commit 99b044e

Browse files
committed
Refactor RustcDev dist step
1 parent 92d076c commit 99b044e

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
@@ -1057,6 +1057,7 @@ mod snapshot {
10571057
[build] rustc 0 <host> -> GenerateCopyright 1 <host>
10581058
[dist] rustc <host>
10591059
[dist] rustc 1 <host> -> std 1 <host>
1060+
[dist] rustc 1 <host> -> rustc-dev 2 <host>
10601061
[dist] src <>
10611062
"
10621063
);
@@ -1119,6 +1120,7 @@ mod snapshot {
11191120
[build] rustc 0 <host> -> GenerateCopyright 1 <host>
11201121
[dist] rustc <host>
11211122
[dist] rustc 1 <host> -> std 1 <host>
1123+
[dist] rustc 1 <host> -> rustc-dev 2 <host>
11221124
[dist] src <>
11231125
[build] rustc 1 <host> -> cargo 2 <host>
11241126
[build] rustc 1 <host> -> rust-analyzer 2 <host>
@@ -1199,6 +1201,7 @@ mod snapshot {
11991201
[dist] rustc 1 <host> -> std 1 <host>
12001202
[build] rustc 2 <host> -> std 2 <target1>
12011203
[dist] rustc 2 <host> -> std 2 <target1>
1204+
[dist] rustc 1 <host> -> rustc-dev 2 <host>
12021205
[dist] src <>
12031206
"
12041207
);
@@ -1257,6 +1260,8 @@ mod snapshot {
12571260
[build] rustdoc 2 <target1>
12581261
[dist] rustc <target1>
12591262
[dist] rustc 1 <host> -> std 1 <host>
1263+
[dist] rustc 1 <host> -> rustc-dev 2 <host>
1264+
[dist] rustc 1 <host> -> rustc-dev 2 <target1>
12601265
[dist] src <>
12611266
"
12621267
);
@@ -1336,6 +1341,8 @@ mod snapshot {
13361341
[dist] rustc <target1>
13371342
[dist] rustc 1 <host> -> std 1 <host>
13381343
[dist] rustc 1 <host> -> std 1 <target1>
1344+
[dist] rustc 1 <host> -> rustc-dev 2 <host>
1345+
[dist] rustc 1 <host> -> rustc-dev 2 <target1>
13391346
[dist] src <>
13401347
"
13411348
);
@@ -1441,6 +1448,7 @@ mod snapshot {
14411448
[build] rustc 0 <host> -> GenerateCopyright 1 <host>
14421449
[dist] rustc <target1>
14431450
[dist] rustc 1 <host> -> std 1 <target1>
1451+
[dist] rustc 1 <host> -> rustc-dev 2 <target1>
14441452
[dist] src <>
14451453
[build] rustc 1 <host> -> cargo 2 <target1>
14461454
[build] rustc 1 <host> -> rust-analyzer 2 <target1>
@@ -1504,6 +1512,7 @@ mod snapshot {
15041512
[dist] rustc <host>
15051513
[dist] rustc 1 <host> -> rustc_codegen_cranelift 2 <host>
15061514
[dist] rustc 1 <host> -> std 1 <host>
1515+
[dist] rustc 1 <host> -> rustc-dev 2 <host>
15071516
[dist] src <>
15081517
");
15091518
}

0 commit comments

Comments
 (0)