Skip to content

How to save lisp and die from Slime or Sly #38

Description

@vindarel

Usually, to save a lisp image, we must call SBCL from the terminal and call save-lisp-and-die from there. If we attempt to do it from the Slime REPL, we get an error related to too many threads: we can't do it while the REPL thread is running.

Here is a snippet given by Akasha on Discord for Sly.

(defun sbcl-save-sly-and-die ()
  "Save a sbcl image, even when running from inside Sly.
This function should only be used in the *inferior-buffer* buffer,
inside emacs."
  (mapcar #'(lambda (x)
              (slynk::close-connection 
               x nil nil))
          slynk::*connections*)
  (dolist (thread (remove
                   (slynk-backend::current-thread)
                   (slynk-backend::all-threads)))
    (slynk-backend::kill-thread thread))
  (sleep 1)
  (sb-ext:save-lisp-and-die #P"~/your-main-program.exe"
                            :toplevel #'your-main-function-here
                            :executable t
                            :compression t))

;; in *sly-inferior-lisp* buffer
(sbcl-save-sly-and-die)

(untested by me)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    executablesreplslimeslySpecific to SLY. Feature not available on SLIME.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions