-
Notifications
You must be signed in to change notification settings - Fork 13.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Linking LLVM in-tree as a shared library fails on macOS but not on Linux #138563
Comments
I think what might be happening here is that during the first build, Then, during the second build, because the Random notes on llvm-config+macOSThere are some know issues with Bootstrap has some custom logic for copying
Some of this logic doesn't run when using "system LLVM", i.e. when setting the |
Thanks for your help! That's similar to what I was thinking, too. However...
From what I can tell, both the original Two other additional things to add from my original post:
|
I think I've figured out the issue. On Unix systems, the link to the sysroot is inserted into the If you dynamically link against an external "system" LLVM, then Patch for configure_linker// If we are dynamically linking against a prebuilt system LLVM,
// then libraries will not be copied into the sysroot, so they
// cannot be located via rpath. We fix this by adding the path to
// the LLVM libdir to rpath, in addition to the sysroot.
if builder.llvm_link_shared() && builder.is_system_llvm(target) {
if let Some(llvm_config) = builder.llvm_config(target) {
let llvm_libdir =
command(llvm_config).arg("--libdir").run_capture_stdout(builder).stdout();
self.rustflags.arg(&format!("-Clink-args=-Wl,-rpath,{llvm_libdir}"));
}
} I'l be using the patch above until there's a more permanent fix. I'd make a PR, but it seems like there's still more to investigate here. Strangely enough, disabling |
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 locatelibLLVM
on macOS. This does not occur on anx86_64-unknown-linux-gnu
system.Command used
Replace
<host>
with the current host.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:
Bootstrap configuration (config.toml)
Operating system
x86_64-unknown-linux-gnu
)aarch64-apple-darwin
)HEAD
4d30011
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
log.txt
The text was updated successfully, but these errors were encountered: