Skip to content

Commit aa4554f

Browse files
Dedicated rust development tarball
This currently includes libLLVM, llvm-config, and FileCheck, but will perhaps expand to more tooling overtime. It should be considered entirely unstable and may change at any time.
1 parent f76eda3 commit aa4554f

File tree

2 files changed

+83
-0
lines changed

2 files changed

+83
-0
lines changed

src/bootstrap/builder.rs

+1
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,7 @@ impl<'a> Builder<'a> {
471471
dist::Clippy,
472472
dist::Miri,
473473
dist::LlvmTools,
474+
dist::RustDev,
474475
dist::Extended,
475476
dist::HashSign
476477
),

src/bootstrap/dist.rs

+82
Original file line numberDiff line numberDiff line change
@@ -2499,3 +2499,85 @@ impl Step for LlvmTools {
24992499
Some(distdir(builder).join(format!("{}-{}.tar.gz", name, target.triple)))
25002500
}
25012501
}
2502+
2503+
// Tarball intended for internal consumption to ease rustc/std development.
2504+
//
2505+
// Should not be considered stable by end users.
2506+
#[derive(Clone, Debug, Eq, Hash, PartialEq)]
2507+
pub struct RustDev {
2508+
pub target: TargetSelection,
2509+
}
2510+
2511+
impl Step for RustDev {
2512+
type Output = Option<PathBuf>;
2513+
const DEFAULT: bool = true;
2514+
const ONLY_HOSTS: bool = true;
2515+
2516+
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
2517+
run.path("rust-dev")
2518+
}
2519+
2520+
fn make_run(run: RunConfig<'_>) {
2521+
run.builder.ensure(RustDev { target: run.target });
2522+
}
2523+
2524+
fn run(self, builder: &Builder<'_>) -> Option<PathBuf> {
2525+
let target = self.target;
2526+
2527+
builder.info(&format!("Dist RustDev ({})", target));
2528+
let _time = timeit(builder);
2529+
let src = builder.src.join("src/llvm-project/llvm");
2530+
let name = pkgname(builder, "rust-dev");
2531+
2532+
let tmp = tmpdir(builder);
2533+
let image = tmp.join("rust-dev-image");
2534+
drop(fs::remove_dir_all(&image));
2535+
2536+
// Prepare the image directory
2537+
let dst_bindir = image.join("bin");
2538+
t!(fs::create_dir_all(&dst_bindir));
2539+
let exe = builder.llvm_out(target).join("bin").join(exe("llvm-config", target));
2540+
builder.install(&exe, &dst_bindir, 0o755);
2541+
builder.install(&builder.llvm_filecheck(target), &dst_bindir, 0o755);
2542+
2543+
// Copy the include directory as well; needed mostly to build
2544+
// librustc_llvm properly (e.g., llvm-config.h is in here). But also
2545+
// just broadly useful to be able to link against the bundled LLVM.
2546+
builder.cp_r(&builder.llvm_out(target).join("include"), &image.join("include"));
2547+
2548+
// Copy libLLVM.so to the target lib dir as well, so the RPATH like
2549+
// `$ORIGIN/../lib` can find it. It may also be used as a dependency
2550+
// of `rustc-dev` to support the inherited `-lLLVM` when using the
2551+
// compiler libraries.
2552+
maybe_install_llvm(builder, target, &image.join("lib"));
2553+
2554+
// Prepare the overlay
2555+
let overlay = tmp.join("rust-dev-overlay");
2556+
drop(fs::remove_dir_all(&overlay));
2557+
builder.create_dir(&overlay);
2558+
builder.install(&src.join("README.txt"), &overlay, 0o644);
2559+
builder.install(&src.join("LICENSE.TXT"), &overlay, 0o644);
2560+
builder.create(&overlay.join("version"), &builder.rust_version());
2561+
2562+
// Generate the installer tarball
2563+
let mut cmd = rust_installer(builder);
2564+
cmd.arg("generate")
2565+
.arg("--product-name=Rust")
2566+
.arg("--rel-manifest-dir=rustlib")
2567+
.arg("--success-message=rust-dev-installed.")
2568+
.arg("--image-dir")
2569+
.arg(&image)
2570+
.arg("--work-dir")
2571+
.arg(&tmpdir(builder))
2572+
.arg("--output-dir")
2573+
.arg(&distdir(builder))
2574+
.arg("--non-installed-overlay")
2575+
.arg(&overlay)
2576+
.arg(format!("--package-name={}-{}", name, target.triple))
2577+
.arg("--legacy-manifest-dirs=rustlib,cargo")
2578+
.arg("--component-name=rust-dev");
2579+
2580+
builder.run(&mut cmd);
2581+
Some(distdir(builder).join(format!("{}-{}.tar.gz", name, target.triple)))
2582+
}
2583+
}

0 commit comments

Comments
 (0)