Skip to content

Commit 85e01e3

Browse files
committed
Add dist step for Enzyme
1 parent 316627e commit 85e01e3

3 files changed

Lines changed: 53 additions & 0 deletions

File tree

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

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2717,6 +2717,55 @@ impl Step for LlvmBitcodeLinker {
27172717
}
27182718
}
27192719

2720+
/// Distributes the `enzyme` library so that it can be used by a compiler whose host
2721+
/// is `target`.
2722+
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
2723+
pub struct Enzyme {
2724+
/// Enzyme will by usable by rustc on this host.
2725+
pub target: TargetSelection,
2726+
}
2727+
2728+
impl Step for Enzyme {
2729+
type Output = Option<GeneratedTarball>;
2730+
const IS_HOST: bool = true;
2731+
2732+
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
2733+
run.alias("enzyme")
2734+
}
2735+
2736+
fn is_default_step(builder: &Builder<'_>) -> bool {
2737+
builder.config.llvm_enzyme
2738+
}
2739+
2740+
fn make_run(run: RunConfig<'_>) {
2741+
run.builder.ensure(Enzyme { target: run.target });
2742+
}
2743+
2744+
fn run(self, builder: &Builder<'_>) -> Option<GeneratedTarball> {
2745+
// This prevents Enzyme from being built for "dist"
2746+
// or "install" on the stable/beta channels. It is not yet stable and
2747+
// should not be included.
2748+
if !builder.build.unstable_features() {
2749+
return None;
2750+
}
2751+
2752+
let target = self.target;
2753+
2754+
let enzyme = builder.ensure(llvm::Enzyme { target });
2755+
2756+
let target_libdir = format!("lib/rustlib/{}/lib", target.triple);
2757+
2758+
// Prepare the image directory
2759+
let mut tarball = Tarball::new(builder, "enzyme", &target.triple);
2760+
tarball.set_overlay(OverlayKind::Enzyme);
2761+
tarball.is_preview(true);
2762+
2763+
tarball.add_file(enzyme.enzyme_path(), target_libdir, FileType::NativeLibrary);
2764+
2765+
Some(tarball.generate())
2766+
}
2767+
}
2768+
27202769
/// Tarball intended for internal consumption to ease rustc/std development.
27212770
///
27222771
/// Should not be considered stable by end users.

src/bootstrap/src/core/builder/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -980,6 +980,7 @@ impl<'a> Builder<'a> {
980980
dist::LlvmTools,
981981
dist::LlvmBitcodeLinker,
982982
dist::RustDev,
983+
dist::Enzyme,
983984
dist::Bootstrap,
984985
dist::Extended,
985986
// It seems that PlainSourceTarball somehow changes how some of the tools

src/bootstrap/src/utils/tarball.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ pub(crate) enum OverlayKind {
2828
RustcCodegenGcc,
2929
Gcc,
3030
LlvmBitcodeLinker,
31+
Enzyme,
3132
}
3233

3334
impl OverlayKind {
@@ -37,6 +38,7 @@ impl OverlayKind {
3738
OverlayKind::Llvm => {
3839
&["src/llvm-project/llvm/LICENSE.TXT", "src/llvm-project/llvm/README.txt"]
3940
}
41+
OverlayKind::Enzyme => &["src/tools/enzyme/LICENSE", "src/tools/enzyme/Readme.md"],
4042
OverlayKind::Cargo => &[
4143
"src/tools/cargo/README.md",
4244
"src/tools/cargo/LICENSE-MIT",
@@ -111,6 +113,7 @@ impl OverlayKind {
111113
OverlayKind::RustcCodegenGcc => builder.rust_version(),
112114
OverlayKind::LlvmBitcodeLinker => builder.rust_version(),
113115
OverlayKind::Gcc => builder.rust_version(),
116+
OverlayKind::Enzyme => builder.rust_version(),
114117
}
115118
}
116119
}

0 commit comments

Comments
 (0)