@@ -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,14 +3239,15 @@ 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
32443247fn 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 ) ;
3248- builder. clear_dir ( & plain_src_dir) ;
3250+ builder. clear_dir ( plain_src_dir) ;
32493251
32503252 let configure_args: Vec < String > = std:: env:: var ( "DISTCHECK_CONFIGURE_ARGS" )
32513253 . map ( |args| args. split ( " " ) . map ( |s| s. to_string ( ) ) . collect :: < Vec < String > > ( ) )
@@ -3255,35 +3257,35 @@ fn distcheck_plain_source_tarball(builder: &Builder<'_>, plain_src_dir: &Path) {
32553257 . arg ( "-xf" )
32563258 . arg ( plain_src_tarball. tarball ( ) )
32573259 . arg ( "--strip-components=1" )
3258- . current_dir ( & plain_src_dir)
3260+ . current_dir ( plain_src_dir)
32593261 . run ( builder) ;
32603262 command ( "./configure" )
32613263 . arg ( "--set" )
32623264 . arg ( "rust.omit-git-hash=false" )
32633265 . args ( & configure_args)
32643266 . arg ( "--enable-vendor" )
3265- . current_dir ( & plain_src_dir)
3267+ . current_dir ( plain_src_dir)
32663268 . run ( builder) ;
32673269 command ( helpers:: make ( & builder. config . host_target . triple ) )
32683270 . arg ( "check" )
32693271 // Do not run the build as if we were in CI, otherwise git would be assumed to be
32703272 // present, but we build from a tarball here
32713273 . env ( "GITHUB_ACTIONS" , "0" )
3272- . current_dir ( & plain_src_dir)
3274+ . current_dir ( plain_src_dir)
32733275 . run ( builder) ;
32743276}
32753277
3278+ /// Check that rust-src has all of libstd's dependencies
32763279fn 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 ) ;
3280- builder. clear_dir ( & src_dir) ;
3282+ builder. clear_dir ( src_dir) ;
32813283
32823284 command ( "tar" )
32833285 . arg ( "-xf" )
32843286 . arg ( src_tarball. tarball ( ) )
32853287 . arg ( "--strip-components=1" )
3286- . current_dir ( & src_dir)
3288+ . current_dir ( src_dir)
32873289 . run ( builder) ;
32883290
32893291 let toml = src_dir. join ( "rust-src/lib/rustlib/src/rust/library/std/Cargo.toml" ) ;
@@ -3294,7 +3296,29 @@ fn distcheck_rust_src(builder: &Builder<'_>, src_dir: &Path) {
32943296 . arg ( "generate-lockfile" )
32953297 . arg ( "--manifest-path" )
32963298 . arg ( & toml)
3297- . current_dir ( & src_dir)
3299+ . current_dir ( src_dir)
3300+ . run ( builder) ;
3301+ }
3302+
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)
32983322 . run ( builder) ;
32993323}
33003324
0 commit comments