Subject: Re: Implementing Lisp in C?
From: rpw3@rpw3.org (Rob Warnock)
Date: Sun, 11 Apr 2004 07:18:34 -0500
Newsgroups: comp.lang.lisp
Message-ID: <PJSdne0zmMIHquTdRVn-gQ@speakeasy.net>
Duane Rettig  <duane@franz.com> wrote:
+---------------
| rpw3@rpw3.org (Rob Warnock) writes:
| > Somebody posted some code here just recently to do *exactly* that...
| > From: Eric Marsden <emarsden@laas.fr>
| > <http://www.google.com/groups?as_umsgid=wzin05x9wjt.fsf%40melbourne.laas.fr>
| > The function RELOAD-SHARED-LIBRARIES, which he cheerfully admits is
| > CMUCL-specific and nowhere near "supported".
| 
| This looks correct, but there's still a piece missing (though CMUCL might
| already do this anyway): When a user does a
| dumplisp/save-image/whatever-it's-called-by-your-vendor the reborn
| lisp image should for the most part come back up the way it had been
| before.  So all those loaded .so files should also be re-loaded if
| they exist...
+---------------

No, CMUCL doesn't try to do this for you. In fact, there's a warning
in the CMUCL User's Manual in the section on the "Alien" FFI stuff:

    8.6 Loading Unix Object Files
    Foreign object files are loaded into the running Lisp process
    by LOAD-FOREIGN...
    Note that if a Lisp core image is saved (using SAVE-LISP),
    all loaded foreign code is lost when the image is restarted.

[The same is equally true if you use the internal SYSTEM::LOAD-OBJECT-FILE
to load ".so" files directly, as some of us do...]

That said, though, CMUCL *does* provide an *AFTER-SAVE-INITIALIZATIONS*
hook -- "a list of functions which are called when a saved core image
starts up" -- so before saving the image you can push a closure onto
this hook to (re)load stuff for you.

+---------------
| (this part is a stickler, since the dumped image might be moved
| to a different directory or even to a different machine, but it
| is resolvable, especially by using logical pathnames).
+---------------

That helps, but varying versions of operating systems and/or system
libraries might create further portability problems, just as they do
with C programs that use shared libs.

+---------------
| For Allegro CL, we have a FAQ entry, with the question "How does Lisp
| start up, in terms of shared-library linking and loading?" which is at
|   http://www.franz.com/support/documentation/6.2/doc/faq/faq3-9.htm#393
| Note specifically bullet 9 in the section labelled "The Startup Process".
+---------------

Interesting, thanks!


-Rob

-----
Rob Warnock			<rpw3@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607