Subject: Re: bug#78416: [PATCH] * src/lread.c (get-load-suffixes): Avoid module suffix with compressed suffix

From: Lin Sun <[email-masked]>
Date: Wed, 21 May 2025 20:43:15 +0000

From: Eli Zaretskii <[email-masked]>
Sent: Saturday, May 17, 2025 06:57 AM

> Thanks, but I think you've misunderstood the comments.  We should only
> ignore the ".gz" suffix.  Ignoring other suffixes would be a potential
> regression, because there's nothing wrong in trying to load a file
> called, say, foobar.so.abc.  The current code supports that, and I see
> no reason to drop that support.

> The ".gz" suffix gets in the way because dynamic loaders cannot load
> such compressed shared libraries.

> So the condition for not appending a suffix from
> load-file-rep-suffixes should also test the value of 'ext', and only
> refuse to append it if it compares equal with ".gz".

Yes, you're right.

According to the document of "load-file-rep-suffixes", the "jka-compr-load-suffixes" is used for the compressed suffixes.
So I attach a new patch, the patch will seek the "jka-compr-load-suffixes" to determine the compressed suffixes for emacs module and skip it.
Please check the attached patch for details. Thank you.

From 996f8f8fa776df91ebdced04d72e60ef1492ca6a Mon Sep 17 00:00:00 2001
From: Lin Sun <[email-masked]>
Date: Wed, 14 May 2025 06:30:34 +0000
Subject: [PATCH] * src/lread.c (get-load-suffixes): Avoid module suffix with
 compressed suffix

---
 src/lread.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/src/lread.c b/src/lread.c
index 95c9e711130..cf57c14eaef 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -1205,7 +1205,21 @@ DEFUN ("get-load-suffixes", Fget_load_suffixes, Sget_load_suffixes, 0, 0, 0,
       Lisp_Object exts = Vload_file_rep_suffixes;
       Lisp_Object suffix = XCAR (suffixes);
       FOR_EACH_TAIL (exts)
-	lst = Fcons (concat2 (suffix, XCAR (exts)), lst);
+	{
+	  Lisp_Object ext = XCAR (exts);
+#ifdef HAVE_MODULES
+	  if (SCHARS (ext) > 0
+	      && (suffix_p (suffix, MODULES_SUFFIX)
+# ifdef MODULES_SECONDARY_SUFFIX
+		  || suffix_p (suffix, MODULES_SECONDARY_SUFFIX)
+# endif
+		 )
+	      && !NILP (Fmember (ext, Fsymbol_value (
+					Qjka_compr_load_suffixes))))
+	    continue;
+#endif
+	  lst = Fcons (concat2 (suffix, ext), lst);
+	}
     }
   return Fnreverse (lst);
 }
@@ -5926,6 +5940,8 @@ syms_of_lread (void)
 customize `jka-compr-load-suffixes' rather than the present variable.  */);
   Vload_file_rep_suffixes = list1 (empty_unibyte_string);
 
+  DEFSYM (Qjka_compr_load_suffixes, "jka-compr-load-suffixes");
+
   DEFVAR_BOOL ("load-in-progress", load_in_progress,
 	       doc: /* Non-nil if inside of `load'.  */);
   DEFSYM (Qload_in_progress, "load-in-progress");
-- 
2.34.1