Lisp: Auto-generate SBCL core to speed up SLY startup.

master
Pierre Neidhardt 2020-11-06 20:13:25 +01:00
parent 34214f9c5d
commit 0eede6b0a5
1 changed files with 37 additions and 4 deletions

View File

@ -46,11 +46,44 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Sly
(defun dump-sbcl-core-for-sly () ; REVIEW: This probably works for SLIME too.
(cl-flet ((read-bytes (path)
(with-temp-buffer
;; (set-buffer-multibyte nil)
;; (setq buffer-file-coding-system 'binary)
(insert-file-contents-literally path)
(buffer-substring-no-properties (point-min) (point-max)))))
(let* ((sbcl-core-dir (expand-file-name "sly/" user-emacs-directory))
(sbcl-core (expand-file-name "sbcl.core-for-sly" sbcl-core-dir))
(sbcl-core-version (expand-file-name "sbcl.version" sbcl-core-dir))
(current-sbcl-version (cadr (split-string
(with-temp-buffer
(call-process "sbcl" nil t nil "--version")
(buffer-string))))))
(when (or (not (file-exists-p sbcl-core-version))
(version< (car (split-string (read-bytes sbcl-core-version)))
current-sbcl-version))
(make-directory sbcl-core-dir :parents)
(call-process
"sbcl" nil nil nil
"--eval" "(mapc 'require '(sb-bsd-sockets sb-posix sb-introspect sb-cltl2 asdf))"
"--eval" (format "(save-lisp-and-die %S)" sbcl-core))
(with-temp-file sbcl-core-version
(insert current-sbcl-version)))
(when (file-exists-p sbcl-core)
sbcl-core))))
(with-eval-after-load 'sly
(setq sly-lisp-implementations
'((sbcl ("sbcl" "--noinform"))
(ccl ("ccl"))
(ecl ("ecl"))))
(let ((core (dump-sbcl-core-for-sly)))
(setq sly-lisp-implementations
`((sbcl ("sbcl"
,@(if core
`("--core" ,core)
'())))
;; (sbcl ("sbcl" "--noinform"))
(ccl ("ccl"))
(ecl ("ecl")))))
(with-eval-after-load 'sly-mrepl
(setq sly-mrepl-history-file-name (expand-file-name "sly-mrepl-history" user-emacs-directory))
(define-key sly-mrepl-mode-map (kbd "C-c M-o") 'sly-mrepl-clear-repl))