Strange linking error on `cargo test`


#1

When I’m running test suite for my library ucl everything is fine, except when I’m trying to add doc-tests. Then I get linking error:

failures:

---- _0 stdout ----
        error: linking with `cc` failed: exit code: 1
note: "cc" "-Wl,--as-needed" "-m64" "-L" "/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-o" "/tmp/rustdoctest.iOcU8rsBmCGd/rust_out" "/tmp/rustdoctest.iOcU8rsBmCGd/rust_out.o" "-Wl,--whole-archive" "-lmorestack" "-Wl,--no-whole-archive" "-Wl,--gc-sections" "-pie" "-nodefaultlibs" "/home/hauleth/Workspace/ucl-rs/target/debug/libucl.rlib" "/home/hauleth/Workspace/ucl-rs/target/debug/deps/liblibucl_sys-1226c518b95feffe.rlib" "/home/hauleth/Workspace/ucl-rs/target/debug/deps/libcurl_sys-dd89af55ea8cd7e5.rlib" "/home/hauleth/Workspace/ucl-rs/target/debug/deps/liblibz_sys-c145b8b5c75fd5a3.rlib" "/home/hauleth/Workspace/ucl-rs/target/debug/deps/libopenssl_sys-5040130ff99796a0.rlib" "/home/hauleth/Workspace/ucl-rs/target/debug/deps/liblibc-2eda841eb12a3090.rlib" "-L" "/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-lstd-4e7c5e5c" "-L" "/home/hauleth/Workspace/ucl-rs/target/debug/deps" "-L" "/home/hauleth/.linuxbrew/Cellar/curl/7.42.1/lib" "-L" "/home/hauleth/Workspace/ucl-rs/target/debug/build/openssl-sys-5040130ff99796a0/out" "-L" "/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-L" "/home/hauleth/Workspace/ucl-rs/.rust/lib/x86_64-unknown-linux-gnu" "-L" "/home/hauleth/Workspace/ucl-rs/lib/x86_64-unknown-linux-gnu" "-Wl,--whole-archive" "-Wl,-Bstatic" "-Wl,--no-whole-archive" "-Wl,-Bdynamic" "-lcurl" "-lz" "-lssl" "-lcrypto" "-lc" "-lm" "-ldl" "-lpthread" "-lrt" "-lgcc_s" "-lpthread" "-lc" "-lm" "-lcompiler-rt"
note: /home/hauleth/.linuxbrew/Cellar/curl/7.42.1/lib/libcurl.so: undefined reference to `SSL_get0_alpn_selected'
/home/hauleth/.linuxbrew/Cellar/curl/7.42.1/lib/libcurl.so: undefined reference to `SSL_CTX_set_alpn_protos'
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I was thinking that this was issue with libcurl (installed via LinuxBrew) but I’ve checked with objdump and libcurl.so and libcurl.a contains that symbol:

libcurl.a:

0000000000000000         *UND*	0000000000000000 SSL_CTX_set_alpn_protos
0000000000000000         *UND*	0000000000000000 SSL_CTX_set_cipher_list
0000000000000000         *UND*	0000000000000000 SSL_CTX_set_default_passwd_cb
0000000000000000         *UND*	0000000000000000 SSL_CTX_set_default_passwd_cb_userdata
0000000000000000         *UND*	0000000000000000 SSL_CTX_set_next_proto_select_cb
0000000000000000         *UND*	0000000000000000 SSL_CTX_set_srp_password
0000000000000000         *UND*	0000000000000000 SSL_CTX_set_srp_username
0000000000000000         *UND*	0000000000000000 SSL_CTX_set_verify

libcurl.so:

0000000000000000       F *UND*	0000000000000000              SSL_CTX_set_srp_password
0000000000000000       F *UND*	0000000000000000              SSL_CTX_set_verify
0000000000000000       F *UND*	0000000000000000              SSL_CTX_set_alpn_protos
0000000000000000       F *UND*	0000000000000000              SSL_CTX_set_default_passwd_cb_userdata
0000000000000000       F *UND*	0000000000000000              SSL_CTX_set_default_passwd_cb
0000000000000000       F *UND*	0000000000000000              SSL_CTX_set_cipher_list
0000000000000000       F *UND*	0000000000000000              SSL_CTX_set_srp_username
0000000000000000       F *UND*	0000000000000000              SSL_CTX_set_next_proto_select_cb

Any ideas what is wrong? Example binaries works fine, “normal” test are passing, just doc-tests are failing without any reason (at least for me).

Is there something wrong with me or with my environment?