>>>>> "ra" == R Alemi <[EMAIL PROTECTED]> writes:

  ra> However, the un-compiled version is very slow, and if I compile
  ra> the files, then gl-bindings.x86f and gl-routines.x86f won't load
  ra> in cmucl. they would complain that they don't know where gl*()
  ra> functions are. so I have to first load the libraries.

indeed, you must load foreign libraries before loading any FASL
(compiled lisp) files that reference foreign functions from those
libraries. You can't do "late binding" of references to foreign code.

The usual way to work around this problem is to use a system
definition tool such as ASDF. Add a file that loads your foreign
libraries to the system, and ensure that this file is loaded before
any source files that reference foreign functions, for both
system compilation and system load. For an example of how to do this
with ASDF, see

<http://common-lisp.net/cgi-bin/viewcvs.cgi/pg/pg.asd?rev=1.4
&cvsroot=pg&content-type=text/vnd.viewcvs-markup>


  ra> Michael Naunton has kindly instructed me to add
  ra> an :init-function and load the libraries there, but the function
  ra> should also load every file that uses those libraries. this
  ra> defeats the purpose of a core image.

unfortunately, CMUCL does not reload foreign libraries when you
restart a saved image. You could try using SYS::LOAD-OBJECT-FILE to
load your shared libraries (instead of EXT:LOAD-FOREIGN), and adding
the following code to your project:

,----
| (defun reload-global-table ()
|   (loop :for lib-entry in sys::*global-table*
|       :for (sap . lib-path) = lib-entry
|         :when lib-path :do
|         (let ((new-sap (sys::dlopen (namestring lib-path)
|                                     (logior sys::rtld-now sys::rtld-global))))
|           (when (zerop (sys:sap-int new-sap))
|             (error "Couldn't open library ~S: ~S" lib-path (sys::dlerror)))
|           (setf (car lib-entry) new-sap)))
|   (alien:alien-funcall (alien:extern-alien "os_resolve_data_linkage"
|                                          (alien:function c-call:void))))
| 
| (pushnew 'reload-global-table ext:*after-save-initializations*)
`----

Hopefully this problem will be fixed in the next release.

-- 
Eric Marsden                          <URL:http://www.laas.fr/~emarsden/>

Reply via email to