update llvm-tools copying logic for dist step

Signed-off-by: onur-ozkan <work@onurozkan.dev>
This commit is contained in:
onur-ozkan 2025-05-12 06:33:11 +00:00
parent 718ddf660e
commit 63de63e8a4
2 changed files with 21 additions and 12 deletions

View file

@ -1984,17 +1984,20 @@ impl Step for Assemble {
trace!("installing `{tool}`");
let tool_exe = exe(tool, target_compiler.host);
let src_path = llvm_bin_dir.join(&tool_exe);
// When using `download-ci-llvm`, some of the tools
// may not exist, so skip trying to copy them.
if src_path.exists() {
// There is a chance that these tools are being installed from an external LLVM.
// Use `Builder::resolve_symlink_and_copy` instead of `Builder::copy_link` to ensure
// we are copying the original file not the symlinked path, which causes issues for
// tarball distribution.
//
// See https://github.com/rust-lang/rust/issues/135554.
builder.resolve_symlink_and_copy(&src_path, &libdir_bin.join(&tool_exe));
// When using `download-ci-llvm`, some of the tools may not exist, so skip trying to copy them.
if !src_path.exists() && builder.config.llvm_from_ci {
eprintln!("{} does not exist; skipping copy", src_path.display());
continue;
}
// There is a chance that these tools are being installed from an external LLVM.
// Use `Builder::resolve_symlink_and_copy` instead of `Builder::copy_link` to ensure
// we are copying the original file not the symlinked path, which causes issues for
// tarball distribution.
//
// See https://github.com/rust-lang/rust/issues/135554.
builder.resolve_symlink_and_copy(&src_path, &libdir_bin.join(&tool_exe));
}
}
}

View file

@ -2274,9 +2274,9 @@ impl Step for LlvmTools {
let target = self.target;
/* run only if llvm-config isn't used */
// Run only if a custom llvm-config is not used
if let Some(config) = builder.config.target_config.get(&target) {
if let Some(ref _s) = config.llvm_config {
if !builder.config.llvm_from_ci && config.llvm_config.is_some() {
builder.info(&format!("Skipping LlvmTools ({target}): external LLVM"));
return None;
}
@ -2294,6 +2294,12 @@ impl Step for LlvmTools {
let dst_bindir = format!("lib/rustlib/{}/bin", target.triple);
for tool in tools_to_install(&builder.paths) {
let exe = src_bindir.join(exe(tool, target));
// When using `download-ci-llvm`, some of the tools may not exist, so skip trying to copy them.
if !exe.exists() && builder.config.llvm_from_ci {
eprintln!("{} does not exist; skipping copy", exe.display());
continue;
}
tarball.add_file(&exe, &dst_bindir, FileType::Executable);
}
}