@@ -3182,23 +3182,25 @@ impl Step for Distcheck {
3182
3182
/// check steps from those sources.
3183
3183
/// - Check that selected dist components (`rust-src` only at the moment) at least have expected
3184
3184
/// 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
3185
3186
///
3186
3187
/// FIXME(#136822): dist components are under-tested.
3187
3188
fn run ( self , builder : & Builder < ' _ > ) {
3188
3189
// Use a temporary directory completely outside the current checkout, to avoid reusing any
3189
3190
// local source code, built artifacts or configuration by accident
3190
3191
let root_dir = std:: env:: temp_dir ( ) . join ( "distcheck" ) ;
3191
3192
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" ) ) ;
3194
3196
}
3195
3197
}
3196
3198
3199
+ /// Check that we can build some basic things from the plain source tarball
3197
3200
fn distcheck_plain_source_tarball ( builder : & Builder < ' _ > , plain_src_dir : & Path ) {
3198
- // Check that we can build some basic things from the plain source tarball
3199
3201
builder. info ( "Distcheck plain source tarball" ) ;
3200
3202
let plain_src_tarball = builder. ensure ( dist:: PlainSourceTarball ) ;
3201
- builder. clear_dir ( & plain_src_dir) ;
3203
+ builder. clear_dir ( plain_src_dir) ;
3202
3204
3203
3205
let configure_args: Vec < String > = std:: env:: var ( "DISTCHECK_CONFIGURE_ARGS" )
3204
3206
. 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) {
3208
3210
. arg ( "-xf" )
3209
3211
. arg ( plain_src_tarball. tarball ( ) )
3210
3212
. arg ( "--strip-components=1" )
3211
- . current_dir ( & plain_src_dir)
3213
+ . current_dir ( plain_src_dir)
3212
3214
. run ( builder) ;
3213
3215
command ( "./configure" )
3214
3216
. arg ( "--set" )
3215
3217
. arg ( "rust.omit-git-hash=false" )
3216
3218
. args ( & configure_args)
3217
3219
. arg ( "--enable-vendor" )
3218
- . current_dir ( & plain_src_dir)
3220
+ . current_dir ( plain_src_dir)
3219
3221
. run ( builder) ;
3220
3222
command ( helpers:: make ( & builder. config . host_target . triple ) )
3221
3223
. arg ( "check" )
3222
3224
// Do not run the build as if we were in CI, otherwise git would be assumed to be
3223
3225
// present, but we build from a tarball here
3224
3226
. env ( "GITHUB_ACTIONS" , "0" )
3225
- . current_dir ( & plain_src_dir)
3227
+ . current_dir ( plain_src_dir)
3226
3228
. run ( builder) ;
3227
3229
}
3228
3230
3231
+ /// Check that rust-src has all of libstd's dependencies
3229
3232
fn distcheck_rust_src ( builder : & Builder < ' _ > , src_dir : & Path ) {
3230
- // Now make sure that rust-src has all of libstd's dependencies
3231
3233
builder. info ( "Distcheck rust-src" ) ;
3232
3234
let src_tarball = builder. ensure ( dist:: Src ) ;
3233
- builder. clear_dir ( & src_dir) ;
3235
+ builder. clear_dir ( src_dir) ;
3234
3236
3235
3237
command ( "tar" )
3236
3238
. arg ( "-xf" )
3237
3239
. arg ( src_tarball. tarball ( ) )
3238
3240
. arg ( "--strip-components=1" )
3239
- . current_dir ( & src_dir)
3241
+ . current_dir ( src_dir)
3240
3242
. run ( builder) ;
3241
3243
3242
3244
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) {
3247
3249
. arg ( "generate-lockfile" )
3248
3250
. arg ( "--manifest-path" )
3249
3251
. 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)
3251
3277
. run ( builder) ;
3252
3278
}
3253
3279
0 commit comments