How to save a common Lisp image using SBCL?

If I want to create a Lisp image of my program, how do I do it right? Are there any prerequisites? And doesn't he play well with QUICKLISP?

Right now, if I run SBCL (with QUICKLISP preloaded) and save the image:

(save-lisp-and-die "core") 

And then try running SBCL again with this image

 sbcl --core core 

And then try to do:

 (ql:quickload :cl-yaclyaml) 

I get the following:

 To load "cl-yaclyaml": Load 1 ASDF system: cl-yaclyaml ; Loading "cl-yaclyaml" ....... debugger invoked on a SB-INT:EXTENSION-FAILURE in thread #<THREAD "main thread" RUNNING {100322C613}>: Don't know how to REQUIRE sb-sprof. See also: The SBCL Manual, Variable *MODULE-PROVIDER-FUNCTIONS* The SBCL Manual, Function REQUIRE Type HELP for debugger help, or (SB-EXT:EXIT) to exit from SBCL. restarts (invokable by number or by possibly-abbreviated name): 0: [RETRY ] Retry completing load for #<REQUIRE-SYSTEM "sb-sprof">. 1: [ACCEPT ] Continue, treating completing load for #<REQUIRE-SYSTEM "sb-sprof"> as having been successful. 2: Retry ASDF operation. 3: [CLEAR-CONFIGURATION-AND-RETRY] Retry ASDF operation after resetting the configuration. 4: [ABORT ] Give up on "cl-yaclyaml" 5: Exit debugger, returning to top level. (SB-IMPL::REQUIRE-ERROR "Don't know how to ~S ~A." REQUIRE "sb-sprof") 0] 

Alternatively, if I try:

 (require 'sb-sprof) 

when sbcl starts with a saved kernel, I get the same error. If sbcl is running as sbcl , no error messages are reported.

In fact, preloading QUICKLISP is not a problem: the same problem occurs if sbcl is first called with sbcl --no-userinit --no-sysinit .

Am I doing it wrong?

PS. If I use roswell, ros -L sbcl-bin -m core run somehow does not raise the image (it is checked by declaring the variable *A* before saving and does not see it after restarting).

PS2. So far, it seems that sbcl does not provide extension modules ( SB-SPROF , SB-POSIX , etc.), unless they are clearly needed to save the image.

+7
source share
2 answers

Thanks for the help from @jkiiski, here is a complete explanation and solution:

  • SBCL uses additional modules ( SB-SPROF , SB-POSIX and others) that are not always loaded into the image. This module is located in the contrib directory, either where the SBCL_HOME environment variable is SBCL_HOME (if installed) or where the image is located (for example, in /usr/local/lib/sbcl/ ).

  • When the image is saved elsewhere, and if SBCL_HOME not set, SBCL will not be able to find contrib , hence the errors that I saw.

  • Setting SBCL_HOME to specify the location of contrib (or copying contrib to the location of the image or a new image to the location of contrib ) solves the problem.

  • Finally, about roswell: the roswell -m option searches for images in a specific location. For SBCL ( sbcl-bin ), it will be something like ~/.roswell/impls/x86-64/linux/sbcl-bin/1.3.7/dump/ . Secondly, the image name for SBCL must be in the form <name>.core . And to get started, use: ros -m <name> -L sbcl-bin run . (Quick editing: it is better to use ros dump to save images using roswell, as I was told)

+6
source

If you want to create executables, you can try the following:

  (sb-ext: save-lisp-and-die 
   "core"
   : compression t
   ;;  this is the main function:
   : toplevel (lambda () 
               (print "hell world")                                      
               0)
   : executable t)

With this, you can call QUICKLOAD as you wish. Perhaps you want to check my extension on CL-PROJECT to create executable files: https://github.com/ritschmaster/cl-project

+1
source

All Articles