Skip to content
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

cargo links against system library #124

Open
ghost opened this issue May 5, 2015 · 1 comment
Open

cargo links against system library #124

ghost opened this issue May 5, 2015 · 1 comment

Comments

@ghost
Copy link

ghost commented May 5, 2015

When <=dev-libs/libgit2-0.22.2 is installed, cargo fails to build:
/tmp/portage/portage/dev-rust/cargo-0.2.0/homedir/.cargo/registry/src/github.ghproxy.top-1ecc6299db9ec823/git2-0.2.9/src/call.rs:14: undefined reference to `git_config_get_string_buf'

git_config_get_string_buf was recently added to libgit2 and is not present in libgit2-0.22.2.

I assume during the build of libgit2-sys the libgit2 library inside libgit2-sys is used for compilation.
When cargo is finally build and in its link-phase, the system libgit2.so is used instead.
This results in the linking error above.

My conclusion is that order of the library paths is not correct in the final call to cc:

"cc" "-Wl,--as-needed" "-m64" "-L" "/usr/lib/rust-9999/rustlib/x86_64-unknown-linux-gnu/lib"
"-o" "/tmp/portage/portage/dev-rust/cargo-0.2.0/work/cargo-0.2.0/target/x86_64-unknown-linux-
gnu/debug/cargo"
"/tmp/portage/portage/dev-rust/cargo-0.2.0/work/cargo-0.2.0/target/x86_64-unknown-linux-gnu/debug/cargo.o"
"-Wl,--whole-archive" "-lmorestack" "-Wl,--no-whole-archive" "-Wl,--gc-sections" "-pie" "-nodefaultlibs"
"/tmp/portage/portage/dev-rust/cargo-0.2.0/work/cargo-0.2.0/target/x86_64-unknown-linux-gnu/debug/libcargo-585217ecbd0232dc.rlib"
"/tmp/portage/portage/dev-rust/cargo-0.2.0/work/cargo-0.2.0/target/x86_64-unknown-linux-gnu/debug/deps/libsemver-97eaa84569c2a87a.rlib"
"/tmp/portage/portage/dev-rust/cargo-0.2.0/work/cargo-0.2.0/target/x86_64-unknown-linux-gnu/debug/deps/libtoml-e4d393d734aaa578.rlib">
... various other .rlib lines ...
"/tmp/portage/portage/dev-rust/cargo-0.2.0/work/cargo-0.2.0/target/x86_64-unknown-linux-gnu/debug/deps/libgit2-4a698c238a72e394.rlib"
"-L" "/tmp/portage/portage/dev-rust/cargo-0.2.0/work/cargo-0.2.0/target/x86_64-unknown-linux-gnu/debug"
"-L" "/tmp/portage/portage/dev-rust/cargo-0.2.0/work/cargo-0.2.0/target/x86_64-unknown-linux-gnu/debug/deps"
"-L" "/usr/lib64"
"-L" "/usr//usr/lib64"
"-L" "/usr/lib64"
"-L" "/usr/lib64"
"-L" "/usr/lib64"
"-L" "/tmp/portage/portage/dev-rust/cargo-0.2.0/work/cargo-0.2.0/target/x86_64-unknown-linux-gnu/debug/build/miniz-sys-b8d8088fb65057d4/out"
... other /out lines ...
"-L" "/usr/lib/rust-9999/rustlib/x86_64-unknown-linux-gnu/lib"
"-L" "/tmp/portage/portage/dev-rust/cargo-0.2.0/work/cargo-0.2.0/.rust/lib/rust-9999/x86_64-unknown-linux-gnu"
"-L" "/tmp/portage/portage/dev-rust/cargo-0.2.0/work/cargo-0.2.0/lib/rust-9999/x86_64-unknown-linux-gnu"
"-Wl,--whole-archive" "-Wl,-Bstatic" "-Wl,--no-whole-archive" "-Wl,-Bdynamic"
"-lrt" "-lhttp_parser" "-lrt" "-lgit2" "-lssl" "-lgmp" "-ldl" "-lz" "-lcrypto" "-lgmp" "-ldl" "-lz" "-lssh2" "-lcurl" "-lssl" "-lcrypto" "-lz" "-lc" "-lm" "-ldl" "-lpthread" "-lrt" "-lgcc_s" "-lpthread" "-lc" "-lm" "-lcompiler-rt"

@gentoo90
Copy link
Contributor

gentoo90 commented May 5, 2015

Looks like pkg-config in build.rs script of libgit2-sys returns different result, when running in ebuild environment. I'll try to fix this.

gentoo90 added a commit to gentoo90/gentoo-rust that referenced this issue May 6, 2015
gentoo90 added a commit to gentoo90/gentoo-rust that referenced this issue May 6, 2015
cnd pushed a commit that referenced this issue May 6, 2015
Fix cargo build when dev-libs/libgit2 is installed (#124)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant