gentoo-rust icon indicating copy to clipboard operation
gentoo-rust copied to clipboard

cargo links against system library

Open ghost opened this issue 10 years ago • 1 comments

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.com-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"

ghost avatar May 05 '15 00:05 ghost

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 avatar May 05 '15 11:05 gentoo90