Repository navigation
libcurl links with libnghttp3 even when http3 support is off #12833
Description
I did this
Hello! A user's bug report to MacPorts revealed that libcurl is linking with libnghttp3 even when http3 support is not enabled and this seemed incorrect to me.
We use the autotools build system. If ngtcp2 and nghttp3 are both installed and curl is configured with no flags relating to ngtcp2 or nghttp3, then I expected that http3 support would not be enabled and libnghttp3 would not be used. Output from configure is:
checking for libnghttp3 options with pkg-config... found
configure: -l is -lnghttp3
configure: -I is
configure: -L is -L/opt/local/lib
checking for nghttp3_conn_client_new_versioned in -lnghttp3... yes
checking for nghttp3/nghttp3.h... yes
…
LIBS: -lnghttp3 -lnghttp2 -lidn2 -lpsl -lssl -lcrypto -lssl -lcrypto -lzstd -lzstd -lbrotlidec -lbrotlidec -lz
…
HTTP3: no (--with-ngtcp2 --with-nghttp3, --with-quiche, --with-openssl-quic, --with-msh3)
After installation curl reports:
% curl --version
curl 8.6.0 (x86_64-apple-darwin21.6.0) libcurl/8.6.0 OpenSSL/3.2.1 zlib/1.3.1 brotli/1.1.0 zstd/1.5.5 libidn2/2.3.7 libpsl/0.21.2 nghttp2/1.59.0
Release-Date: 2024-01-31
Protocols: dict file ftp ftps gopher gophers http https imap imaps ipfs ipns mqtt pop3 pop3s rtsp smb smbs smtp smtps telnet tftp
Features: alt-svc AsynchDNS brotli HSTS HTTP2 HTTPS-proxy IDN IPv6 Largefile libz NTLM PSL SSL threadsafe TLS-SRP UnixSockets zstd
So the first line correctly omits ngtcp2/1.2.0 nghttp3/1.1.0 from the list of libraries used and the last line correctly omits HTTP3 from the list of features however libcurl is still linked with libnghttp3 (but not with libngtcp2):
% otool -L /opt/local/lib/libcurl.dylib
/opt/local/lib/libcurl.dylib:
/opt/local/lib/libcurl.4.dylib (compatibility version 13.0.0, current version 13.0.0)
/opt/local/lib/libnghttp3.9.dylib (compatibility version 11.0.0, current version 11.0.0)
/opt/local/lib/libnghttp2.14.dylib (compatibility version 41.0.0, current version 41.0.0)
/opt/local/lib/libidn2.0.dylib (compatibility version 5.0.0, current version 5.0.0)
/opt/local/lib/libpsl.5.dylib (compatibility version 9.0.0, current version 9.4.0)
/opt/local/libexec/openssl3/lib/libssl.3.dylib (compatibility version 3.0.0, current version 3.0.0)
/opt/local/libexec/openssl3/lib/libcrypto.3.dylib (compatibility version 3.0.0, current version 3.0.0)
/opt/local/lib/libzstd.1.dylib (compatibility version 1.0.0, current version 1.5.5)
/opt/local/lib/libbrotlidec.1.dylib (compatibility version 1.0.0, current version 1.1.0)
/opt/local/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.3.1)
/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1856.105.0)
/System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices (compatibility version 1.0.0, current version 1141.1.0)
/System/Library/Frameworks/SystemConfiguration.framework/Versions/A/SystemConfiguration (compatibility version 1.0.0, current version 1163.60.3)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1311.0.0)
It correctly links with libngtcp2 and libnghttp3 and enables http3 support if I use the --with-ngtcp2 and --with-nghttp3 configure flags, and it correctly does not link with libngtcp2 or libnghttp3 if I use the --without-ngtcp2 and --without-nghttp3 configure flags.
I expected the following
I expected the configure script not to check for libnghttp3 and for libcurl not to be linked with libnghttp3 unless http3 support was enabled with the --with-ngtcp2 and --with-nghttp3 configure flags.
curl/libcurl version
curl 8.6.0
operating system
macOS 12.7.2
Activity
bagder commentedon Jan 31, 2024
It happens because it first finds an OpenSSL version with QUIC functionality, which is then a signal to check for nghttp3 as well. This is for building the experimental HTTP/3 support using the OpenSSL QUIC stack.But yes, it should not be done implied like this...Update: hm, no. I talked too soon. I don't know why this happens
bagder commentedon Jan 31, 2024
@icing any idea?
configure, do not link nghttp3 unless necessary
icing commentedon Feb 5, 2024
The fix in our configure had a typo and was not properly disengaging nghttp3. Fix in #12864.
configure: do not link with nghttp3 unless necessary