[libvirt] [PATCH] build: fix build with newer gnutls

Building with gnutls 3.2.0 (such as shipped with current cygwin) fails with: rpc/virnettlscontext.c: In function 'virNetTLSSessionGetKeySize': rpc/virnettlscontext.c:1358:5: error: implicit declaration of function 'gnutls_cipher_get_key_size' [-Wimplicit-function-declaration] Yeah, it's stupid that gnutls broke API by moving their declaration into a new header without including that header from the old one, but it's easy enough to work around, all without breaking on gnutls 1.4.1 (hello RHEL 5) that lacked the new header. * src/rpc/virnettlscontext.c (includes): Include additional header. * configure.ac (gnutls): Check for <gnutls/crypto.h>. Signed-off-by: Eric Blake <eblake@redhat.com> --- Pushing under the build-breaker rule, once my testing completes across multiple systems with various gnutls versions (1.4.1 in RHEL5, 2.12.23 in Fedora 18, 3.2.0 in Cygwin). configure.ac | 1 + src/rpc/virnettlscontext.c | 3 +++ 2 files changed, 4 insertions(+) diff --git a/configure.ac b/configure.ac index 7041710..0b3d028 100644 --- a/configure.ac +++ b/configure.ac @@ -1087,6 +1087,7 @@ if test "x$with_gnutls" != "xno"; then if test "$GNUTLS_FOUND" = "no"; then fail=0 AC_CHECK_HEADER([gnutls/gnutls.h], [], [fail=1]) + AC_CHECK_HEADERS([gnutls/crypto.h]) AC_CHECK_LIB([gnutls], [gnutls_handshake],[], [fail=1], [-lgcrypt]) test $fail = 0 && GNUTLS_FOUND=yes diff --git a/src/rpc/virnettlscontext.c b/src/rpc/virnettlscontext.c index e29c439..f2ac551 100644 --- a/src/rpc/virnettlscontext.c +++ b/src/rpc/virnettlscontext.c @@ -25,6 +25,9 @@ #include <stdlib.h> #include <gnutls/gnutls.h> +#if HAVE_GNULTLS_CRYPTO_H +# include <gnutls/crypto.h> +#endif #include <gnutls/x509.h> #include "gnutls_1_0_compat.h" -- 1.8.1.4

On 05/28/2013 09:23 PM, Eric Blake wrote:
Building with gnutls 3.2.0 (such as shipped with current cygwin) fails with:
rpc/virnettlscontext.c: In function 'virNetTLSSessionGetKeySize': rpc/virnettlscontext.c:1358:5: error: implicit declaration of function 'gnutls_cipher_get_key_size' [-Wimplicit-function-declaration]
Yeah, it's stupid that gnutls broke API by moving their declaration into a new header without including that header from the old one, but it's easy enough to work around, all without breaking on gnutls 1.4.1 (hello RHEL 5) that lacked the new header.
* src/rpc/virnettlscontext.c (includes): Include additional header. * configure.ac (gnutls): Check for <gnutls/crypto.h>.
Signed-off-by: Eric Blake <eblake@redhat.com> ---
Pushing under the build-breaker rule, once my testing completes across multiple systems with various gnutls versions (1.4.1 in RHEL5, 2.12.23 in Fedora 18, 3.2.0 in Cygwin).
Or not - it failed my builds.
+++ b/configure.ac @@ -1087,6 +1087,7 @@ if test "x$with_gnutls" != "xno"; then if test "$GNUTLS_FOUND" = "no"; then fail=0 AC_CHECK_HEADER([gnutls/gnutls.h], [], [fail=1]) + AC_CHECK_HEADERS([gnutls/crypto.h])
This line needs tweaking to pre-include <gnutls/gnutls.h> before probing for crypto.h. I'll post a v2 once I complete more testing. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

Building with gnutls 3.2.0 (such as shipped with current cygwin) fails with: rpc/virnettlscontext.c: In function 'virNetTLSSessionGetKeySize': rpc/virnettlscontext.c:1358:5: error: implicit declaration of function 'gnutls_cipher_get_key_size' [-Wimplicit-function-declaration] Yeah, it's stupid that gnutls broke API by moving their declaration into a new header without including that header from the old one, but it's easy enough to work around, all without breaking on gnutls 1.4.1 (hello RHEL 5) that lacked the new header. * src/rpc/virnettlscontext.c (includes): Include additional header. * configure.ac (gnutls): Check for <gnutls/crypto.h>. Signed-off-by: Eric Blake <eblake@redhat.com> --- This version passed testing; pushing under the build-breaker rule. configure.ac | 7 +++++-- src/rpc/virnettlscontext.c | 3 +++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 2055637..8efbb04 100644 --- a/configure.ac +++ b/configure.ac @@ -1103,10 +1103,13 @@ if test "x$with_gnutls" != "xno"; then dnl it explicitly for the calls to gcry_control/check_version GNUTLS_LIBS="$GNUTLS_LIBS -lgcrypt" - dnl We're not using gcrypt deprecated features so define GCRYPT_NO_DEPRECATED - dnl to avoid deprecated warnings + dnl We're not using gcrypt deprecated features so define + dnl GCRYPT_NO_DEPRECATED to avoid deprecated warnings GNUTLS_CFLAGS="$GNUTLS_CFLAGS -DGCRYPT_NO_DEPRECATED" + dnl gnutls 3.x moved some declarations to a new header + AC_CHECK_HEADERS([gnutls/crypto.h], [], [], [[#include <gnutls/gnutls.h>]]) + with_gnutls=yes fi diff --git a/src/rpc/virnettlscontext.c b/src/rpc/virnettlscontext.c index e29c439..f2ac551 100644 --- a/src/rpc/virnettlscontext.c +++ b/src/rpc/virnettlscontext.c @@ -25,6 +25,9 @@ #include <stdlib.h> #include <gnutls/gnutls.h> +#if HAVE_GNULTLS_CRYPTO_H +# include <gnutls/crypto.h> +#endif #include <gnutls/x509.h> #include "gnutls_1_0_compat.h" -- 1.8.1.4
participants (1)
-
Eric Blake