Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/bootstrap/src/core/build_steps/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2309,15 +2309,15 @@ impl Step for Assemble {
if let Some(_llvm_config) = builder.llvm_config(builder.config.host_target) {
let target_libdir =
builder.sysroot_target_libdir(target_compiler, target_compiler.host);

let offload_libdir = builder.offload_out(build_compiler.host).join("lib");

for p in offload_install.offload_paths() {
let libname = p.file_name().unwrap();
let dst_lib = target_libdir.join(libname);
let relative = t!(p.strip_prefix(&offload_libdir));
let dst_lib = target_libdir.join(relative);
t!(fs::create_dir_all(dst_lib.parent().unwrap()));
builder.resolve_symlink_and_copy(&p, &dst_lib);
}
// FIXME(offload): Add amdgcn-amd-amdhsa and nvptx64-nvidia-cuda folder
// This one is slightly more tricky, since we have the same file twice, in two
// subfolders for amdgcn and nvptx64. We'll likely find two more in the future, once
// Intel and Spir-V support lands in offload.
}
}

Expand Down
13 changes: 13 additions & 0 deletions src/bootstrap/src/core/build_steps/dist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,19 @@ impl Step for Rustc {
);
}

if builder.config.llvm_offload {
let src_dir = builder.sysroot_target_libdir(target_compiler, target);
let dst_dir = image.join("lib/rustlib").join(target).join("lib");

for offload_target in ["amdgcn-amd-amdhsa", "nvptx64-nvidia-cuda"] {
let src = src_dir.join(offload_target);
let dst = dst_dir.join(offload_target);

t!(fs::create_dir_all(&dst));
builder.cp_link_r(&src, &dst);
}
}

if builder.tool_enabled("wasm-component-ld") {
let src_dir = builder.sysroot_target_bindir(target_compiler, target);
let ld = exe("wasm-component-ld", target_compiler.host);
Expand Down
26 changes: 26 additions & 0 deletions src/bootstrap/src/core/build_steps/llvm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -993,6 +993,31 @@ impl Step for OmpOffload {
files.push(out_dir.join("lib").join("libomp").with_extension(lib_ext));
files.push(out_dir.join("lib").join("libomptarget").with_extension(lib_ext));

files.push(
out_dir.join("lib").join("amdgcn-amd-amdhsa").join("libompdevice").with_extension("a"),
);
files.push(
out_dir
.join("lib")
.join("amdgcn-amd-amdhsa")
.join("libomptarget-amdgpu")
.with_extension("bc"),
);
files.push(
out_dir
.join("lib")
.join("nvptx64-nvidia-cuda")
.join("libompdevice")
.with_extension("a"),
);
files.push(
out_dir
.join("lib")
.join("nvptx64-nvidia-cuda")
.join("libomptarget-nvptx")
.with_extension("bc"),
);

// Offload/OpenMP are just subfolders of LLVM, so we can use the LLVM sha.
static STAMP_HASH_MEMO: OnceLock<String> = OnceLock::new();
let smart_stamp_hash = STAMP_HASH_MEMO.get_or_init(|| {
Expand Down Expand Up @@ -1092,6 +1117,7 @@ impl Step for OmpOffload {
cfg.define("LLVM_ENABLE_RUNTIMES", "openmp;offload");
} else {
// OpenMP provides some device libraries, so we also compile it for all gpu targets.
cfg.define("OPENMP_INSTALL_LIBDIR", Path::new("lib").join(omp_target));
cfg.define("LLVM_USE_LINKER", "lld");
cfg.define("LLVM_ENABLE_RUNTIMES", "openmp");
cfg.define("CMAKE_C_COMPILER_TARGET", omp_target);
Expand Down
4 changes: 3 additions & 1 deletion src/ci/docker/host-x86_64/dist-x86_64-linux/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ RUN ./cmake.sh
# Now build LLVM+Clang, afterwards configuring further compilations to use the
# clang/clang++ compilers.
COPY scripts/build-clang.sh /tmp/
ENV LLVM_BUILD_TARGETS=X86
ENV LLVM_BUILD_TARGETS="X86;AMDGPU;NVPTX"
RUN ./build-clang.sh
ENV CC=clang CXX=clang++

Expand All @@ -90,6 +90,8 @@ ENV RUST_CONFIGURE_ARGS="--enable-full-tools \
--set llvm.thin-lto=true \
--set llvm.ninja=false \
--set llvm.libzstd=true \
--set llvm.offload=true \
--set llvm.offload-clang-dir="/rustroot/lib/cmake/clang" \
--set rust.jemalloc \
--set rust.bootstrap-override-lld=true \
--set rust.lto=thin \
Expand Down
2 changes: 1 addition & 1 deletion src/tools/opt-dist/src/utils/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub fn reset_directory(path: &Utf8Path) -> anyhow::Result<()> {

pub fn copy_directory(src: &Utf8Path, dst: &Utf8Path) -> anyhow::Result<()> {
log::info!("Copying directory {src} to {dst}");
fs_extra::dir::copy(src, dst, &CopyOptions::default().copy_inside(true))?;
fs_extra::dir::copy(src, dst, &CopyOptions::default().content_only(true))?;

@sgasho sgasho Jul 13, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't figure out why copy_inside(true) is used here. The latest CI failure seems related, so I'd like to try content_only(true).

View changes since the review

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I also feel that using copy_inside(true) in a function named copy_directory can lead to unexpected behavior, as seen in the latest CI failure. It does more than just copy the contents of src to dst)

Ok(())
}

Expand Down
Loading