Closed kpcyrd closed 4 months ago
A good first trick is to check your config.log where it gets introduced into the LIBS/CFLAGS.
What is your libssh2 using for example?
When I configure rustls
and libssh2
, the -lssl -lcrypto
do not get added.
A common pattern when things like this happened in the past, it has been bad pkg-config files from some package curl gets the options from during configure.
libssh2
depends on openssl itself, but I'm explicitly using readelf
instead of ldd
. If it would be a transitive dependency it wouldn't show up, but the curl build itself is passing -lssl -lcrypto
to the linker (as can be seen in $LIBS
).
It looks like -lssl
is first used by configure exactly after it got the data from pkg-config for libssh2...
I have this pkgconfig file on my system, but I didn't have the time yet to check if Libs:
was recently changed (but it seems wrong to have -lssl
and -lcrypto
in there).
% cat /usr/lib/pkgconfig/libssh2.pc
###########################################################################
# libssh2 installation details
###########################################################################
prefix=/usr
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include
Name: libssh2
URL: https://www.libssh2.org/
Description: Library for SSH-based communication
Version: 1.11.0
Requires.private: libssl libcrypto zlib
Libs: -L${libdir} -lssh2 -L/usr/lib -lssl -L/usr/lib -lcrypto
Libs.private: -L/usr/lib -lssl -L/usr/lib -lcrypto
Cflags: -I${includedir}
It does indeed seem wrong and it proves I was right (and this is not a curl regression).
Possibly related fix in libssh2 (post 1.11.0, not in a release yet): https://github.com/libssh2/libssh2/commit/624abe275fbb88816539fa5d7ebfef7f0e5ca2f1 https://github.com/libssh2/libssh2/pull/1119
@vszakats thanks! I've locally changed the libssh2
PKGBUILD to use 624abe275fbb88816539fa5d7ebfef7f0e5ca2f1 (the patch doesn't apply cleanly to the latest libssh2 release) and the pkg-config file looks better now:
/usr/lib/pkgconfig/libssh2.pc
###########################################################################
# libssh2 installation details
#
# Copyright (C) The libssh2 project and its contributors.
# SPDX-License-Identifier: BSD-3-Clause
###########################################################################
prefix=/usr
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include
Name: libssh2
URL: https://www.libssh2.org/
Description: Library for SSH-based communication
Version: 1.11.1_DEV
Requires:
Requires.private: libssl,libcrypto,zlib
Libs: -L${libdir} -lssh2
Libs.private: -L/usr/lib -lssl -L/usr/lib -lcrypto -L/usr/lib -lz
Cflags: -I${includedir}
The diff between the two looks like this:
> #
> # Copyright (C) The libssh2 project and its contributors.
> # SPDX-License-Identifier: BSD-3-Clause
13,16c16,20
< Version: 1.11.0
< Requires.private: libssl libcrypto zlib
< Libs: -L${libdir} -lssh2 -L/usr/lib -lssl -L/usr/lib -lcrypto
< Libs.private: -L/usr/lib -lssl -L/usr/lib -lcrypto
---
> Version: 1.11.1_DEV
> Requires:
> Requires.private: libssl,libcrypto,zlib
> Libs: -L${libdir} -lssh2
> Libs.private: -L/usr/lib -lssl -L/usr/lib -lcrypto -L/usr/lib -lz
(It seems weird there's no spaces in Requires.private
, so ,
instead of ,
, I didn't see this with other software before)
I couldn't test this with curl however since they aren't compatible (it seems libssh2_session_callback_set2
was removed):
CC vquic/libcurl_la-vquic.lo
CC vquic/libcurl_la-vquic-tls.lo
CC vssh/libcurl_la-libssh.lo
CC vssh/libcurl_la-libssh2.lo
/build/curl-rustls/src/curl/lib/vssh/libssh2.c: In function 'ssh_connect':
/build/curl-rustls/src/curl/lib/vssh/libssh2.c:3313:5: error: implicit declaration of function 'libssh2_session_callback_set2'; did you mean 'libssh2_session_callback_set'? [-Wimplicit-function-declaration]
3313 | libssh2_session_callback_set2(sshc->ssh_session,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| libssh2_session_callback_set
/build/curl-rustls/src/curl/lib/vssh/libssh2.c:3315:36: error: 'libssh2_cb_generic' undeclared (first use in this function)
3315 | (libssh2_cb_generic *)ssh_tls_recv);
| ^~~~~~~~~~~~~~~~~~
/build/curl-rustls/src/curl/lib/vssh/libssh2.c:3315:36: note: each undeclared identifier is reported only once for each function it appears in
/build/curl-rustls/src/curl/lib/vssh/libssh2.c:3315:56: error: expected expression before ')' token
3315 | (libssh2_cb_generic *)ssh_tls_recv);
| ^
/build/curl-rustls/src/curl/lib/vssh/libssh2.c:3318:56: error: expected expression before ')' token
3318 | (libssh2_cb_generic *)ssh_tls_send);
| ^
make[2]: *** [Makefile:3378: vssh/libcurl_la-libssh2.lo] Error 1
make[2]: Leaving directory '/build/curl-rustls/src/build-curl/lib'
make[1]: *** [Makefile:1540: all] Error 2
make[1]: Leaving directory '/build/curl-rustls/src/build-curl/lib'
make: *** [Makefile:1224: all-recursive] Error 1
libssh2_session_callback_set2
is new to libssh2-1.11.1-DEV. curl uses it when this version is detected, but it needs the latest libssh2-DEV libraries and all headers too. It works for me and in CI. Have you tried with a vanilla libssh2-DEV build?
As for the comma, according to docs, it seems to be the "official" separator (also used by libssh2 CMake builds): https://github.com/libssh2/libssh2/commit/7f83de14a022f60c287361293f9ae513c9443d9c If here is further info or tricks to know about, let me know.
I did this
I built a curl binary with the rustls backend, and openssl explicitly disabled:
It prints this summary at the end of configure:
I expected the following
Arch Linux dev tooling flagged the binary as over-linked:
and indeed, it wants the linker to load libssl and libcrypto into the process:
This looks like another autotools issue.
curl/libcurl version
operating system
Arch Linux