Skip to content

Commit cde58dd

Browse files
committed
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. Signed-off-by: onur-ozkan <[email protected]>
1 parent 7a202a9 commit cde58dd

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

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

+7-1
Original file line numberDiff line numberDiff line change
@@ -1777,7 +1777,13 @@ impl Step for Assemble {
17771777
// When using `download-ci-llvm`, some of the tools
17781778
// may not exist, so skip trying to copy them.
17791779
if src_path.exists() {
1780-
builder.copy_link(&src_path, &libdir_bin.join(&tool_exe));
1780+
// There is a chance that these tools are being installed from an external LLVM.
1781+
// Use `Builder::resolve_symlink_and_copy` instead of `Builder::copy_link` to ensure
1782+
// we are copying the original file not the symlinked path, which causes issues for
1783+
// tarball distribution.
1784+
//
1785+
// See https://github.com/rust-lang/rust/issues/135554.
1786+
builder.resolve_symlink_and_copy(&src_path, &libdir_bin.join(&tool_exe));
17811787
}
17821788
}
17831789
}

src/bootstrap/src/lib.rs

+8
Original file line numberDiff line numberDiff line change
@@ -1633,6 +1633,14 @@ Executed at: {executed_at}"#,
16331633
paths
16341634
}
16351635

1636+
/// Copies a file from `src` to `dst`.
1637+
///
1638+
/// If `src` is a symlink, `src` will be resolved to the actual path
1639+
/// and copied to `dst` instead of the symlink itself.
1640+
pub fn resolve_symlink_and_copy(&self, src: &Path, dst: &Path) {
1641+
self.copy_link_internal(src, dst, true);
1642+
}
1643+
16361644
/// Links a file from `src` to `dst`.
16371645
/// Attempts to use hard links if possible, falling back to copying.
16381646
/// You can neither rely on this being a copy nor it being a link,

0 commit comments

Comments
 (0)