Skip to content

Commit

Permalink
Auto merge of rust-lang#121967 - nikic:libllvm-linker-script, r=Mark-…
Browse files Browse the repository at this point in the history
…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 rust-lang#121889.

r? `@cuviper`
  • Loading branch information
bors committed Mar 6, 2024
2 parents 3314d5c + 5d1d408 commit bfe762e
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/bootstrap/src/core/build_steps/dist.rs
Expand Up @@ -2035,10 +2035,18 @@ fn install_llvm_file(
// If we have a symlink like libLLVM-18.so -> libLLVM.so.18.1, install the target of the
// symlink, which is what will actually get loaded at runtime.
builder.install(&t!(fs::canonicalize(source)), destination, 0o644);

let full_dest = destination.join(source.file_name().unwrap());
if install_symlink {
// If requested, also install the symlink. This is used by download-ci-llvm.
let full_dest = destination.join(source.file_name().unwrap());
// For download-ci-llvm, also install the symlink, to match what LLVM does. Using a
// symlink is fine here, as this is not a rustup component.
builder.copy(&source, &full_dest);
} else {
// Otherwise, replace the symlink with an equivalent linker script. This is used when
// projects like miri link against librustc_driver.so. We don't use a symlink, as
// these are not allowed inside rustup components.
let link = t!(fs::read_link(source));
t!(std::fs::write(full_dest, format!("INPUT({})\n", link.display())));
}
} else {
builder.install(&source, destination, 0o644);
Expand Down

0 comments on commit bfe762e

Please sign in to comment.