Linking LLVM in-tree as a shared library fails on macOS but not on Linux
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
Summary
I am trying to build LLVM in-tree as a shared library and then link against it as if it were an external, prebuilt installation (e.g. setting llvm-config in the bootstrap config). When I try this, stage 1 builds fail to locate libLLVM on macOS. This does not occur on an x86_64-unknown-linux-gnu system.
Command used
Replace <host> with the current host.
./x.py build llvm
export LD_LIBRARY_PATH="absolute/path/to/build/<host>/llvm/build/lib"
./x.py build —stage 1 --set target.<host>.llvm-config="absolute/path/to/build/<host>/llvm/bin/llvm-config"
Expected behaviour
The build should succeed on macOS like it does on Linux.
Actual behaviour
The build fails at the very end with the following message:
dyld[7250]: Library not loaded: @rpath/libLLVM.dylib
Bootstrap configuration (config.toml)
profile = "dist"
change-id = 134650
[llvm]
download-ci-llvm = false
link-shared = true
Operating system
- Ubuntu 22.04.5 (
x86_64-unknown-linux-gnu) - macOS 15.3.2 (
aarch64-apple-darwin)
HEAD
4d30011f6c616be074ba655a75e5d55441232bbb
Additional context
I haven't modified anything other than my bootstrap config.
I am trying to do this so that I can test changes to a custom LLVM instrumentation pass without having to rebuild the Rust frontend. This is purely for convenience during development—the project's CI pipeline builds and tests everything with rustc statically linked to LLVM in the usual way. The variable LD_LIBRARY_PATH is set by default to that directory in the development environment.
Build Log
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the x.py build llvm and stage 1 commands, the bootstrap config.toml, and the llvm-config setting described in the report. Compare shared-library loading on macOS and Linux, focusing on the @rpath/libLLVM.dylib failure. Done means the macOS stage 1 build succeeds with link-shared = true, as it does on Linux.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- build-system, compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100