Skip to content

Commit

Permalink
Unrolled build for rust-lang#135585
Browse files Browse the repository at this point in the history
Rollup merge of rust-lang#135585 - onur-ozkan:135554, r=Kobzol

resolve symlinks of LLVM tool binaries before copying them

There is a chance that these tools are being installed from an external LLVM and we have no control over them. If any of these tools use symlinks, they will fail during tarball distribution. This change makes copying process to resolve symlinks just before placing them into the destination path.

Fixes rust-lang#135554
  • Loading branch information
rust-timer authored Jan 17, 2025
2 parents 99db273 + cde58dd commit ef5f7b9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/bootstrap/src/core/build_steps/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1777,7 +1777,13 @@ impl Step for Assemble {
// When using `download-ci-llvm`, some of the tools
// may not exist, so skip trying to copy them.
if src_path.exists() {
builder.copy_link(&src_path, &libdir_bin.join(&tool_exe));
// 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));
}
}
}
Expand Down
8 changes: 8 additions & 0 deletions src/bootstrap/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1633,6 +1633,14 @@ Executed at: {executed_at}"#,
paths
}

/// Copies a file from `src` to `dst`.
///
/// If `src` is a symlink, `src` will be resolved to the actual path
/// and copied to `dst` instead of the symlink itself.
pub fn resolve_symlink_and_copy(&self, src: &Path, dst: &Path) {
self.copy_link_internal(src, dst, true);
}

/// Links a file from `src` to `dst`.
/// Attempts to use hard links if possible, falling back to copying.
/// You can neither rely on this being a copy nor it being a link,
Expand Down

0 comments on commit ef5f7b9

Please sign in to comment.