after ./configure && make, I got this link error:
error: linking with `cc` failed: exit code: 1
note: cc '-m64' '-L' '/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib' '-o' '/home/liigo/rust/cargo/target/x86_64-unknown-linux-gnu/cargo' '/home/liigo/rust/cargo/target/x86_64-unknown-linux-gnu/cargo.o' '-Wl,--whole-archive' '-lmorestack' '-Wl,--no-whole-archive' '-nodefaultlibs' '-fno-lto' '-Wl,--gc-sections' '-pie' '-Wl,--as-needed' '/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib/libnative-4e7c5e5c.rlib' '/home/liigo/rust/cargo/target/x86_64-unknown-linux-gnu/libcargo-6b6a080e6e564e68.rlib' '/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib/libterm-4e7c5e5c.rlib' '/home/liigo/rust/cargo/target/x86_64-unknown-linux-gnu/deps/libflate2-7571a86064e76c6d.rlib' '/home/liigo/rust/cargo/target/x86_64-unknown-linux-gnu/deps/libgit2-09174fe7d724f48b.rlib' '/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib/libtime-4e7c5e5c.rlib' '/home/liigo/rust/cargo/target/x86_64-unknown-linux-gnu/deps/liblibgit2-fcba23a36b59f31c.rlib' '/home/liigo/rust/cargo/target/x86_64-unknown-linux-gnu/deps/libtar-6ccba66e5440ac37.rlib' '/home/liigo/rust/cargo/target/x86_64-unknown-linux-gnu/deps/libsemver-6324dd0606536988.rlib' '/home/liigo/rust/cargo/target/x86_64-unknown-linux-gnu/deps/libglob-54e4fdcda4a7c968.rlib' '/home/liigo/rust/cargo/target/x86_64-unknown-linux-gnu/deps/libopenssl-static-sys-6ae299ea46a69e57.rlib' '/home/liigo/rust/cargo/target/x86_64-unknown-linux-gnu/deps/libtoml-a3516e82ea71aded.rlib' '/home/liigo/rust/cargo/target/x86_64-unknown-linux-gnu/deps/libdocopt-c190fc8d655c6f84.rlib' '/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib/libdebug-4e7c5e5c.rlib' '/home/liigo/rust/cargo/target/x86_64-unknown-linux-gnu/deps/libcurl-f3f9ef32955b72e6.rlib' '/home/liigo/rust/cargo/target/x86_64-unknown-linux-gnu/deps/liburl-921578b148f50e06.rlib' '/home/liigo/rust/cargo/target/x86_64-unknown-linux-gnu/deps/libencoding-4805bc5305f7cd87.rlib' '/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib/libserialize-4e7c5e5c.rlib' '/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblog-4e7c5e5c.rlib' '/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib/libregex-4e7c5e5c.rlib' '/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-4e7c5e5c.rlib' '/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib/librand-4e7c5e5c.rlib' '/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib/libsync-4e7c5e5c.rlib' '/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustrt-4e7c5e5c.rlib' '/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcollections-4e7c5e5c.rlib' '/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunicode-4e7c5e5c.rlib' '/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-4e7c5e5c.rlib' '/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-4e7c5e5c.rlib' '/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-4e7c5e5c.rlib' '-L' '/home/liigo/rust/cargo/target/x86_64-unknown-linux-gnu' '-L' '/home/liigo/rust/cargo/target/x86_64-unknown-linux-gnu/deps' '-L' '/home/liigo/rust/cargo/target/x86_64-unknown-linux-gnu/native/flate2-7571a86064e76c6d' '-L' '/home/liigo/rust/cargo/target/x86_64-unknown-linux-gnu/native/curl-sys-9d9d6a6df3c98f14' '-L' '/home/liigo/rust/cargo/target/x86_64-unknown-linux-gnu/native/libgit2-fcba23a36b59f31c' '-L' '/home/liigo/rust/cargo/target/x86_64-unknown-linux-gnu/native/openssl-static-sys-6ae299ea46a69e57' '-L' '/home/liigo/rust/cargo/target/x86_64-unknown-linux-gnu/native/libssh2-static-sys-c29829f2cf163ffd' '-L' '/home/liigo/rust/cargo/.rust' '-L' '/home/liigo/rust/cargo' '-Wl,--whole-archive' '-Wl,-Bstatic' '-Wl,--no-whole-archive' '-Wl,-Bdynamic' '-lrt' '-lrt' '-lz' '-ldl' '-lz' '-lrt' '-ldl' '-lpthread' '-lgcc_s' '-lpthread' '-lc' '-lm' '-lcompiler-rt'
note: /usr/bin/ld: /home/liigo/rust/cargo/target/x86_64-unknown-linux-gnu/deps/liblibgit2-fcba23a36b59f31c.rlib(lldb-fix-r-ssl-ssl_algs.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
/home/liigo/rust/cargo/target/x86_64-unknown-linux-gnu/deps/liblibgit2-fcba23a36b59f31c.rlib: could not read symbols: Bad value
collect2: error: ld returned 1 exit status
error: aborting due to previous error
Could not compile `cargo`.
To learn more, run the command again with --verbose.
make: *** [cargo-x86_64-unknown-linux-gnu] Error 101
This looks like it's linking statically against OpenSSL which wasn't compiled with -fPIC, how is OpenSSL installed on your system?
I compiled openssl myself, just ./config && make && make install, some times ago. Debian 7.x 64bit.
I'll try to compile it with -fPIC, and report result here.
@alexcrichton
I have made sure that my openssl was re-compiled with -fPIC (include rsaz_exp.o).
But when compiling cargo I still got a similar error:
note: /usr/bin/ld: /home/liigo/rust/cargo/target/x86_64-unknown-linux-gnu/deps/liblibgit2-fcba23a36b59f31c.rlib(r-crypto-rsaz_exp.o): relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
/home/liigo/rust/cargo/target/x86_64-unknown-linux-gnu/deps/liblibgit2-fcba23a36b59f31c.rlib: could not read symbols: Bad value
collect2: error: ld returned 1 exit status
error: aborting due to previous error
Could not compile `cargo`.
git clone git://git.openssl.org/openssl.git
cd openssl
./config -fPIC --prefix=/usr/local --openssldir=/usr/local/ssl
make
make install
It is compiled as static library. (And was already linked to non-Rust project, it works.)
make clean
./configure
make
followed by rm -rf ~/.cargo.
Thank you @alexcrichton ! The problem is solved (after a clean cargo make).
Recompile openssl with -fPIC is the key:
./config -fPIC --prefix=/usr/local --openssldir=/usr/local/ssl
Most helpful comment
Thank you @alexcrichton ! The problem is solved (after a clean cargo make).
Recompile openssl with
-fPICis the key:./config -fPIC --prefix=/usr/local --openssldir=/usr/local/ssl