|
6 | 6 | (:local-nicknames (:bt :bordeaux-threads))
|
7 | 7 | (:shadowing-import-from :closer-mop :ensure-finalized)
|
8 | 8 | (:import-from :cffi)
|
9 |
| - (:import-from :kiln/dispatch) |
| 9 | + (:import-from :kiln/dispatch :*entry-point*) |
| 10 | + (:import-from :kiln/flags :dbg :+kiln-target-system+) |
10 | 11 | (:import-from :kiln/script-cache :populate-script-cache)
|
11 | 12 | (:import-from :kiln/script-cache :populate-script-cache)
|
12 | 13 | (:import-from :kiln/utils :setpgrp)
|
13 | 14 | (:export
|
14 |
| - :load-all-script-systems)) |
| 15 | + :load-all-script-systems)) |
15 | 16 | (in-package :kiln/image)
|
16 | 17 |
|
17 | 18 | (let (lib-names)
|
|
33 | 34 | script-systems
|
34 | 35 | :test #'equal)))
|
35 | 36 |
|
| 37 | +(defun mark-all-systems-immutable () |
| 38 | + (map nil 'asdf:register-immutable-system |
| 39 | + (asdf:already-loaded-systems))) |
| 40 | + |
36 | 41 | (defun record-builtins ()
|
37 | 42 | (setf *builtins-by-system*
|
38 | 43 | (list-all-scripts-by-system)
|
|
54 | 59 | (unless (typep cls 'built-in-class)
|
55 | 60 | (ensure-finalized cls)))))
|
56 | 61 |
|
| 62 | +(defparameter *target-system* |
| 63 | + (uiop:getenvp +kiln-target-system+)) |
| 64 | + |
57 | 65 | (defun kiln-before-dump-image ()
|
58 | 66 | (setf uiop/image::*lisp-interaction* nil)
|
59 | 67 | #+sbcl (setf sb-ext:*derive-function-types* t)
|
|
65 | 73 | (record-builtins)
|
66 | 74 | ;; NB Quicklisp doesn't work if it's called inside of the ASDF
|
67 | 75 | ;; build-op. So we run it in a separate thread. (Is this still true?)
|
68 |
| - (let* ((subsystems (list-builtin-script-subsystems))) |
69 |
| - (load-all-script-systems :script-systems subsystems) |
70 |
| - ;; Mark systems immutable twice: first anything loaded by the |
71 |
| - ;; package scripts (so the shebang scripts load faster), then |
72 |
| - ;; again for anything loaded after the shebang scripts. |
73 |
| - (mark-other-systems-immutable :script-systems subsystems) |
74 |
| - (populate-script-cache) |
75 |
| - (mark-other-systems-immutable :script-systems subsystems)) |
| 76 | + (if *target-system* |
| 77 | + (progn |
| 78 | + (load-system *target-system*) |
| 79 | + (mark-all-systems-immutable) |
| 80 | + (setf *entry-point* |
| 81 | + (uiop:ensure-function |
| 82 | + (asdf/system:component-entry-point |
| 83 | + (asdf:find-system *target-system*))))) |
| 84 | + (let* ((subsystems (list-builtin-script-subsystems))) |
| 85 | + (load-all-script-systems :script-systems subsystems) |
| 86 | + ;; Mark systems immutable twice: first anything loaded by the |
| 87 | + ;; package scripts (so the shebang scripts load faster), then |
| 88 | + ;; again for anything loaded after the shebang scripts. |
| 89 | + (mark-other-systems-immutable :script-systems subsystems) |
| 90 | + (populate-script-cache) |
| 91 | + (mark-other-systems-immutable :script-systems subsystems))) |
76 | 92 | (finalize-all-classes)
|
77 | 93 | (asdf:clear-configuration)
|
78 | 94 | (unload-all-foreign-libraries))))
|
|
83 | 99 | #+sbcl
|
84 | 100 | (defvar *sbcl-home* (sb-int:sbcl-homedir-pathname))
|
85 | 101 |
|
86 |
| - |
87 | 102 | (defun kiln-after-restore-image ()
|
88 | 103 | #+sbcl (sb-ext:disable-debugger)
|
89 | 104 | ;; TODO Would it be better to preload them all?
|
90 |
| - #+sbcl (setf sb-sys::*sbcl-homedir-pathname* *sbcl-home*) |
91 |
| - #+sbcl (setf sb-ext:*derive-function-types* nil) |
| 105 | + (unless *target-system* |
| 106 | + #+sbcl (setf sb-sys::*sbcl-homedir-pathname* *sbcl-home*) |
| 107 | + #+sbcl (setf sb-ext:*derive-function-types* nil)) |
92 | 108 | (setf uiop/image::*lisp-interaction* nil)
|
93 | 109 | (setpgrp)
|
94 | 110 | (reload-all-foreign-libraries))
|
|
0 commit comments