about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorJakub Beránek <berykubik@gmail.com>2025-09-02 17:02:48 +0200
committerJakub Beránek <berykubik@gmail.com>2025-09-03 15:30:42 +0200
commitfe90610e1a3dc3b85894f9fd2f567ad3b3376c85 (patch)
tree64f78fd2bc16381eb45bf960ab2e2b8103ba5892 /src
parentf19c33e4eed884f0199b4e3924a8011a34f5e21c (diff)
downloadrust-fe90610e1a3dc3b85894f9fd2f567ad3b3376c85.tar.gz
rust-fe90610e1a3dc3b85894f9fd2f567ad3b3376c85.zip
Check `rustc-dev` in `distcheck`
Diffstat (limited to 'src')
-rw-r--r--src/bootstrap/src/core/build_steps/dist.rs20
-rw-r--r--src/bootstrap/src/core/build_steps/test.rs48
2 files changed, 50 insertions, 18 deletions
diff --git a/src/bootstrap/src/core/build_steps/dist.rs b/src/bootstrap/src/core/build_steps/dist.rs
index f113dd7683d..820dda5a652 100644
--- a/src/bootstrap/src/core/build_steps/dist.rs
+++ b/src/bootstrap/src/core/build_steps/dist.rs
@@ -823,6 +823,18 @@ pub struct RustcDev {
     target: TargetSelection,
 }
 
