@@ -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.
0 commit comments