Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit fe90610

Browse files
committed
Check rustc-dev in distcheck
1 parent f19c33e commit fe90610

File tree

2 files changed

+50
-18
lines changed

2 files changed

+50
-18
lines changed

‎src/bootstrap/src/core/build_steps/dist.rs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -823,6 +823,18 @@ pub struct RustcDev {
823823
target: TargetSelection,
824824
}
825825

826+
impl RustcDev {
827+
pub fn new(builder: &Builder<'_>, target: TargetSelection) -> Self {
828+
Self {
829+
// We currently always ship a stage 2 rustc-dev component, so we build it with the
830+
// stage 1 compiler. This might change in the future.
831+
// The precise stage used here is important, so we hard-code it.
832+
build_compiler: builder.compiler(1, builder.config.host_target),
833+
target,
834+
}
835+
}
836+
}
837+
826838
impl Step for RustcDev {
827839
type Output = Option<GeneratedTarball>;
828840
const DEFAULT: bool = true;
@@ -833,13 +845,7 @@ impl Step for RustcDev {
833845
}
834846

835847
fn make_run(run: RunConfig<'_>) {
836-
run.builder.ensure(RustcDev {
837-
// We currently always ship a stage 2 rustc-dev component, so we build it with the
838-
// stage 1 compiler. This might change in the future.
839-
// The precise stage used here is important, so we hard-code it.
840-
build_compiler: run.builder.compiler(1, run.builder.config.host_target),
841-
target: run.target,
842-
});
848+
run.builder.ensure(RustcDev::new(run.builder, run.target));
843849
}
844850

845851
fn run(self, builder: &Builder<'_>) -> Option<GeneratedTarball> {

‎src/bootstrap/src/core/build_steps/test.rs

Lines changed: 37 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -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
31973200
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
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
32293232
fn 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

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /