Skip to content

Commit ccf94e2

Browse files
committed
Add dist step for Enzyme
1 parent 08c63fc commit ccf94e2

File tree

3 files changed

+53
-0
lines changed

3 files changed

+53
-0
lines changed

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

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2592,6 +2592,55 @@ impl Step for LlvmBitcodeLinker {
25922592
}
25932593
}
25942594

2595+
/// Distributes the `enzyme` library so that it can be used by a compiler whose host
2596+
/// is `target`.
2597+
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
2598+
pub struct Enzyme {
2599+
/// Enzyme will by usable by rustc on this host.
2600+
pub target: TargetSelection,
2601+
}
2602+
2603+
impl Step for Enzyme {
2604+
type Output = Option<GeneratedTarball>;
2605+
const IS_HOST: bool = true;
2606+
2607+
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
2608+
run.alias("enzyme")
2609+
}
2610+
2611+
fn is_default_step(builder: &Builder<'_>) -> bool {
2612+
builder.config.llvm_enzyme
2613+
}
2614+
2615+
fn make_run(run: RunConfig<'_>) {
2616+
run.builder.ensure(Enzyme { target: run.target });
2617+
}
2618+
2619+
fn run(self, builder: &Builder<'_>) -> Option<GeneratedTarball> {
2620+
// This prevents Enzyme from being built for "dist"
2621+
// or "install" on the stable/beta channels. It is not yet stable and
2622+
// should not be included.
2623+
if !builder.build.unstable_features() {
2624+
return None;
2625+
}
2626+
2627+
let target = self.target;
2628+
2629+
let enzyme = builder.ensure(llvm::Enzyme { target });
2630+
2631+
let target_libdir = format!("lib/rustlib/{}/lib", target.triple);
2632+
2633+
// Prepare the image directory
2634+
let mut tarball = Tarball::new(builder, "enzyme", &target.triple);
2635+
tarball.set_overlay(OverlayKind::Enzyme);
2636+
tarball.is_preview(true);
2637+
2638+
tarball.add_file(enzyme.enzyme_path(), target_libdir, FileType::NativeLibrary);
2639+
2640+
Some(tarball.generate())
2641+
}
2642+
}
2643+
25952644
/// Tarball intended for internal consumption to ease rustc/std development.
25962645
///
25972646
/// 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
@@ -979,6 +979,7 @@ impl<'a> Builder<'a> {
979979
dist::LlvmTools,
980980
dist::LlvmBitcodeLinker,
981981
dist::RustDev,
982+
dist::Enzyme,
982983
dist::Bootstrap,
983984
dist::Extended,
984985
// 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
@@ -26,6 +26,7 @@ pub(crate) enum OverlayKind {
2626
RustAnalyzer,
2727
RustcCodegenCranelift,
2828
LlvmBitcodeLinker,
29+
Enzyme,
2930
}
3031

3132
impl OverlayKind {
@@ -35,6 +36,7 @@ impl OverlayKind {
3536
OverlayKind::Llvm => {
3637
&["src/llvm-project/llvm/LICENSE.TXT", "src/llvm-project/llvm/README.txt"]
3738
}
39+
OverlayKind::Enzyme => &["src/tools/enzyme/LICENSE", "src/tools/enzyme/Readme.md"],
3840
OverlayKind::Cargo => &[
3941
"src/tools/cargo/README.md",
4042
"src/tools/cargo/LICENSE-MIT",
@@ -94,6 +96,7 @@ impl OverlayKind {
9496
.version(builder, &builder.release_num("rust-analyzer/crates/rust-analyzer")),
9597
OverlayKind::RustcCodegenCranelift => builder.rust_version(),
9698
OverlayKind::LlvmBitcodeLinker => builder.rust_version(),
99+
OverlayKind::Enzyme => builder.rust_version(),
97100
}
98101
}
99102
}

0 commit comments

Comments
 (0)