Add dist step for Enzyme

This commit is contained in:
Jakub Beránek 2025-12-16 21:55:56 +01:00
parent 316627ee24
commit 85e01e3c4e
No known key found for this signature in database
GPG key ID: 909CD0D26483516B
3 changed files with 53 additions and 0 deletions

View file

@ -2717,6 +2717,55 @@ impl Step for LlvmBitcodeLinker {
}
}
/// Distributes the `enzyme` library so that it can be used by a compiler whose host
/// is `target`.
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
pub struct Enzyme {
/// Enzyme will by usable by rustc on this host.
pub target: TargetSelection,
}
impl Step for Enzyme {
type Output = Option<GeneratedTarball>;
const IS_HOST: bool = true;
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
run.alias("enzyme")
}
fn is_default_step(builder: &Builder<'_>) -> bool {
builder.config.llvm_enzyme
}
fn make_run(run: RunConfig<'_>) {
run.builder.ensure(Enzyme { target: run.target });
}
fn run(self, builder: &Builder<'_>) -> Option<GeneratedTarball> {
// This prevents Enzyme from being built for "dist"
// or "install" on the stable/beta channels. It is not yet stable and
// should not be included.
if !builder.build.unstable_features() {
return None;
}
let target = self.target;
let enzyme = builder.ensure(llvm::Enzyme { target });
let target_libdir = format!("lib/rustlib/{}/lib", target.triple);
// Prepare the image directory
let mut tarball = Tarball::new(builder, "enzyme", &target.triple);
tarball.set_overlay(OverlayKind::Enzyme);
tarball.is_preview(true);
tarball.add_file(enzyme.enzyme_path(), target_libdir, FileType::NativeLibrary);
Some(tarball.generate())
}
}
/// Tarball intended for internal consumption to ease rustc/std development.
///
/// Should not be considered stable by end users.

View file

@ -980,6 +980,7 @@ impl<'a> Builder<'a> {
dist::LlvmTools,
dist::LlvmBitcodeLinker,
dist::RustDev,
dist::Enzyme,
dist::Bootstrap,
dist::Extended,
// It seems that PlainSourceTarball somehow changes how some of the tools

View file

@ -28,6 +28,7 @@ pub(crate) enum OverlayKind {
RustcCodegenGcc,
Gcc,
LlvmBitcodeLinker,
Enzyme,
}
impl OverlayKind {
@ -37,6 +38,7 @@ impl OverlayKind {
OverlayKind::Llvm => {
&["src/llvm-project/llvm/LICENSE.TXT", "src/llvm-project/llvm/README.txt"]
}
OverlayKind::Enzyme => &["src/tools/enzyme/LICENSE", "src/tools/enzyme/Readme.md"],
OverlayKind::Cargo => &[
"src/tools/cargo/README.md",
"src/tools/cargo/LICENSE-MIT",
@ -111,6 +113,7 @@ impl OverlayKind {
OverlayKind::RustcCodegenGcc => builder.rust_version(),
OverlayKind::LlvmBitcodeLinker => builder.rust_version(),
OverlayKind::Gcc => builder.rust_version(),
OverlayKind::Enzyme => builder.rust_version(),
}
}
}