Skip to content

Commit fefaa85

Browse files
committed
Check rustc-dev in distcheck
1 parent 1520e42 commit fefaa85

File tree

2 files changed

+39
-9
lines changed

2 files changed

+39
-9
lines changed

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

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -823,6 +823,18 @@ pub struct RustcDev {
823823
target: TargetSelection,
824824
}
825825

826+
impl RustcDev {
827+
pub fn new(builder: &Builder<'_>, target: TargetSelection) -> Self {
828+
Self {
829+
// We currently always ship a stage 2 rustc-dev component, so we build it with the
830+
// stage 1 compiler. This might change in the future.
831+
// The precise stage used here is important, so we hard-code it.
832+
build_compiler: builder.compiler(1, builder.config.host_target),
833+
target,
834+
}
835+
}
836+
}
837+
826838
impl Step for RustcDev {
827839
type Output = Option<GeneratedTarball>;
828840
const DEFAULT: bool = true;
@@ -833,13 +845,7 @@ impl Step for RustcDev {
833845
}
834846

835847
fn make_run(run: RunConfig<'_>) {
836-
run.builder.ensure(RustcDev {
837-
// We currently always ship a stage 2 rustc-dev component, so we build it with the
838-
// stage 1 compiler. This might change in the future.
839-
// The precise stage used here is important, so we hard-code it.
840-
build_compiler: run.builder.compiler(1, run.builder.config.host_target),
841-
target: run.target,
842-
});
848+
run.builder.ensure(RustcDev::new(run.builder, run.target));
843849
}
844850

845851
fn run(self, builder: &Builder<'_>) -> Option<GeneratedTarball> {

src/bootstrap/src/core/build_steps/test.rs

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3229,6 +3229,7 @@ impl Step for Distcheck {
32293229
/// check steps from those sources.
32303230
/// - Check that selected dist components (`rust-src` only at the moment) at least have expected
32313231
/// directory shape and crate manifests that cargo can generate a lockfile from.
3232+
/// - Check that we can run `cargo metadata` on the workspace in the `rustc-dev` component
32323233
///
32333234
/// FIXME(#136822): dist components are under-tested.
32343235
fn run(self, builder: &Builder<'_>) {
@@ -3238,11 +3239,12 @@ impl Step for Distcheck {
32383239

32393240
distcheck_plain_source_tarball(builder, &root_dir.join("distcheck-plain-src"));
32403241
distcheck_rust_src(builder, &root_dir.join("distcheck-src"));
3242+
distcheck_rustc_dev(builder, &root_dir.join("distcheck-rustc-dev"));
32413243
}
32423244
}
32433245

3246+
/// Check that we can build some basic things from the plain source tarball
32443247
fn distcheck_plain_source_tarball(builder: &Builder<'_>, plain_src_dir: &Path) {
3245-
// Check that we can build some basic things from the plain source tarball
32463248
builder.info("Distcheck plain source tarball");
32473249
let plain_src_tarball = builder.ensure(dist::PlainSourceTarball);
32483250
builder.clear_dir(&plain_src_dir);
@@ -3273,8 +3275,8 @@ fn distcheck_plain_source_tarball(builder: &Builder<'_>, plain_src_dir: &Path) {
32733275
.run(builder);
32743276
}
32753277

3278+
/// Check that rust-src has all of libstd's dependencies
32763279
fn distcheck_rust_src(builder: &Builder<'_>, src_dir: &Path) {
3277-
// Now make sure that rust-src has all of libstd's dependencies
32783280
builder.info("Distcheck rust-src");
32793281
let src_tarball = builder.ensure(dist::Src);
32803282
builder.clear_dir(&src_dir);
@@ -3298,6 +3300,28 @@ fn distcheck_rust_src(builder: &Builder<'_>, src_dir: &Path) {
32983300
.run(builder);
32993301
}
33003302

3303+
/// Check that rustc-dev's compiler crate source code can be loaded with `cargo metadata`
3304+
fn distcheck_rustc_dev(builder: &Builder<'_>, dir: &Path) {
3305+
builder.info("Distcheck rustc-dev");
3306+
let tarball = builder.ensure(dist::RustcDev::new(builder, builder.host_target)).unwrap();
3307+
builder.clear_dir(&dir);
3308+
3309+
command("tar")
3310+
.arg("-xf")
3311+
.arg(tarball.tarball())
3312+
.arg("--strip-components=1")
3313+
.current_dir(&dir)
3314+
.run(builder);
3315+
3316+
command(&builder.initial_cargo)
3317+
.arg("metadata")
3318+
.arg("--manifest-path")
3319+
.arg("rustc-dev/lib/rustlib/rustc-src/rust/compiler/rustc_ast/Cargo.toml")
3320+
.env("RUSTC_BOOTSTRAP", "1")
3321+
.current_dir(&dir)
3322+
.run(builder);
3323+
}
3324+
33013325
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
33023326
pub struct Bootstrap;
33033327

0 commit comments

Comments
 (0)