Subject: bug#25061: consider adding %COMPAT to default gnutls priority string

From: Andy Moreton <[email-masked]>
Date: Wed, 20 Dec 2017 12:54:45 +0000

On Tue 19 Dec 2017, Ted Zlatanov wrote:

> On Tue, 19 Dec 2017 22:00:34 +0000 Kaushal Modi <[email-masked]> wrote: 
>
> KM> I couldn't test the fix on my local machine because I cannot recreate the
> KM> problem there.
>
> KM> So I was waiting for the emacs-26 branch build to finish on the Travis CI
> KM> set up by Noam.. but the build itself failed:
> KM> https://travis-ci.org/npostavs/emacs-travis/jobs/318857869
>
> KM>   CC       lastfile.o
> KM>   CCLD     temacs
> KM> gnutls.o: In function `Fgnutls_available_p':
> KM> gnutls.c:(.text+0x105d): undefined reference to `gnutls_ext_get_name'
> KM> collect2: error: ld returned 1 exit status
> KM> make[1]: *** [temacs] Error 1
> KM> make[1]: Leaving directory `/tmp/emacs-emacs-26/src'
> KM> make: *** [src] Error 2
> KM> make: Leaving directory `/tmp/emacs-emacs-26'
>
> I don't understand why. This function has been available since GnuTLS
> was created, according to the docs. Do we know what GnuTLS version is used
> in Travis CI?

The Windows builds of emacs use runtime imports of GnuTLS functions, so
that emacs will still run on a system that does not have the required
DLLs installed.

The following patch fixes this:

diff --git a/src/gnutls.c b/src/gnutls.c
index 8db201ae83..f2b078d964 100644
--- a/src/gnutls.c
+++ b/src/gnutls.c
@@ -238,6 +238,7 @@ DEF_DLL_FN (int, gnutls_hash, (gnutls_hash_hd_t, const void *, size_t));
 DEF_DLL_FN (void, gnutls_hash_deinit, (gnutls_hash_hd_t, void *));
 DEF_DLL_FN (void, gnutls_hash_output, (gnutls_hash_hd_t, void *));
 #  endif        /* HAVE_GNUTLS3 */
+DEF_DLL_FN (const char *, gnutls_ext_get_name, (unsigned int));

 static bool
@@ -357,6 +358,7 @@ init_gnutls_functions (void)
   LOAD_DLL_FN (library, gnutls_hash_deinit);
   LOAD_DLL_FN (library, gnutls_hash_output);
 #  endif        /* HAVE_GNUTLS3 */
+  LOAD_DLL_FN (library, gnutls_ext_get_name);

   max_log_level = global_gnutls_log_level;

@@ -470,6 +472,8 @@ init_gnutls_functions (void)
 #  define gnutls_hash_deinit fn_gnutls_hash_deinit
 #  define gnutls_hash_output fn_gnutls_hash_output
 #  endif        /* HAVE_GNUTLS3 */
+#  define gnutls_ext_get_name fn_gnutls_ext_get_name

 /* This wrapper is called from fns.c, which doesn't know about the
    LOAD_DLL_FN stuff above.  */