Skip to content

Commit a06caa7

Browse files
committed
make Enzyme build optional
1 parent 7b0d0f1 commit a06caa7

File tree

4 files changed

+16
-8
lines changed

4 files changed

+16
-8
lines changed

src/bootstrap/configure.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ def v(*args):
7272
o("optimize-llvm", "llvm.optimize", "build optimized LLVM")
7373
o("llvm-assertions", "llvm.assertions", "build LLVM with assertions")
7474
o("llvm-plugins", "llvm.plugins", "build LLVM with plugin interface")
75+
o("llvm-enzyme", "llvm.enzyme", "build LLVM with enzyme")
7576
o("debug-assertions", "rust.debug-assertions", "build with debugging assertions")
7677
o("debug-assertions-std", "rust.debug-assertions-std", "build the standard library with debugging assertions")
7778
o("overflow-checks", "rust.overflow-checks", "build with overflow checks")

src/bootstrap/src/core/build_steps/compile.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1638,12 +1638,11 @@ impl Step for Assemble {
16381638
}
16391639

16401640
// Build enzyme
1641-
let enzyme_install = Some(builder.ensure(llvm::Enzyme { target: build_compiler.host }));
1642-
//let enzyme_install = if builder.config.llvm_enzyme {
1643-
// Some(builder.ensure(llvm::Enzyme { target: build_compiler.host }))
1644-
//} else {
1645-
// None
1646-
//};
1641+
let enzyme_install = if builder.config.llvm_enzyme {
1642+
Some(builder.ensure(llvm::Enzyme { target: build_compiler.host }))
1643+
} else {
1644+
None
1645+
};
16471646

16481647
if let Some(enzyme_install) = enzyme_install {
16491648
let src_lib = enzyme_install.join("build/Enzyme/LLVMEnzyme-17.so");

src/bootstrap/src/core/builder.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1417,8 +1417,10 @@ impl<'a> Builder<'a> {
14171417
}
14181418

14191419
// https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/.E2.9C.94.20link.20new.20library.20into.20stage1.2Frustc
1420-
rustflags.arg("-l");
1421-
rustflags.arg("LLVMEnzyme-17");
1420+
if self.config.llvm_enzyme {
1421+
rustflags.arg("-l");
1422+
rustflags.arg("LLVMEnzyme-17");
1423+
}
14221424

14231425
let use_new_symbol_mangling = match self.config.rust_new_symbol_mangling {
14241426
Some(setting) => {

src/bootstrap/src/core/config/config.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ pub struct Config {
211211
pub llvm_assertions: bool,
212212
pub llvm_tests: bool,
213213
pub llvm_plugins: bool,
214+
pub llvm_enzyme: bool,
214215
pub llvm_optimize: bool,
215216
pub llvm_thin_lto: bool,
216217
pub llvm_release_debuginfo: bool,
@@ -872,6 +873,7 @@ define_config! {
872873
release_debuginfo: Option<bool> = "release-debuginfo",
873874
assertions: Option<bool> = "assertions",
874875
tests: Option<bool> = "tests",
876+
enzyme: Option<bool> = "enzyme",
875877
plugins: Option<bool> = "plugins",
876878
ccache: Option<StringOrBool> = "ccache",
877879
static_libstdcpp: Option<bool> = "static-libstdcpp",
@@ -1494,6 +1496,7 @@ impl Config {
14941496
// we'll infer default values for them later
14951497
let mut llvm_assertions = None;
14961498
let mut llvm_tests = None;
1499+
let mut llvm_enzyme = None;
14971500
let mut llvm_plugins = None;
14981501
let mut debug = None;
14991502
let mut debug_assertions = None;
@@ -1697,6 +1700,7 @@ impl Config {
16971700
release_debuginfo,
16981701
assertions,
16991702
tests,
1703+
enzyme,
17001704
plugins,
17011705
ccache,
17021706
static_libstdcpp,
@@ -1729,6 +1733,7 @@ impl Config {
17291733
set(&mut config.ninja_in_file, ninja);
17301734
llvm_assertions = assertions;
17311735
llvm_tests = tests;
1736+
llvm_enzyme = enzyme;
17321737
llvm_plugins = plugins;
17331738
set(&mut config.llvm_optimize, optimize_toml);
17341739
set(&mut config.llvm_thin_lto, thin_lto);
@@ -1885,6 +1890,7 @@ impl Config {
18851890

18861891
config.llvm_assertions = llvm_assertions.unwrap_or(false);
18871892
config.llvm_tests = llvm_tests.unwrap_or(false);
1893+
config.llvm_enzyme = llvm_enzyme.unwrap_or(true);
18881894
config.llvm_plugins = llvm_plugins.unwrap_or(false);
18891895
config.rust_optimize = optimize.unwrap_or(RustOptimize::Bool(true));
18901896

0 commit comments

Comments
 (0)