-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Linker error on a crates that link with system frameworks and add library search paths #36250
Comments
I investigated this a bit, and it look like this is not a rustdoc bug (as running the command from a separated process works just fine). It looks like this is caused by rustup on my machine. Setting The good new here is that using the latest master of rustup also fixes the error! (Maybe due to rust-lang/rustup@b851f7c ?) Ping @brson for rustup |
I ran into this error myself while linking I created a repo with the bare minimum needed to trigger the error here: https://github.com/casey/rust-dynamic-linker-error Note that in the above repo, the symbol and library in the error message are different, but I believe the cause to be the same. What's happening is that the build script is emitting On my system, I have an extern block in When the binary runs, the loader tries to dynamically link the Most of the specifics here aren't super important. This could happen with macports or homebrew, and any number of frameworks which link against system-supplied dynamic libraries that happen to be found in an alternate location. Unfortunately I'm not sure what exactly fix is here. macOS frameworks expect to link dynamic libraries in |
@alexcrichton might have some insight here |
Also, I'm using rustup myself, but I'm not sure if it's related. I'm on 0.6.5, which has |
Unfortunately I may not have many insights beyond I believe your summary is accurate @casey. This isn't really a rust-lang/rust bug AFAIK though, it's just an unfortunate interaction with openssl-sys and libgit2-sys |
Are you sure it isn't a rust bug? Wanting to link a binary with a dynamic library in a nonstandard location and a framework in a standard location seems like a reasonable thing to do. Does rust have its own linker or does it use an external linker? If it uses an external linker, is there a way to get the command line that rustc passes to that linker? Perhaps there's a way of specifying search path precedence in such a way that it will work. |
The plot thickens! I was using
However, I happened to try to run the binary directly, and it worked:
When I inspected the environment variables that the binary was inheriting when run with Cargo is setting The In fact, I was able to trigger the same error in a C program compiled with clang by exporting the same variable:
I'm not sure why cargo is exporting this variable, since it isn't necessary. So, fortunately it looks like this one has an easy fix, just stop exporting this variable. If it would cause libraries to not be found, we can look at exporting I'll open an issue with cargo. I think this issue can be closed. |
It looks like perhaps there already is an issue: rust-lang/cargo#2888 Edit: Actually, that issue looks a little too general, so I opened rust-lang/cargo#3366 |
@casey currently we shell out to |
I've said this in a bunch of different issues already in both here and the cargo repo. The root cause of the problem is Sent with GitHawk |
Is this still relevant? It sounds like it was never a rustdoc bug in the first place, is that true? |
On OS X rustdoc somehow ends up linking the tested crate with
ImageIO.framework
andlibjpeg
, even if the crate doesn't link with any library.If the tested crate's build script merely sets a search path (
cargo:rustc-link-search=native=/usr/local/lib
) to a path contains a version oflibjpeg
, rustdoc will link with it. This is problematic, because rustdoc also links with OS X'sImageIO.framework
which can't coexist with non-Applelibjpeg
in the same program.$ cargo test --doc
What makes even more bizarre is that if I run the failing command myself from terminal, it works:
rustc 1.13.0-nightly (497d67d 2016-09-01)
To reproduce:
brew install libjpeg && brew link libjpeg cargo new testing
add
build.rs
withcargo test --doc
The text was updated successfully, but these errors were encountered: