-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Can't compile code when using openssl from MacPorts #3538
Comments
Do you have a version of iconv in macports as well? It looks like libgit2 may have been compiled against one and linked against another. |
Hi Alex, yes I found a libiconv in the macports dir. I tried this from a fresh install with just openssl and cmake installed. Here is the full build output: http://pastebin.com/jNPXdEEL |
I can see these lines related to iconv:
-- Found Iconv: -L/usr/lib -liconv Then when running rustc on libgit2-sys-0.6.6/lib.rs: -L native=/opt/local/lib Where there is also an iconv. So I'm not sure I'm reading this right but it seems your hypothesis was correct! How could we fix this? |
Unfortunately I'm not sure there's really a great way to fix this other than coercing libgit2 to find iconv in /opt/local/lib first (which I'm not sure how to do) |
This PR seems relevant: https://github.com/libgit2/libgit2/pull/3092/files I don't know a great way to fix it either but without a fix, the build will be broken for macports users. Is there a way to override this through a linker path or something else from our side as the consumer of libgit2? Maybe following their behavior on the Rust side? |
I can get it working by adding this to libgit2-sys' build.rs:
I'm able to compile and run the git2 tests without running into that linker error. It's actually not required to modify build.rs, as this works, too:
This makes everything work! However, it's definitely not newbie friendly! It took me a while to figure out that I needed to do this + also override the OPENSSL env vars to get everything working. I also don't know how great of a solution this is; the libgit2 team intentionally removed /opt/local from their search path and they seem to prefer defaulting to the system libraries, while cargo does search in /opt/local by default (and right now I'm not sure how to override that). Sys programming is not my main job :), so I'm really not sure which way is "right". |
In any case this seems like a bug for the git2 crate not Cargo itself. It could perhaps do tricks to figure out what's being printed where, but this is unfortunately just a situation where having lots of libs that shadow each other doesn't work out well when there's no real dependencies between them. |
It might be cargo-related if there is an issue with the way cargo is looking up the paths, though I don't really know if this is or not. Why does cargo look in /opt without being told to? Is it using the path? Is this easily overridable using env vars? Otherwise sure, I could close this issue and open one up on the git2 crate. I'm just wondering how to make this all more newbie-friendly and how to teach the user about these semantics because right now, it's a bit of a frustrating experience. |
Oh sorry what I meant was that Cargo isn't involved here at all, this is all libgit2-sys's build script (changes necessary there at least) |
Oh, sorry, so you mean the build.rs? OK I'll move the issue over :) |
Yeah this is all basically logic that should go into libgit2-sys's build.rs. Either in the way of error message or in terms of probing for the right libs. |
OK I see now -- still learning about all of this. I opened up https://github.com/alexcrichton/git2-rs/issues/180 to track over there. |
Sorry for the spam, but the updated link is rust-lang/git2-rs#180 and to build git2-rs I ended up using:
update git2-rs 0.13+ no longer requires the |
This issue seems to have arisen again on macOS 11; see my comment here: rust-lang/git2-rs#180 (comment) Unfortunately there isn't a nice workaround other than deactivating the |
Hi team,
I was trying out dinghy and had some issues running
cargo install dinghy
due to some undefined git symbols. It seems that it doesn't work when openssl is installed from MacPorts, but it does work when installed from Homebrew.Here's the linker error:
Here is my config:
macOS 10.12.2
Xcode 8.2.1
git version 2.10.1 (Apple Git-78)
sudo port install cmake
sudo port install openssl
export OPENSSL_INCLUDE_DIR=/opt/local/include
export OPENSSL_LIB_DIR=/opt/local/lib
cargo clean
cargo install dinghy
See also: sonos/dinghy#3
Here's some sample code which reduces the problem:
Cargo.toml
main.rs
The text was updated successfully, but these errors were encountered: