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

From: Andy Moreton <[email-masked]>
Date: Wed, 20 Dec 2017 13:16:34 +0000

On Wed 20 Dec 2017, Andy Moreton wrote:

> 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.

Please ignore the previous patch - this version has been tested:

diff --git a/src/gnutls.c b/src/gnutls.c
index 8db201ae83..acea77ba32 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.  */
@@ -2439,15 +2443,6 @@ Any GnuTLS extension with ID up to 100
   capabilities = Fcons (intern("macs"), capabilities);
 # endif	  /* HAVE_GNUTLS3 */
 
-  for (unsigned int ext=0; ext < 100; ext++)
-    {
-      const char* name = gnutls_ext_get_name(ext);
-      if (name != NULL)
-        {
-          capabilities = Fcons (intern(name), capabilities);
-        }
-    }
-
 # ifdef WINDOWSNT
   Lisp_Object found = Fassq (Qgnutls, Vlibrary_cache);
   if (CONSP (found))
@@ -2462,6 +2457,15 @@ Any GnuTLS extension with ID up to 100
 # endif /* WINDOWSNT */
 #endif	/* HAVE_GNUTLS */
 
+  for (unsigned int ext=0; ext < 100; ext++)
+    {
+      const char* name = gnutls_ext_get_name(ext);
+      if (name != NULL)
+        {
+          capabilities = Fcons (intern(name), capabilities);
+        }
+    }
+
   return capabilities;
 }