From b398a7254fe652a302e88bb66fe96c3d11bba5ab Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Sat, 30 Jul 2022 18:17:35 -0400 Subject: [PATCH 1/2] Publish compiletest as a rustc-tools component --- src/bootstrap/builder.rs | 1 + src/bootstrap/dist.rs | 41 ++++++++++++++++++++++++++++ src/tools/build-manifest/src/main.rs | 5 +++- 3 files changed, 46 insertions(+), 1 deletion(-) diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index 0ab4824ac0a73..9cad5a95904b4 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -724,6 +724,7 @@ impl<'a> Builder<'a> { dist::LlvmTools, dist::RustDev, dist::Extended, + dist::RustcTools, // It seems that PlainSourceTarball somehow changes how some of the tools // perceive their dependencies (see #93033) which would invalidate fingerprints // and force us to rebuild tools after vendoring dependencies. diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs index 6291b204e485f..5ccdd6319a523 100644 --- a/src/bootstrap/dist.rs +++ b/src/bootstrap/dist.rs @@ -2006,6 +2006,47 @@ impl Step for LlvmTools { } } +/// This tarball contains tools useful inside/outside the rustc tree (today just +/// compiletest). This is separate from the rust-dev tarball packaged below +/// because that contains a full LLVM and in practice keeping that separate +/// makes a lot of sense (it's probably worth renaming that tarball but that +/// takes some work to do). We also publish this component on nightly, so that +/// consumers (like clippy) can make use of it. +#[derive(Clone, Debug, Eq, Hash, PartialEq)] +pub struct RustcTools { + pub target: TargetSelection, +} + +impl Step for RustcTools { + type Output = Option; + const ONLY_HOSTS: bool = true; + const DEFAULT: bool = true; + + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { + let default = should_build_extended_tool(&run.builder, "rustc-tools"); + run.alias("rustc-tools").default_condition(default) + } + + fn make_run(run: RunConfig<'_>) { + run.builder.ensure(RustcTools { target: run.target }); + } + + fn run(self, builder: &Builder<'_>) -> Option { + let target = self.target; + + let mut tarball = Tarball::new(builder, "rustc-tools", &target.triple); + tarball.set_overlay(OverlayKind::Rust); + tarball.is_preview(true); + + // We place compiletest in rustlib since it shouldn't be directly run, + // only through some wrapper tool. + let dst_bindir = format!("lib/rustlib/{}/bin", target.triple); + tarball.add_file(builder.tool_exe(tool::Tool::Compiletest), &dst_bindir, 0o755); + + Some(tarball.generate()) + } +} + // Tarball intended for internal consumption to ease rustc/std development. // // Should not be considered stable by end users. diff --git a/src/tools/build-manifest/src/main.rs b/src/tools/build-manifest/src/main.rs index efe3f2b618be3..7fbcb29b5ed8e 100644 --- a/src/tools/build-manifest/src/main.rs +++ b/src/tools/build-manifest/src/main.rs @@ -184,7 +184,7 @@ static PKG_INSTALLERS: &[&str] = &["x86_64-apple-darwin", "aarch64-apple-darwin" static MINGW: &[&str] = &["i686-pc-windows-gnu", "x86_64-pc-windows-gnu"]; -static NIGHTLY_ONLY_COMPONENTS: &[&str] = &["miri-preview"]; +static NIGHTLY_ONLY_COMPONENTS: &[&str] = &["miri-preview", "rustc-tools-preview"]; macro_rules! t { ($e:expr) => { @@ -323,6 +323,7 @@ impl Builder { package!("rust-analyzer-preview", HOSTS); package!("clippy-preview", HOSTS); package!("miri-preview", HOSTS); + package!("rustc-tools-preview", HOSTS); package!("rustfmt-preview", HOSTS); package!("rust-analysis", TARGETS); package!("llvm-tools-preview", TARGETS); @@ -403,6 +404,7 @@ impl Builder { rename("rustfmt", "rustfmt-preview"); rename("clippy", "clippy-preview"); rename("miri", "miri-preview"); + rename("rustc-tools", "rustc-tools-preview"); rename("rust-analyzer", "rust-analyzer-preview"); } @@ -454,6 +456,7 @@ impl Builder { extensions.extend(vec![ host_component("clippy-preview"), host_component("miri-preview"), + host_component("rustc-tools-preview"), host_component("rls-preview"), host_component("rust-analyzer-preview"), host_component("rustfmt-preview"), From 9223b0c7e5e8f33544f2babfcfaebd85f7378436 Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Sun, 31 Jul 2022 11:31:07 -0400 Subject: [PATCH 2/2] Improve assertion error in build-manifest --- src/tools/build-manifest/src/main.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/tools/build-manifest/src/main.rs b/src/tools/build-manifest/src/main.rs index 7fbcb29b5ed8e..05e913bb1cdc7 100644 --- a/src/tools/build-manifest/src/main.rs +++ b/src/tools/build-manifest/src/main.rs @@ -547,7 +547,12 @@ impl Builder { if target_name.contains(substr) { let t = Target::from_compressed_tar(self, &tarball_name!(fallback_target)); // Fallbacks must always be available. - assert!(t.available); + assert!( + t.available, + "{} fallback for {} not available", + tarball_name!(target_name), + tarball_name!(fallback_target) + ); return t; } }