1 ;;;; "warm initialization": initialization which comes after cold init
3 ;;;; This software is part of the SBCL system. See the README file for
6 ;;;; This software is derived from the CMU CL system, which was
7 ;;;; written at Carnegie Mellon University and released into the
8 ;;;; public domain. The software is in the public domain and is
9 ;;;; provided with absolutely no warranty. See the COPYING and CREDITS
10 ;;;; files for more information.
12 (in-package "COMMON-LISP-USER")
14 ;;;; general warm init compilation policy
16 (proclaim '(optimize (compilation-speed 1)
17 (debug #+sb-show 2 #-sb-show 1)
23 ;;;; KLUDGE: Compile and load files which really belong in cold load but are
24 ;;;; here for various unsound reasons. We handle them here, before the package
25 ;;;; hacking below, because they use the SB!FOO cold package name convention
26 ;;;; instead of the SB-FOO final package name convention (since they really
27 ;;;; do belong in cold load and will hopefully make it back there reasonably
28 ;;;; soon). -- WHN 19991207
30 (dolist (stem '(;; FIXME: The files here from outside the src/pcl directory
31 ;; probably belong in cold load instead of warm load. They
32 ;; ended up here as a quick hack to work around the
33 ;; consequences of my misunderstanding how ASSEMBLE-FILE works
34 ;; when I wrote the cold build code. The cold build code
35 ;; expects only one FASL filename per source file, when it
36 ;; turns out we really need one FASL file for ASSEMBLE-FILE
37 ;; output and another for COMPILE-FILE output. It would
38 ;; probably be good to redo the cold build code so that the
39 ;; COMPILE-FILE stuff generated here can be loaded at the same
40 ;; time as the ASSEMBLE-FILE stuff generated there.
41 "src/assembly/target/assem-rtns"
42 "src/assembly/target/array"
43 "src/assembly/target/arith"
44 "src/assembly/target/alloc"))
45 ;; KLUDGE: Cut-and-paste programming, the sign of a true professional.:-|
46 ;; (Hopefully this will go away as we move the files above into cold load.)
48 (let ((fullname (concatenate 'string stem ".lisp")))
49 (sb!int:/show "about to compile" fullname)
51 (compiled-truename compilation-warnings-p compilation-failure-p)
52 (compile-file fullname)
53 (declare (ignore compilation-warnings-p))
54 (sb!int:/show "done compiling" fullname)
55 (if compilation-failure-p
56 (error "COMPILE-FILE of ~S failed." fullname)
57 (unless (load compiled-truename)
58 (error "LOAD of ~S failed." compiled-truename))))))
62 ;;; Our cross-compilation host is out of the picture now, so we no longer need
63 ;;; to worry about collisions between our package names and cross-compilation
64 ;;; host package names, so now is a good time to rename any package with a
65 ;;; bootstrap-only name SB!FOO to its permanent name SB-FOO.
67 ;;; (In principle it might be tidier to do this when dumping the cold image in
68 ;;; genesis, but in practice the logic might be a little messier because
69 ;;; genesis dumps both symbols and packages, and we'd need to make that dumped
70 ;;; symbols were renamed in the same way as dumped packages. Or we could do it
71 ;;; in cold init, but it's easier to experiment with and debug things here in
72 ;;; warm init than in cold init, so we do it here instead.)
73 (let ((boot-prefix "SB!")
75 (dolist (package (list-all-packages))
76 (let ((old-package-name (package-name package)))
77 (when (and (>= (length old-package-name) (length boot-prefix))
78 (string= boot-prefix old-package-name
79 :end2 (length boot-prefix)))
80 (let ((new-package-name (concatenate 'string
82 (subseq old-package-name
83 (length boot-prefix)))))
84 (rename-package package
86 (package-nicknames package)))))))
88 ;;; KLUDGE: This is created here (instead of in package-data-list.lisp-expr)
89 ;;; because it doesn't have any symbols in it, so even if it's
90 ;;; present at cold load time, genesis thinks it's unimportant
91 ;;; and doesn't dump it. There's gotta be a better way, but for now
92 ;;; I'll just do it here. (As noted below, I'd just as soon have this
93 ;;; go away entirely, so I'm disinclined to fiddle with it too much.)
96 ;;; FIXME: Why do slot accessor names need to be interned anywhere? For
97 ;;; low-level debugging? Perhaps this should go away, or at least
98 ;;; be optional, controlled by SB-SHOW or something.
99 (defpackage "SB-SLOT-ACCESSOR-NAME"
102 ;;;; compiling and loading more of the system
104 ;;; KLUDGE: In SBCL, almost all in-the-flow-of-control package hacking has
105 ;;; gone away in favor of package setup controlled by tables. However, that
106 ;;; mechanism isn't smart enough to handle shadowing, and since this shadowing
107 ;;; is inherently a non-ANSI KLUDGE anyway (i.e. there ought to be no
108 ;;; difference between e.g. CL:CLASS and SB-PCL:CLASS) there's not much
109 ;;; point in trying to polish it by implementing a non-KLUDGEy way of
110 ;;; setting it up. -- WHN 19991203
111 (let ((*package* (the package (find-package "SB-PCL"))))
112 (shadow '(;; CLASS itself and operations thereon
113 "CLASS" "CLASS-NAME" "CLASS-OF" "FIND-CLASS"
114 ;; some system classes
115 "BUILT-IN-CLASS" "STANDARD-CLASS" "STRUCTURE-CLASS"))
116 ;; Of the shadowing symbols above, these are external symbols in CMU CL ca.
117 ;; 19991203. I'm not sure what's the basis of the decision to export some and
118 ;; not others; we'll just follow along..
119 (export (mapcar #'intern '("CLASS-NAME" "CLASS-OF" "FIND-CLASS"))))
121 ;;; FIXME: CMU CL's pclcom.lisp had extra optional stuff wrapped around
122 ;;; COMPILE-PCL, at least some of which we should probably have too:
124 ;;; (with-compilation-unit
125 ;;; (:optimize '(optimize (debug #+(and (not high-security) small) .5
126 ;;; #-(or high-security small) 2
127 ;;; #+high-security 3)
128 ;;; (speed 2) (safety #+(and (not high-security) small) 0
129 ;;; #-(or high-security small) 2
130 ;;; #+high-security 3)
131 ;;; (inhibit-warnings 2))
132 ;;; :optimize-interface '(optimize-interface #+(and (not high-security) small)
134 ;;; #+high-security (safety 3))
135 ;;; :context-declarations
136 ;;; '((:external (declare (optimize-interface (safety #-high-security 2 #+high-
138 ;;; (debug #-high-security 1 #+high-s
140 ;;; ((:or :macro (:match "$EARLY-") (:match "$BOOT-"))
141 ;;; (declare (optimize (speed 0))))))
143 ;;; FIXME: This has mutated into a hack which crudely duplicates
144 ;;; functionality from the existing mechanism to load files from
145 ;;; stems-and-flags.lisp-expr, without being quite parallel. (E.g.
146 ;;; object files end up alongside the source files instead of ending
147 ;;; up in parallel directory trees.) Maybe we could merge the
148 ;;; filenames here into stems-and-flags.lisp-expr with some new flag
149 ;;; (perhaps :WARM) to indicate that the files should be handled not
150 ;;; in cold load but afterwards. Alternatively, we could call
152 ;; CLOS, derived from the PCL reference implementation
154 ;; This PCL build order is based on a particular
155 ;; linearization of the declared build order
156 ;; dependencies from the old PCL defsys.lisp
157 ;; dependency database.
162 "src/pcl/compiler-support"
164 ;; "src/pcl/fin" merged into "src/pcl/low" in 0.6.11.43
179 "src/pcl/generic-functions"
191 "src/pcl/documentation"
192 "src/pcl/print-object"
196 ;; miscellaneous functionality which depends on CLOS
197 "src/code/force-delayed-defbangmethods"
199 ;; CLOS-level support for the Gray OO streams
200 ;; extension (which is also supported by various
201 ;; lower-level hooks elsewhere in the code)
202 "src/pcl/gray-streams-class"
203 "src/pcl/gray-streams"
205 ;; other functionality not needed for cold init, moved
206 ;; to warm init to reduce peak memory requirement in
213 "src/code/run-program"
215 ;; Code derived from PCL's pre-ANSI DESCRIBE-OBJECT
216 ;; facility is still used in our ANSI DESCRIBE
217 ;; facility, and should be compiled and loaded after
218 ;; our DESCRIBE facility is compiled and loaded.
221 (let ((fullname (concatenate 'string stem ".lisp")))
222 (sb-int:/show "about to compile" fullname)
224 (compiled-truename compilation-warnings-p compilation-failure-p)
225 (compile-file fullname)
226 (declare (ignore compilation-warnings-p))
227 (sb-int:/show "done compiling" fullname)
228 (cond (compilation-failure-p
229 (error "COMPILE-FILE of ~S failed." fullname))
231 (unless (load compiled-truename)
232 (error "LOAD of ~S failed." compiled-truename))
233 (sb-int:/show "done loading" compiled-truename))))))
235 ;;;; setting package documentation
237 ;;; While we were running on the cross-compilation host, we tried to
238 ;;; be portable and not overwrite the doc strings for the standard
239 ;;; packages. But now the cross-compilation host is only a receding
240 ;;; memory, and we can have our way with the doc strings.
241 (sb-int:/show "setting package documentation")
242 #+sb-doc (setf (documentation (find-package "COMMON-LISP") t)
243 "public: home of symbols defined by the ANSI language specification")
244 #+sb-doc (setf (documentation (find-package "COMMON-LISP-USER") t)
245 "public: the default package for user code and data")
246 #+sb-doc (setf (documentation (find-package "KEYWORD") t)
247 "public: home of keywords")
249 ;;; KLUDGE: It'd be nicer to do this in the table with the other
250 ;;; non-standard packages. -- WHN 19991206
251 #+sb-doc (setf (documentation (find-package "SB-SLOT-ACCESSOR-NAME") t)
252 "private: home of CLOS slot accessor internal names")
254 ;;; FIXME: There doesn't seem to be any easy way to get package doc strings
255 ;;; through the cold boot process. They need to be set somewhere. Maybe the
256 ;;; easiest thing to do is to read them out of package-data-list.lisp-expr
259 ;;;; restoring compilation policy to neutral values in preparation for
260 ;;;; SAVE-LISP-AND-DIE as final SBCL core
262 (sb-int:/show "setting compilation policy to neutral values")
263 (proclaim '(optimize (compilation-speed 1)
270 ;;; FIXME: It would be good to unintern stuff we will no longer need
271 ;;; before we go on to PURIFY. E.g.
272 ;;; * various PCL stuff like INITIAL-CLASSES-AND-WRAPPERS; and
273 ;;; * *BUILT-IN-CLASSES* (which can't actually be freed by UNINTERN at
274 ;;; this point, since it passed through another PURIFY earlier
275 ;;; at cold init time).