Skip to content

Commit bfe762e

Browse files
committed
Auto merge of #121967 - nikic:libllvm-linker-script, r=Mark-Simulacrum
Replace libLLVM symlink with linker script It turns out that the libLLVM-N.so -> libLLVM.so.N.1 symlink is also needed when projects like miri link against librustc_driver.so. As such, we have to distribute it in real rustup components like rustc-dev, rather than only for download-ci-llvm. To avoid actually distributing symlinks (which are not supported or not fully supported by the rustup infrastructure) replace it with a linker script that does the same thing instead. Fixes #121889. r? `@cuviper`
2 parents 3314d5c + 5d1d408 commit bfe762e

File tree

1 file changed

+10
-2
lines changed
  • src/bootstrap/src/core/build_steps

1 file changed

+10
-2
lines changed

src/bootstrap/src/core/build_steps/dist.rs

+10-2
Original file line numberDiff line numberDiff line change
@@ -2035,10 +2035,18 @@ fn install_llvm_file(
20352035
// If we have a symlink like libLLVM-18.so -> libLLVM.so.18.1, install the target of the
20362036
// symlink, which is what will actually get loaded at runtime.
20372037
builder.install(&t!(fs::canonicalize(source)), destination, 0o644);
2038+
2039+
let full_dest = destination.join(source.file_name().unwrap());
20382040
if install_symlink {
2039-
// If requested, also install the symlink. This is used by download-ci-llvm.
2040-
let full_dest = destination.join(source.file_name().unwrap());
2041+
// For download-ci-llvm, also install the symlink, to match what LLVM does. Using a
2042+
// symlink is fine here, as this is not a rustup component.
20412043
builder.copy(&source, &full_dest);
2044+
} else {
2045+
// Otherwise, replace the symlink with an equivalent linker script. This is used when
2046+
// projects like miri link against librustc_driver.so. We don't use a symlink, as
2047+
// these are not allowed inside rustup components.
2048+
let link = t!(fs::read_link(source));
2049+
t!(std::fs::write(full_dest, format!("INPUT({})\n", link.display())));
20422050
}
20432051
} else {
20442052
builder.install(&source, destination, 0o644);

0 commit comments

Comments
 (0)