Skip to content

Commit 7daabfd

Browse files
committed
adjust libdir for windows, use lld during enzyme build when needed
1 parent b6bed6f commit 7daabfd

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

  • src/bootstrap/src/core/build_steps

src/bootstrap/src/core/build_steps/llvm.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use crate::core::config::{Config, TargetSelection};
2323
use crate::utils::build_stamp::{BuildStamp, generate_smart_stamp_hash};
2424
use crate::utils::exec::command;
2525
use crate::utils::helpers::{
26-
self, exe, get_clang_cl_resource_dir, t, unhashed_basename, up_to_date,
26+
self, exe, get_clang_cl_resource_dir, libdir, t, unhashed_basename, up_to_date,
2727
};
2828
use crate::{CLang, GitRepo, Kind, trace};
2929

@@ -561,7 +561,6 @@ impl Step for Llvm {
561561
}
562562
};
563563

564-
// FIXME(ZuseZ4): Do we need that for Enzyme too?
565564
// When building LLVM with LLVM_LINK_LLVM_DYLIB for macOS, an unversioned
566565
// libLLVM.dylib will be built. However, llvm-config will still look
567566
// for a versioned path like libLLVM-14.dylib. Manually create a symbolic
@@ -1159,7 +1158,7 @@ impl Step for Enzyme {
11591158
let llvm_version_major = llvm::get_llvm_version_major(builder, &host_llvm_config);
11601159
let lib_ext = std::env::consts::DLL_EXTENSION;
11611160
let libenzyme = format!("libEnzyme-{llvm_version_major}");
1162-
let build_dir = out_dir.join("lib");
1161+
let build_dir = out_dir.join(libdir(target));
11631162
let dylib = build_dir.join(&libenzyme).with_extension(lib_ext);
11641163

11651164
trace!("checking build stamp to see if we need to rebuild enzyme artifacts");
@@ -1197,7 +1196,16 @@ impl Step for Enzyme {
11971196
// hard to spot more relevant issues.
11981197
let mut cflags = CcFlags::default();
11991198
cflags.push_all("-Wno-deprecated");
1200-
configure_cmake(builder, target, &mut cfg, true, LdFlags::default(), cflags, &[]);
1199+
1200+
// Logic copied from `configure_llvm`
1201+
// ThinLTO is only available when building with LLVM, enabling LLD is required.
1202+
// Apple's linker ld64 supports ThinLTO out of the box though, so don't use LLD on Darwin.
1203+
let mut ldflags = LdFlags::default();
1204+
if builder.config.llvm_thin_lto && !target.contains("apple") {
1205+
ldflags.push_all("-fuse-ld=lld");
1206+
}
1207+
1208+
configure_cmake(builder, target, &mut cfg, true, ldflags, cflags, &[]);
12011209

12021210
// Re-use the same flags as llvm to control the level of debug information
12031211
// generated by Enzyme.

0 commit comments

Comments
 (0)