[cffi-devel] The use of wrappers in deployed applications

John Fremlin jf at msi.co.jp
Fri Jan 30 06:05:11 UTC 2009


Martin Simmons <martin at lispworks.com> writes:
[...]
>> --- a/addons/cffi/grovel/grovel.lisp
>> +++ b/addons/cffi/grovel/grovel.lisp
>> @@ -767,7 +767,10 @@ error:
>>        (format out ";;;; This file was automatically generated by cffi-grovel.~%
>>                     ;;;; Do not edit by hand.~%")
>>        (let ((*package* (find-package '#:cl)))
>> -        (format out "~%~S~%" `(cffi:load-foreign-library ,lib-file)))
>> +        (format out "~%~S~%" `(cffi:load-foreign-library 
>> +                               '(:or ,lib-file
>> +                                 ,(file-namestring lib-file)
>> +                                 (:default ,(pathname-name lib-file))))))
>>        (dolist (form lisp-forms)
>>          (print form out))
>>        (terpri out))
>> 
>> This patch doesn't help, because once the shared objects are loaded
>> (before delivery) the path is stored by the Lisp environment and the
>> other paths are not used.
>> 
>> Any advice or suggestions?
>
> I strongly recommend calling cffi:load-foreign-library at run time
> only (never before delivery).  That gives you control over how the
> library is loaded on startup (for example reporting errors to the
> user).

Thanks for your input. I guess that is a very sensible approach on all
Lisps except Allegro which bundles the shared objects.

Luis, would you consider a patch to add a special variable
*cffi-wrapper-delay-load* which would set a special mode for the
generated wrapper.lisps?

This mode would inhibit the loading of generated shared objects and the
definition of functions depending on them, so that the image can be
saved. When the image is loaded then the definitions should be made at
that time.





More information about the cffi-devel mailing list