3

Is it sufficient to check whether the module-file-suffix variable exists an is not nil to tell whether the running Emacs supports dynamic module loading?

I'd like to be sure that an instance of Emacs I did not build myself was built using make after configuring with the --with-modules configure switch. Id like to detect this in Emacs Lisp code.

The docstring of that Emacs Lisp variable seems to indicate that it's sufficient to detect it, yet something I know depends on dynamic module loading does not seem to work and I suspect that the module loading mechanism does not work properly in that instance of Emacs.

Are there better ways to detect the support of dynamic module loading?

2
  • 1
    "something I know depends on dynamic module loading does not seem to work and I suspect that the module loading mechanism does not work properly in that instance of Emacs" FYI: You might consider filing an Emacs bug, to specify this: M-x report-emacs-bug.
    – Drew
    Feb 14, 2022 at 4:47
  • 1
    At this point I don't have enough information to state it's an Emacs bug. Something else might be the case of the problem (ie the loaded module itself crashing). That's why I want to first identify for sure that dynamic module loading is actually supported by the Emacs process instance.
    – PRouleau
    Feb 14, 2022 at 14:46

1 Answer 1

1

If I compile --without-modules then apropos shows me the following relevant matches for the pattern module:

module-file-suffix
  Variable: Suffix of loadable module file, or nil if modules are not
            supported.
  Properties: variable-documentation

module-function-p
  Function: Return t if OBJECT is a function loaded from a dynamic
            module.

and

module-file-suffix is a variable defined in ‘C source code’.

Its value is nil

Suffix of loadable module file, or nil if modules are not supported.

If I compile with modules then I get:

module-file-suffix is a variable defined in ‘C source code’.

Its value is ".so"

Suffix of loadable module file, or nil if modules are not supported.

and apropos also now shows me an additional function:

module-load
  Function: Load module FILE.

Along with a bunch of error symbols ("Properties: error-conditions error-message") which also weren't there previously:

missing-module-init-function
module-init-failed
module-load-failed
module-not-gpl-compatible
module-open-failed

So my take is that the value of module-file-suffix should be a valid test (and I agree with Drew that you should report a bug if you are seeing inconsistent results); but if you wanted to then you could test (fboundp 'module-load) instead (however this is not documented to be an reliable test).

1
  • Thanks Phils. In order for me to identify the problem I'm facing I'll have to dig further inside the code of the module. You answered the question related to the Emacs side.
    – PRouleau
    Feb 15, 2022 at 23:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.