emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 28268e4: Support .dylib suffix for modules on macOS (Bug#36226).


From: Philipp Stephani
Subject: master 28268e4: Support .dylib suffix for modules on macOS (Bug#36226).
Date: Wed, 25 Dec 2019 09:51:30 -0500 (EST)

branch: master
commit 28268e47d844215b11f9a731d2bedb58bee0b343
Author: Philipp Stephani <address@hidden>
Commit: Philipp Stephani <address@hidden>

    Support .dylib suffix for modules on macOS (Bug#36226).
    
    On macOS, shared libraries typically have the suffix .dylib.  This
    commit switches the module suffix to .dylib on Darwin to account for
    that.  To also support the .so suffix, introduce the concept of a
    secondary module suffix.
    
    * configure.ac: Switch MODULES_SUFFIX to .dylib for Darwin, introduce
    MODULES_SECONDARY_SUFFIX.
    
    * src/lread.c (Fload, syms_of_lread): Also use
    MODULES_SECONDARY_SUFFIX if defined.
    
    * test/src/emacs-module-tests.el (module-darwin-secondary-suffix): New
    unit test.
---
 configure.ac                   | 10 ++++++++++
 src/lread.c                    | 17 ++++++++++++++++-
 test/src/emacs-module-tests.el | 18 ++++++++++++++++++
 3 files changed, 44 insertions(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index 1727bdc..f24597a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3676,8 +3676,13 @@ HAVE_MODULES=no
 MODULES_OBJ=
 case $opsys in
   cygwin|mingw32) MODULES_SUFFIX=".dll" ;;
+  darwin) MODULES_SUFFIX=".dylib" ;;
   *) MODULES_SUFFIX=".so" ;;
 esac
+case "${opsys}" in
+  darwin) MODULES_SECONDARY_SUFFIX='.so' ;;
+  *) MODULES_SECONDARY_SUFFIX='' ;;
+esac
 if test "${with_modules}" != "no"; then
   case $opsys in
     gnu|gnu-linux)
@@ -3708,11 +3713,16 @@ if test "${HAVE_MODULES}" = yes; then
    AC_DEFINE(HAVE_MODULES, 1, [Define to 1 if dynamic modules are enabled])
    AC_DEFINE_UNQUOTED(MODULES_SUFFIX, "$MODULES_SUFFIX",
      [System extension for dynamic libraries])
+   if test -n "${MODULES_SECONDARY_SUFFIX}"; then
+     AC_DEFINE_UNQUOTED(MODULES_SECONDARY_SUFFIX, "$MODULES_SECONDARY_SUFFIX",
+       [Alternative system extension for dynamic libraries.])
+   fi
 fi
 AC_SUBST(MODULES_OBJ)
 AC_SUBST(LIBMODULES)
 AC_SUBST(HAVE_MODULES)
 AC_SUBST(MODULES_SUFFIX)
+AC_SUBST(MODULES_SECONDARY_SUFFIX)
 
 AC_CONFIG_FILES([src/emacs-module.h])
 AC_SUBST_FILE([module_env_snippet_25])
diff --git a/src/lread.c b/src/lread.c
index 7b3686b..6329172 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -1199,6 +1199,9 @@ Return t if the file exists and loads successfully.  */)
              || suffix_p (file, ".elc")
 #ifdef HAVE_MODULES
              || suffix_p (file, MODULES_SUFFIX)
+#ifdef MODULES_SECONDARY_SUFFIX
+              || suffix_p (file, MODULES_SECONDARY_SUFFIX)
+#endif
 #endif
              )
            must_suffix = Qnil;
@@ -1268,7 +1271,12 @@ Return t if the file exists and loads successfully.  */)
     }
 
 #ifdef HAVE_MODULES
-  bool is_module = suffix_p (found, MODULES_SUFFIX);
+  bool is_module =
+    suffix_p (found, MODULES_SUFFIX)
+#ifdef MODULES_SECONDARY_SUFFIX
+    || suffix_p (found, MODULES_SECONDARY_SUFFIX)
+#endif
+    ;
 #else
   bool is_module = false;
 #endif
@@ -4856,9 +4864,16 @@ This list should not include the empty string.
 `load' and related functions try to append these suffixes, in order,
 to the specified file name if a suffix is allowed or required.  */);
 #ifdef HAVE_MODULES
+#ifdef MODULES_SECONDARY_SUFFIX
+  Vload_suffixes = list4 (build_pure_c_string (".elc"),
+                         build_pure_c_string (".el"),
+                         build_pure_c_string (MODULES_SUFFIX),
+                          build_pure_c_string (MODULES_SECONDARY_SUFFIX));
+#else
   Vload_suffixes = list3 (build_pure_c_string (".elc"),
                          build_pure_c_string (".el"),
                          build_pure_c_string (MODULES_SUFFIX));
+#endif
 #else
   Vload_suffixes = list2 (build_pure_c_string (".elc"),
                          build_pure_c_string (".el"));
diff --git a/test/src/emacs-module-tests.el b/test/src/emacs-module-tests.el
index 1876608..322500f 100644
--- a/test/src/emacs-module-tests.el
+++ b/test/src/emacs-module-tests.el
@@ -384,4 +384,22 @@ Interactively, you can try hitting \\[keyboard-quit] to 
quit."
     (ert-info ((format "input: %d" input))
       (should (= (mod-test-double input) (* 2 input))))))
 
+(ert-deftest module-darwin-secondary-suffix ()
+  "Check that on Darwin, both .so and .dylib suffixes work.
+See Bug#36226."
+  (skip-unless (eq system-type 'darwin))
+  (should (member ".dylib" load-suffixes))
+  (should (member ".so" load-suffixes))
+  ;; Preserve the old `load-history'.  This is needed for some of the
+  ;; other unit tests that indirectly rely on `load-history'.
+  (let ((load-history load-history)
+        (dylib (concat mod-test-file ".dylib"))
+        (so (concat mod-test-file ".so")))
+    (should (file-regular-p dylib))
+    (should-not (file-exists-p so))
+    (add-name-to-file dylib so)
+    (unwind-protect
+        (load so nil nil :nosuffix :must-suffix)
+      (delete-file so))))
+
 ;;; emacs-module-tests.el ends here



reply via email to

[Prev in Thread] Current Thread [Next in Thread]