Skip to content

Link LLVM dynamically on aarch64-apple-darwin dist#154839

Draft
sgasho wants to merge 4 commits intorust-lang:mainfrom
sgasho:issue-154408-macos-ci-llvm-versioned-dylib
Draft

Link LLVM dynamically on aarch64-apple-darwin dist#154839
sgasho wants to merge 4 commits intorust-lang:mainfrom
sgasho:issue-154408-macos-ci-llvm-versioned-dylib

Conversation

@sgasho
Copy link
Copy Markdown
Contributor

@sgasho sgasho commented Apr 5, 2026

retry after: #154485

create a symlink from libLLVM-.....dylib to libLLVM.dylib in dist.rs

@rustbot rustbot added A-CI Area: Our Github Actions CI A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. A-testsuite Area: The testsuite used to check the correctness of rustc S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-infra Relevant to the infrastructure team, which will review and decide on the PR/issue. labels Apr 5, 2026
@bjorn3
Copy link
Copy Markdown
Member

bjorn3 commented Apr 5, 2026

It looks like we are actually forcing the unversioned name to be used at another place:

// On macOS, rustc (and LLVM tools) link to an unversioned libLLVM.dylib
// instead of libLLVM-11-rust-....dylib, as on linux. It's not entirely
// clear why this is the case, though. llvm-config will emit the versioned
// paths and we don't want those in the sysroot (as we're expecting
// unversioned paths).
if target.contains("apple-darwin") && builder.llvm_link_shared() {
let src_libdir = builder.llvm_out(target).join("lib");
let llvm_dylib_path = src_libdir.join("libLLVM.dylib");
if llvm_dylib_path.exists() {
builder.install(&llvm_dylib_path, dst_libdir, FileType::NativeLibrary);
}
!builder.config.dry_run()
Would removing that instead work?

@sgasho
Copy link
Copy Markdown
Contributor Author

sgasho commented Apr 6, 2026

Yes, I checked that removing it produces libLLVM.dylib and libLLVM-.dylib, and ./x build did not fail. So it seems it worked.
However, ZuseZ4 and I discussed that we should prepare both versioned and unversioned libLLVM by COPYING first, not symlink.

Two biggest reasons are

  1. Multiple people said that copying libLLVM with the versioned name worked: ./x build failed with llvm-config: error: libLLVM-22-rust-1.96.0-nightly.dylib is missing #154408 (comment)
  2. Nokel81 said that symlink did not work for him: ./x build failed with llvm-config: error: libLLVM-22-rust-1.96.0-nightly.dylib is missing #154408 (comment)

for 2, ln -s command that Nokel81 posted on the comment has a typo in the extension part. But we have no idea whether the symlink itself actually failed or whether the command was just pasted incorrectly. It's possible that my method for verifying symlinks is incorrect.

So, we get to land copying PR first, then this symlink later on.

@bjorn3
Copy link
Copy Markdown
Member

bjorn3 commented Apr 8, 2026

So, we get to land copying PR first, then this symlink later on.

With my suggestion there wouldn't be any symlink either, right? It would just be removing the special case for macOS such that everything is handled the same way as it is handled on Linux.

@sgasho
Copy link
Copy Markdown
Contributor Author

sgasho commented Apr 8, 2026

mmm...symlink has been created. I think I'm misunderstanding something.

Is something wrong with the image below? like, I'm looking at a wrong directory, or....

Would removing that instead work?

Am I misunderstanding this, or verification steps have some mistakes(#154986 (comment))

スクリーンショット 2026-04-09 0 23 30

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-CI Area: Our Github Actions CI A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. A-testsuite Area: The testsuite used to check the correctness of rustc S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-infra Relevant to the infrastructure team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants