@@ -3182,23 +3182,25 @@ impl Step for Distcheck {
31823182 /// check steps from those sources.
31833183 /// - Check that selected dist components (`rust-src` only at the moment) at least have expected
31843184 /// directory shape and crate manifests that cargo can generate a lockfile from.
3185+ /// - Check that we can run `cargo metadata` on the workspace in the `rustc-dev` component
31853186 ///
31863187 /// FIXME(#136822): dist components are under-tested.
31873188 fn run ( self , builder : & Builder < ' _ > ) {
31883189 // Use a temporary directory completely outside the current checkout, to avoid reusing any
31893190 // local source code, built artifacts or configuration by accident
31903191 let root_dir = std:: env:: temp_dir ( ) . join ( "distcheck" ) ;
31913192
3192- distcheck_plain_source_tarball ( builder, & root_dir. join ( "distcheck-plain-src" ) ) ;
3193- distcheck_rust_src ( builder, & root_dir. join ( "distcheck-src" ) ) ;
3193+ distcheck_plain_source_tarball ( builder, & root_dir. join ( "distcheck-rustc-src" ) ) ;
3194+ distcheck_rust_src ( builder, & root_dir. join ( "distcheck-rust-src" ) ) ;
3195+ distcheck_rustc_dev ( builder, & root_dir. join ( "distcheck-rustc-dev" ) ) ;
31943196 }
31953197}
31963198
3199+ /// Check that we can build some basic things from the plain source tarball
31973200fn distcheck_plain_source_tarball ( builder : & Builder < ' _ > , plain_src_dir : & Path ) {
3198- // Check that we can build some basic things from the plain source tarball
31993201 builder. info ( "Distcheck plain source tarball" ) ;
32003202 let plain_src_tarball = builder. ensure ( dist:: PlainSourceTarball ) ;
3201- builder. clear_dir ( & plain_src_dir) ;
3203+ builder. clear_dir ( plain_src_dir) ;
32023204
32033205 let configure_args: Vec < String > = std:: env:: var ( "DISTCHECK_CONFIGURE_ARGS" )
32043206 . 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) {
32083210 . arg ( "-xf" )
32093211 . arg ( plain_src_tarball. tarball ( ) )
32103212 . arg ( "--strip-components=1" )
3211- . current_dir ( & plain_src_dir)
3213+ . current_dir ( plain_src_dir)
32123214 . run ( builder) ;
32133215 command ( "./configure" )
32143216 . arg ( "--set" )
32153217 . arg ( "rust.omit-git-hash=false" )
32163218 . args ( & configure_args)
32173219 . arg ( "--enable-vendor" )
3218- . current_dir ( & plain_src_dir)
3220+ . current_dir ( plain_src_dir)
32193221 . run ( builder) ;
32203222 command ( helpers:: make ( & builder. config . host_target . triple ) )
32213223 . arg ( "check" )
32223224 // Do not run the build as if we were in CI, otherwise git would be assumed to be
32233225 // present, but we build from a tarball here
32243226 . env ( "GITHUB_ACTIONS" , "0" )
3225- . current_dir ( & plain_src_dir)
3227+ . current_dir ( plain_src_dir)
32263228 . run ( builder) ;
32273229}
32283230
3231+ /// Check that rust-src has all of libstd's dependencies
32293232fn distcheck_rust_src ( builder : & Builder < ' _ > , src_dir : & Path ) {
3230- // Now make sure that rust-src has all of libstd's dependencies
32313233 builder. info ( "Distcheck rust-src" ) ;
32323234 let src_tarball = builder. ensure ( dist:: Src ) ;
3233- builder. clear_dir ( & src_dir) ;
3235+ builder. clear_dir ( src_dir) ;
32343236
32353237 command ( "tar" )
32363238 . arg ( "-xf" )
32373239 . arg ( src_tarball. tarball ( ) )
32383240 . arg ( "--strip-components=1" )
3239- . current_dir ( & src_dir)
3241+ . current_dir ( src_dir)
32403242 . run ( builder) ;
32413243
32423244 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) {
32473249 . arg ( "generate-lockfile" )
32483250 . arg ( "--manifest-path" )
32493251 . arg ( & toml)
3250- . current_dir ( & src_dir)
3252+ . current_dir ( src_dir)
3253+ . run ( builder) ;
3254+ }
3255+
3256+ /// Check that rustc-dev's compiler crate source code can be loaded with `cargo metadata`
3257+ fn distcheck_rustc_dev ( builder : & Builder < ' _ > , dir : & Path ) {
3258+ builder. info ( "Distcheck rustc-dev" ) ;
3259+ let tarball = builder. ensure ( dist:: RustcDev :: new ( builder, builder. host_target ) ) . unwrap ( ) ;
3260+ builder. clear_dir ( dir) ;
3261+
3262+ command ( "tar" )
3263+ . arg ( "-xf" )
3264+ . arg ( tarball. tarball ( ) )
3265+ . arg ( "--strip-components=1" )
3266+ . current_dir ( dir)
3267+ . run ( builder) ;
3268+
3269+ command ( & builder. initial_cargo )
3270+ . arg ( "metadata" )
3271+ . arg ( "--manifest-path" )
3272+ . arg ( "rustc-dev/lib/rustlib/rustc-src/rust/compiler/rustc/Cargo.toml" )
3273+ . env ( "RUSTC_BOOTSTRAP" , "1" )
3274+ // We might not have a globally available `rustc` binary on CI
3275+ . env ( "RUSTC" , & builder. initial_rustc )
3276+ . current_dir ( dir)
32513277 . run ( builder) ;
32523278}
32533279
0 commit comments