emacs-devel
[Top][All Lists]
Advanced

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

Re: Dynamic loading progress


From: Aurélien Aptel
Subject: Re: Dynamic loading progress
Date: Thu, 3 Jul 2014 19:09:46 +0200

On Wed, Jul 2, 2014 at 11:33 PM, Andreas Schwab <address@hidden> wrote:
> You need to declare Ffmod with EXFUN.

Thanks, it almost worked. In order to use emacs symbols from a
dynamically loaded module I had to add a linker option to export the
symbols from emacs. The option is -Wl,--export-dynamic. (updated in
configure.ac)

I then ran into another problem: the module is loaded correctly but
emacs_abort() is called inside defsubr(). The actual call was in
intern_c_string_1 where I made the following change:

 Lisp_Object
 intern_c_string_1 (const char *str, ptrdiff_t len)
 {
   Lisp_Object obarray = check_obarray (Vobarray);
   Lisp_Object tem = oblookup (obarray, str, len, len);

   if (SYMBOLP (tem))
     return tem;

   if (NILP (Vpurify_flag))
-    /* Creating a non-pure string from a string literal not
-       implemented yet.  We could just use make_string here and live
-       with the extra copy.  */
-    emacs_abort ();
+    return Fintern (make_string (str, len), obarray);

   return Fintern (make_pure_c_string (str, len), obarray);
 }

I'm not familiar with all the dumping intricacies but judging from the
comment this change seems harmless (Can someone confirm this?).
I've made a modules directory with the sample module and a Makefile
which has to be run separately for now.

Here's the whole procedure the test it for anyone interested:

# get a recent copy of emacs sources
$ wget -O e.zip https://github.com/mirrors/emacs/archive/master.zip
$ unzip e.zip

# apply attached diff
$ cd emacs-master
$ patch -p1 < path/to/dynamic-loading-2.diff

# compile
$ ./autogen.sh && ./configure && make -j8

# compile & test module
$ make -C modules
$ ./src/emacs -Q --batch --eval '(progn (load-module
"modules/fmod.so") (message "%f" (fmod 2.4 2)))'
0.400000

Pretty cool if you ask me :)

The next steps are:
- handle doc strings
- handle features related stuff (provide, require, run-after-load hooks, ...)
- making it portable
- ?

Attachment: dynamic-loading-2.diff
Description: Text document


reply via email to

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