Skip to content

Commit df47148

Browse files
committed
new changes, not passed ci yet
1 parent ecf9534 commit df47148

File tree

2 files changed

+53
-1
lines changed

2 files changed

+53
-1
lines changed

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

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2295,6 +2295,58 @@ impl Step for Assemble {
22952295
}
22962296
}
22972297

2298+
if builder.config.llvm_offload && !builder.config.dry_run() {
2299+
debug!("`llvm_offload` requested");
2300+
let offload_install = builder.ensure(llvm::OmpOffload { target: build_compiler.host });
2301+
if let Some(_llvm_config) = builder.llvm_config(builder.config.host_target) {
2302+
let src_dir = offload_install.join("lib");
2303+
let libdir = builder.sysroot_target_libdir(build_compiler, build_compiler.host);
2304+
let target_libdir =
2305+
builder.sysroot_target_libdir(target_compiler, target_compiler.host);
2306+
let lib_ext = std::env::consts::DLL_EXTENSION;
2307+
2308+
let libenzyme = format!("libLLVMOffload");
2309+
let src_lib = src_dir.join(&libenzyme).with_extension(lib_ext);
2310+
let dst_lib = libdir.join(&libenzyme).with_extension(lib_ext);
2311+
let target_dst_lib = target_libdir.join(&libenzyme).with_extension(lib_ext);
2312+
builder.resolve_symlink_and_copy(&src_lib, &dst_lib);
2313+
builder.resolve_symlink_and_copy(&src_lib, &target_dst_lib);
2314+
2315+
// FIXME(offload): With LLVM-22, we should be able to drop everything below here.
2316+
let omp = format!("libomp");
2317+
let src_omp = src_dir.join(&omp).with_extension(lib_ext);
2318+
let dst_omp_lib = libdir.join(&omp).with_extension(lib_ext);
2319+
let target_omp_dst_lib = target_libdir.join(&omp).with_extension(lib_ext);
2320+
builder.resolve_symlink_and_copy(&src_omp, &dst_omp_lib);
2321+
builder.resolve_symlink_and_copy(&src_omp, &target_omp_dst_lib);
2322+
2323+
let tgt = format!("libomptarget");
2324+
let src_tgt = src_dir.join(&tgt).with_extension(lib_ext);
2325+
let dst_tgt_lib = libdir.join(&tgt).with_extension(lib_ext);
2326+
let target_tgt_dst_lib = target_libdir.join(&tgt).with_extension(lib_ext);
2327+
builder.resolve_symlink_and_copy(&src_tgt, &dst_tgt_lib);
2328+
builder.resolve_symlink_and_copy(&src_tgt, &target_tgt_dst_lib);
2329+
2330+
// The last one is slightly more tricky, since we have the same file twice, in two
2331+
// subfolders for amdgcn and nvptx64. We'll likely find two more in the future, once
2332+
// Intel and Spir-V support lands in offload.
2333+
let gpu_tgts = ["amdgcn-amd-amdhsa", "nvptx64-nvidia-cuda"];
2334+
let device = format!("libompdevice.a");
2335+
for tgt in gpu_tgts {
2336+
let dst_tgt_dir = libdir.join(&tgt);
2337+
let target_tgt_dst_dir = target_libdir.join(&tgt);
2338+
t!(fs::create_dir_all(&dst_tgt_dir));
2339+
t!(fs::create_dir_all(&target_tgt_dst_dir));
2340+
let dst_tgt_lib = dst_tgt_dir.join(&device);
2341+
let target_tgt_dst_lib = target_tgt_dst_dir.join(&device);
2342+
builder.resolve_symlink_and_copy(&src_tgt, &dst_tgt_lib);
2343+
builder.resolve_symlink_and_copy(&src_tgt, &target_tgt_dst_lib);
2344+
// FIXME(offload): copy the files within the directories as well, but figure out
2345+
// the naming scheme before.
2346+
}
2347+
}
2348+
}
2349+
22982350
// Build the libraries for this compiler to link to (i.e., the libraries
22992351
// it uses at runtime).
23002352
debug!(

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -944,7 +944,7 @@ impl Step for OmpOffload {
944944
// subfolder, so that all the logic that processes our build artifacts (hopefully) also
945945
// automatically manages our artifacts in the subfolder.
946946
let out_dir = builder.llvm_out(target).join("offload-outdir");
947-
if std::fs::exists(&out_dir).is_ok_and(|x| x == false) {
947+
if std::fs::exists(&out_dir).is_ok_and(|x| !x) {
948948
std::fs::DirBuilder::new().create(&out_dir).unwrap();
949949
}
950950

0 commit comments

Comments
 (0)