Re: [PATCH 5/8] meson: detect libcurl-gnutls

Martin Schanzenbach <[email protected]> Fri, 10 Oct 2025 09:07:50 +0200
Newsgroups gmane.network.gnunet.devel
Message-ID <[email protected]>
Hello,

thank you for the patches.
I have not gotten around applying the patches that look fine yet, but I
can already tell that this problem needs to be fixed in other ways.

There is a reason the GNUTLS check cannot be done in the preprocessor:
THe define will always be there, it needs to be checked _at runtime_
against which TLS backend curl is linked.

Now, some OSes have a libcurl-gnutls (I think debian does), but not all
of them. Some link libcurl against gnutls.
So this patch will also not work as expected.

I also do not understand how moving the runtime check to the
preprocessor is any different in a cross-compile scenario. If your
environment is cross-compiling, the runtime check should work as
expected.

I do understand the problem, and maybe we can simply have a runtime
check in the binaries.

BR
Martin

On Fri, 2025-10-10 at 02:13 +0100, Daniel Golle wrote:
> Instead of only checking if cURL is built against gnuTLS, also test
> of
> there is a dedicated libcurl-gnutls library and favor using it.
> ---
> =C2=A0meson.build | 67 +++++++++++++++++++++++++++++++++++++++++---------=
-
> --
> =C2=A01 file changed, 52 insertions(+), 15 deletions(-)
>=20
> diff --git a/meson.build b/meson.build
> index 7f7856b03..3ee4dd890 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -189,10 +189,17 @@ if not sqlite_dep.found()
> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 error('Sqlite version >=
=3D 3.35.0 requried')
> =C2=A0=C2=A0=C2=A0=C2=A0 endif
> =C2=A0endif
> -curl_dep =3D dependency('libcurl', version: '>=3D7.85.0', required:
> false)
> -if not curl_dep.found()
> -=C2=A0=C2=A0=C2=A0 curl_dep =3D cc.find_library('curl', required: true)
> -=C2=A0=C2=A0=C2=A0 curl_version_check =3D '''#include <curl/curl.h>
> +
> +curl_gnutls_dep =3D dependency(
> +=C2=A0=C2=A0=C2=A0 'libcurl-gnutls',
> +=C2=A0=C2=A0=C2=A0 version: '>=3D7.85.0',
> +=C2=A0=C2=A0=C2=A0 required: false,
> +)
> +if not curl_gnutls_dep.found()
> +=C2=A0=C2=A0=C2=A0 curl_gnutls_dep =3D cc.find_library('curl-gnutls', re=
quired:
> false)
> +endif
> +
> +curl_version_check =3D '''#include <curl/curl.h>
> =C2=A0=C2=A0 int main(int argc, char **argv) {
> =C2=A0=C2=A0=C2=A0=C2=A0 #if LIBCURL_VERSION_NUM < 0x075500
> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 #error "cURL version >=3D 7.85.0 req=
uired"
> @@ -200,12 +207,34 @@ if not curl_dep.found()
> =C2=A0=C2=A0=C2=A0=C2=A0 return 0;
> =C2=A0=C2=A0=C2=A0=C2=A0 }
> =C2=A0=C2=A0 '''
> -=C2=A0=C2=A0=C2=A0 if not cc.compiles(
> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 curl_version_check,
> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 name: 'cURL version check',
> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 dependencies: curl_dep,
> -=C2=A0=C2=A0=C2=A0 )
> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 error('cURL version >=3D7.85.=
0 required')
> +
> +# If libcurl-gnutls found, use it and we know it has gnutls support
> +curl_is_gnutls =3D false
> +if curl_gnutls_dep.found()
> +=C2=A0=C2=A0=C2=A0 curl_dep =3D curl_gnutls_dep
> +=C2=A0=C2=A0=C2=A0 curl_is_gnutls =3D true
> +=C2=A0=C2=A0=C2=A0 # Check version for libcurl-gnutls if it was found vi=
a
> find_library
> +=C2=A0=C2=A0=C2=A0 if curl_gnutls_dep.type_name() !=3D 'pkgconfig'
> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if not cc.compiles(
> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 curl_=
version_check,
> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 name:=
 'cURL-gnutls version check',
> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 depen=
dencies: curl_dep,
> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 )
> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 error=
('libcurl-gnutls version >=3D7.85.0 required')
> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 endif
> +=C2=A0=C2=A0=C2=A0 endif
> +else
> +=C2=A0=C2=A0=C2=A0 # Fall back to regular libcurl
> +=C2=A0=C2=A0=C2=A0 curl_dep =3D dependency('libcurl', version: '>=3D7.85=
.0', required:
> false)
> +=C2=A0=C2=A0=C2=A0 if not curl_dep.found()
> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 curl_dep =3D cc.find_library(=
'curl', required: true)
> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if not cc.compiles(
> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 curl_=
version_check,
> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 name:=
 'cURL version check',
> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 depen=
dencies: curl_dep,
> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 )
> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 error=
('cURL version >=3D7.85.0 required')
> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 endif
> =C2=A0=C2=A0=C2=A0=C2=A0 endif
> =C2=A0endif
> =C2=A0zlib_dep =3D dependency('zlib', required: false)
> @@ -487,11 +516,19 @@ curl_ssl_check =3D '''#include <curl/curl.h>
> =C2=A0=C2=A0=C2=A0=C2=A0 }
> =C2=A0=C2=A0 '''
> =C2=A0
> -curl_gnutls_available =3D cc.compiles(
> -=C2=A0=C2=A0=C2=A0 curl_ssl_check,
> -=C2=A0=C2=A0=C2=A0 name: 'cURL gnutls check',
> -=C2=A0=C2=A0=C2=A0 dependencies: curl_dep,
> -)
> +# Check if we found libcurl-gnutls (has gnutls support by
> definition)
> +curl_gnutls_available =3D false
> +if curl_is_gnutls
> +=C2=A0=C2=A0=C2=A0 curl_gnutls_available =3D true
> +else
> +=C2=A0=C2=A0=C2=A0 # Fall back to compile-time check for regular libcurl=
 with
> gnutls support
> +=C2=A0=C2=A0=C2=A0 curl_gnutls_available =3D cc.compiles(
> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 curl_ssl_check,
> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 name: 'cURL gnutls check',
> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 dependencies: curl_dep,
> +=C2=A0=C2=A0=C2=A0 )
> +endif
> +
> =C2=A0private_config.set('curl_gnutls', 0)
> =C2=A0if curl_gnutls_available
> =C2=A0=C2=A0=C2=A0=C2=A0 private_config.set('curl_gnutls', 1)