+impl RustcDev {
+    pub fn new(builder: &Builder<'_>, target: TargetSelection) -> Self {
+        Self {
+            // We currently always ship a stage 2 rustc-dev component, so we build it with the
+            // stage 1 compiler. This might change in the future.
+            // The precise stage used here is important, so we hard-code it.
+            build_compiler: builder.compiler(1, builder.config.host_target),
+            target,
+        }
+    }
+}
+
 impl Step for RustcDev {
     type Output = Option<GeneratedTarball>;
     const DEFAULT: bool = true;
@@ -833,13 +845,7 @@ impl Step for RustcDev {
     }
 
     fn make_run(run: RunConfig<'_>) {
-        run.builder.ensure(RustcDev {
-            // We currently always ship a stage 2 rustc-dev component, so we build it with the
-            // stage 1 compiler. This might change in the future.
-            // The precise stage used here is important, so we hard-code it.
-            build_compiler: run.builder.compiler(1, run.builder.config.host_target),
-            target: run.target,
-        });
+        run.builder.ensure(RustcDev::new(run.builder, run.target));
     }
 
     fn run(self, builder: &Builder<'_>) -> Option<GeneratedTarball> {
diff --git a/src/bootstrap/src/core/build_steps/test.rs b/src/bootstrap/src/core/build_steps/test.rs
index f5faa32defd..403d5372783 100644
--- a/src/bootstrap/src/core/build_steps/test.rs
+++ b/src/bootstrap/src/core/build_steps/test.rs
@@ -3182,6 +3182,7 @@ impl Step for Distcheck {
     ///   check steps from those sources.
     /// - Check that selected dist components (`rust-src` only at the moment) at least have expected
     ///   directory shape and crate manifests that cargo can generate a lockfile from.
+    /// - Check that we can run `cargo metadata` on the workspace in the `rustc-dev` component
     ///
     /// FIXME(#136822): dist components are under-tested.
     fn run(self, builder: &Builder<'_>) {
@@ -3189,16 +3190,17 @@ impl Step for Distcheck {
         // local source code, built artifacts or configuration by accident
         let root_dir = std::env::temp_dir().join("distcheck");
 
-        distcheck_plain_source_tarball(builder, &root_dir.join("distcheck-plain-src"));
-        distcheck_rust_src(builder, &root_dir.join("distcheck-src"));
+        distcheck_plain_source_tarball(builder, &root_dir.join("distcheck-rustc-src"));
+        distcheck_rust_src(builder, &root_dir.join("distcheck-rust-src"));
+        distcheck_rustc_dev(builder, &root_dir.join("distcheck-rustc-dev"));
     }
 }
 
+/// Check that we can build some basic things from the plain source tarball
 fn distcheck_plain_source_tarball(builder: &Builder<'_>, plain_src_dir: &Path) {
-    // Check that we can build some basic things from the plain source tarball
     builder.info("Distcheck plain source tarball");
     let plain_src_tarball = builder.ensure(dist::PlainSourceTarball);
-    builder.clear_dir(&plain_src_dir);
+    builder.clear_dir(plain_src_dir);
 
     let configure_args: Vec<String> = std::env::var("DISTCHECK_CONFIGURE_ARGS")
         .map(|args| args.split(" ").map(|s| s.to_string()).collect::<Vec<String>>())
@@ -3208,35 +3210,35 @@ fn distcheck_plain_source_tarball(builder: &Builder<'_>, plain_src_dir: &Path) {
         .arg("-xf")
         .arg(plain_src_tarball.tarball())
         .arg("--strip-components=1")
-        .current_dir(&plain_src_dir)
+        .current_dir(plain_src_dir)
         .run(builder);
     command("./configure")
         .arg("--set")
         .arg("rust.omit-git-hash=false")
         .args(&configure_args)
         .arg("--enable-vendor")
-        .current_dir(&plain_src_dir)
+        .current_dir(plain_src_dir)
         .run(builder);
     command(helpers::make(&builder.config.host_target.triple))
         .arg("check")
         // Do not run the build as if we were in CI, otherwise git would be assumed to be
         // present, but we build from a tarball here
         .env("GITHUB_ACTIONS", "0")
-        .current_dir(&plain_src_dir)
+        .current_dir(plain_src_dir)
         .run(builder);
 }
 
+/// Check that rust-src has all of libstd's dependencies
 fn distcheck_rust_src(builder: &Builder<'_>, src_dir: &Path) {
-    // Now make sure that rust-src has all of libstd's dependencies
     builder.info("Distcheck rust-src");
     let src_tarball = builder.ensure(dist::Src);
-    builder.clear_dir(&src_dir);
+    builder.clear_dir(src_dir);
 
     command("tar")
         .arg("-xf")
         .arg(src_tarball.tarball())
         .arg("--strip-components=1")
-        .current_dir(&src_dir)
+        .current_dir(src_dir)
         .run(builder);
 
     let toml = src_dir.join("rust-src/lib/rustlib/src/rust/library/std/Cargo.toml");
@@ -3247,7 +3249,31 @@ fn distcheck_rust_src(builder: &Builder<'_>, src_dir: &Path) {
         .arg("generate-lockfile")
         .arg("--manifest-path")
         .arg(&toml)
-        .current_dir(&src_dir)
+        .current_dir(src_dir)
+        .run(builder);
+}
+
+/// Check that rustc-dev's compiler crate source code can be loaded with `cargo metadata`
+fn distcheck_rustc_dev(builder: &Builder<'_>, dir: &Path) {
+    builder.info("Distcheck rustc-dev");
+    let tarball = builder.ensure(dist::RustcDev::new(builder, builder.host_target)).unwrap();
+    builder.clear_dir(dir);
+
+    command("tar")
+        .arg("-xf")
+        .arg(tarball.tarball())
+        .arg("--strip-components=1")
+        .current_dir(dir)
+        .run(builder);
+
+    command(&builder.initial_cargo)
+        .arg("metadata")
+        .arg("--manifest-path")
+        .arg("rustc-dev/lib/rustlib/rustc-src/rust/compiler/rustc/Cargo.toml")
+        .env("RUSTC_BOOTSTRAP", "1")
+        // We might not have a globally available `rustc` binary on CI
+        .env("RUSTC", &builder.initial_rustc)
+        .current_dir(dir)
         .run(builder);
 }