@@ -3229,71 +3229,97 @@ 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 < ' _ > ) {
32353236 // Use a temporary directory completely outside the current checkout, to avoid reusing any
32363237 // local source code, built artifacts or configuration by accident
32373238 let root_dir = std:: env:: temp_dir ( ) . join ( "distcheck" ) ;
32383239
3239- // Check that we can build some basic things from the plain source tarball
3240- builder. info ( "Distcheck plain source tarball" ) ;
3241- let plain_src_tarball = builder. ensure ( dist:: PlainSourceTarball ) ;
3242- let plain_src_dir = root_dir. join ( "distcheck-plain-src" ) ;
3243- builder. clear_dir ( & plain_src_dir) ;
3244-
3245- let configure_args: Vec < String > = std:: env:: var ( "DISTCHECK_CONFIGURE_ARGS" )
3246- . map ( |args| args. split ( " " ) . map ( |s| s. to_string ( ) ) . collect :: < Vec < String > > ( ) )
3247- . unwrap_or_default ( ) ;
3248-
3249- // FIXME: unpack the source tarballs into a directory outside the source checkout, to
3250- // ensure that it cannot access any local state
3251- // Also ensure that it doesn't use download-ci-llvm
3252- command ( "tar" )
3253- . arg ( "-xf" )
3254- . arg ( plain_src_tarball. tarball ( ) )
3255- . arg ( "--strip-components=1" )
3256- . current_dir ( & plain_src_dir)
3257- . run ( builder) ;
3258- command ( "./configure" )
3259- . arg ( "--set" )
3260- . arg ( "rust.omit-git-hash=false" )
3261- . args ( & configure_args)
3262- . arg ( "--enable-vendor" )
3263- . current_dir ( & plain_src_dir)
3264- . run ( builder) ;
3265- command ( helpers:: make ( & builder. config . host_target . triple ) )
3266- . arg ( "check" )
3267- // Do not run the build as if we were in CI, otherwise git would be assumed to be
3268- // present, but we build from a tarball here
3269- . env ( "GITHUB_ACTIONS" , "0" )
3270- . current_dir ( & plain_src_dir)
3271- . run ( builder) ;
3272-
3273- // Now make sure that rust-src has all of libstd's dependencies
3274- builder. info ( "Distcheck rust-src" ) ;
3275- let src_tarball = builder. ensure ( dist:: Src ) ;
3276- let src_dir = root_dir. join ( "distcheck-src" ) ;
3277- builder. clear_dir ( & src_dir) ;
3278-
3279- command ( "tar" )
3280- . arg ( "-xf" )
3281- . arg ( src_tarball. tarball ( ) )
3282- . arg ( "--strip-components=1" )
3283- . current_dir ( & src_dir)
3284- . run ( builder) ;
3285-
3286- let toml = src_dir. join ( "rust-src/lib/rustlib/src/rust/library/std/Cargo.toml" ) ;
3287- command ( & builder. initial_cargo )
3288- // Will read the libstd Cargo.toml
3289- // which uses the unstable `public-dependency` feature.
3290- . env ( "RUSTC_BOOTSTRAP" , "1" )
3291- . arg ( "generate-lockfile" )
3292- . arg ( "--manifest-path" )
3293- . arg ( & toml)
3294- . current_dir ( & src_dir)
3295- . run ( builder) ;
3296- }
3240+ distcheck_plain_source_tarball ( builder, & root_dir. join ( "distcheck-plain-src" ) ) ;
3241+ distcheck_rust_src ( builder, & root_dir. join ( "distcheck-src" ) ) ;
3242+ distcheck_rustc_dev ( builder, & root_dir. join ( "distcheck-rustc-dev" ) ) ;
3243+ }
3244+ }
3245+
3246+ /// Check that we can build some basic things from the plain source tarball
3247+ fn distcheck_plain_source_tarball ( builder : & Builder < ' _ > , plain_src_dir : & Path ) {
3248+ builder. info ( "Distcheck plain source tarball" ) ;
3249+ let plain_src_tarball = builder. ensure ( dist:: PlainSourceTarball ) ;
3250+ builder. clear_dir ( & plain_src_dir) ;
3251+
3252+ let configure_args: Vec < String > = std:: env:: var ( "DISTCHECK_CONFIGURE_ARGS" )
3253+ . map ( |args| args. split ( " " ) . map ( |s| s. to_string ( ) ) . collect :: < Vec < String > > ( ) )
3254+ . unwrap_or_default ( ) ;
3255+
3256+ command ( "tar" )
3257+ . arg ( "-xf" )
3258+ . arg ( plain_src_tarball. tarball ( ) )
3259+ . arg ( "--strip-components=1" )
3260+ . current_dir ( & plain_src_dir)
3261+ . run ( builder) ;
3262+ command ( "./configure" )
3263+ . arg ( "--set" )
3264+ . arg ( "rust.omit-git-hash=false" )
3265+ . args ( & configure_args)
3266+ . arg ( "--enable-vendor" )
3267+ . current_dir ( & plain_src_dir)
3268+ . run ( builder) ;
3269+ command ( helpers:: make ( & builder. config . host_target . triple ) )
3270+ . arg ( "check" )
3271+ // Do not run the build as if we were in CI, otherwise git would be assumed to be
3272+ // present, but we build from a tarball here
3273+ . env ( "GITHUB_ACTIONS" , "0" )
3274+ . current_dir ( & plain_src_dir)
3275+ . run ( builder) ;
3276+ }
3277+
3278+ /// Check that rust-src has all of libstd's dependencies
3279+ fn distcheck_rust_src ( builder : & Builder < ' _ > , src_dir : & Path ) {
3280+ builder. info ( "Distcheck rust-src" ) ;
3281+ let src_tarball = builder. ensure ( dist:: Src ) ;
3282+ builder. clear_dir ( & src_dir) ;
3283+
3284+ command ( "tar" )
3285+ . arg ( "-xf" )
3286+ . arg ( src_tarball. tarball ( ) )
3287+ . arg ( "--strip-components=1" )
3288+ . current_dir ( & src_dir)
3289+ . run ( builder) ;
3290+
3291+ let toml = src_dir. join ( "rust-src/lib/rustlib/src/rust/library/std/Cargo.toml" ) ;
3292+ command ( & builder. initial_cargo )
3293+ // Will read the libstd Cargo.toml
3294+ // which uses the unstable `public-dependency` feature.
3295+ . env ( "RUSTC_BOOTSTRAP" , "1" )
3296+ . arg ( "generate-lockfile" )
3297+ . arg ( "--manifest-path" )
3298+ . arg ( & toml)
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)
3322+ . run ( builder) ;
32973323}
32983324
32993325#[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
0 commit comments