Commit 28268e47 authored by Philipp Stephani's avatar Philipp Stephani

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.
parent 7c5d6a2a
Pipeline #4389 failed with stage
in 57 minutes and 51 seconds
......@@ -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])
......
......@@ -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"));
......
......@@ -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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment