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 ;; (Now that we use byte compiler for interpretation, /SHOW
50 ;; doesn't get compiled properly until the src/assembly files have
51 ;; been loaded, so we use PRINT instead.)
52 #+sb-show (print "/about to compile src/assembly file")
53 #+sb-show (print fullname)
55 (compiled-truename compilation-warnings-p compilation-failure-p)
56 (compile-file fullname)
57 (declare (ignore compilation-warnings-p))
58 #+sb-show (print "/done compiling src/assembly file")
59 (if compilation-failure-p
60 (error "COMPILE-FILE of ~S failed." fullname)
61 (unless (load compiled-truename)
62 (error "LOAD of ~S failed." compiled-truename))))))
66 ;;; Our cross-compilation host is out of the picture now, so we no longer need
67 ;;; to worry about collisions between our package names and cross-compilation
68 ;;; host package names, so now is a good time to rename any package with a
69 ;;; bootstrap-only name SB!FOO to its permanent name SB-FOO.
71 ;;; (In principle it might be tidier to do this when dumping the cold image in
72 ;;; genesis, but in practice the logic might be a little messier because
73 ;;; genesis dumps both symbols and packages, and we'd need to make that dumped
74 ;;; symbols were renamed in the same way as dumped packages. Or we could do it
75 ;;; in cold init, but it's easier to experiment with and debug things here in
76 ;;; warm init than in cold init, so we do it here instead.)
77 (let ((boot-prefix "SB!")
79 (dolist (package (list-all-packages))
80 (let ((old-package-name (package-name package)))
81 (when (and (>= (length old-package-name) (length boot-prefix))
82 (string= boot-prefix old-package-name
83 :end2 (length boot-prefix)))
84 (let ((new-package-name (concatenate 'string
86 (subseq old-package-name
87 (length boot-prefix)))))
88 (rename-package package
90 (package-nicknames package)))))))
92 ;;; KLUDGE: This is created here (instead of in package-data-list.lisp-expr)
93 ;;; because it doesn't have any symbols in it, so even if it's
94 ;;; present at cold load time, genesis thinks it's unimportant
95 ;;; and doesn't dump it. There's gotta be a better way, but for now
96 ;;; I'll just do it here. (As noted below, I'd just as soon have this
97 ;;; go away entirely, so I'm disinclined to fiddle with it too much.)
100 ;;; FIXME: Why do slot accessor names need to be interned anywhere? For
101 ;;; low-level debugging? Perhaps this should go away, or at least
102 ;;; be optional, controlled by SB-SHOW or something.
103 (defpackage "SB-SLOT-ACCESSOR-NAME"
106 ;;;; compiling and loading more of the system
108 ;;; KLUDGE: In SBCL, almost all in-the-flow-of-control package hacking has
109 ;;; gone away in favor of package setup controlled by tables. However, that
110 ;;; mechanism isn't smart enough to handle shadowing, and since this shadowing
111 ;;; is inherently a non-ANSI KLUDGE anyway (i.e. there ought to be no
112 ;;; difference between e.g. CL:CLASS and SB-PCL:CLASS) there's not much
113 ;;; point in trying to polish it by implementing a non-KLUDGEy way of
114 ;;; setting it up. -- WHN 19991203
115 (let ((*package* (the package (find-package "SB-PCL"))))
116 (shadow '(;; CLASS itself and operations thereon
117 "CLASS" "CLASS-NAME" "CLASS-OF" "FIND-CLASS"
118 ;; some system classes
119 "BUILT-IN-CLASS" "STANDARD-CLASS" "STRUCTURE-CLASS"))
120 ;; Of the shadowing symbols above, these are external symbols in CMU CL ca.
121 ;; 19991203. I'm not sure what's the basis of the decision to export some and
122 ;; not others; we'll just follow along..
123 (export (mapcar #'intern '("CLASS-NAME" "CLASS-OF" "FIND-CLASS"))))
125 ;;; FIXME: CMU CL's pclcom.lisp had extra optional stuff wrapped around
126 ;;; COMPILE-PCL, at least some of which we should probably have too:
128 ;;; (with-compilation-unit
129 ;;; (:optimize '(optimize (debug #+(and (not high-security) small) .5
130 ;;; #-(or high-security small) 2
131 ;;; #+high-security 3)
132 ;;; (speed 2) (safety #+(and (not high-security) small) 0
133 ;;; #-(or high-security small) 2
134 ;;; #+high-security 3)
135 ;;; (inhibit-warnings 2))
136 ;;; :optimize-interface '(optimize-interface #+(and (not high-security) small)
138 ;;; #+high-security (safety 3))
139 ;;; :context-declarations
140 ;;; '((:external (declare (optimize-interface (safety #-high-security 2 #+high-
142 ;;; (debug #-high-security 1 #+high-s
144 ;;; ((:or :macro (:match "$EARLY-") (:match "$BOOT-"))
145 ;;; (declare (optimize (speed 0))))))
147 ;;; FIXME: This has mutated into a hack which crudely duplicates
148 ;;; functionality from the existing mechanism to load files from
149 ;;; build-order.lisp-expr, without being quite parallel. (E.g. object
150 ;;; files end up alongside the source files instead of ending up in
151 ;;; parallel directory trees.) Maybe we could merge the filenames here
152 ;;; into build-order.lisp-expr with some new flag (perhaps :WARM) to
153 ;;; indicate that the files should be handled not in cold load but
155 (dolist (stem '(;; CLOS, derived from the PCL reference implementation
157 ;; This PCL build order is based on a particular
158 ;; linearization of the declared build order
159 ;; dependencies from the old PCL defsys.lisp
160 ;; dependency database.
165 "src/pcl/compiler-support"
167 ;; "src/pcl/fin" merged into "src/pcl/low" in 0.6.11.43
182 "src/pcl/generic-functions"
194 "src/pcl/documentation"
195 "src/pcl/print-object"
199 ;; miscellaneous functionality which depends on CLOS
200 "src/code/force-delayed-defbangmethods"
202 ;; CLOS-level support for the Gray OO streams
203 ;; extension (which is also supported by various
204 ;; lower-level hooks elsewhere in the code)
205 "src/pcl/gray-streams-class"
206 "src/pcl/gray-streams"
208 ;; other functionality not needed for cold init, moved
209 ;; to warm init to reduce peak memory requirement in
216 "src/code/run-program"
218 ;; Code derived from PCL's pre-ANSI DESCRIBE-OBJECT
219 ;; facility is still used in our ANSI DESCRIBE
220 ;; facility, and should be compiled and loaded after
221 ;; our DESCRIBE facility is compiled and loaded.
224 (let ((fullname (concatenate 'string stem ".lisp")))
225 (sb-int:/show "about to compile" fullname)
227 (compiled-truename compilation-warnings-p compilation-failure-p)
228 (compile-file fullname)
229 (declare (ignore compilation-warnings-p))
230 (sb-int:/show "done compiling" fullname)
231 (cond (compilation-failure-p
232 (error "COMPILE-FILE of ~S failed." fullname))
234 (unless (load compiled-truename)
235 (error "LOAD of ~S failed." compiled-truename))
236 (sb-int:/show "done loading" compiled-truename))))))
238 ;;;; setting package documentation
240 ;;; While we were running on the cross-compilation host, we tried to
241 ;;; be portable and not overwrite the doc strings for the standard
242 ;;; packages. But now the cross-compilation host is only a receding
243 ;;; memory, and we can have our way with the doc strings.
244 (sb-int:/show "setting package documentation")
245 #+sb-doc (setf (documentation (find-package "COMMON-LISP") t)
246 "public: home of symbols defined by the ANSI language specification")
247 #+sb-doc (setf (documentation (find-package "COMMON-LISP-USER") t)
248 "public: the default package for user code and data")
249 #+sb-doc (setf (documentation (find-package "KEYWORD") t)
250 "public: home of keywords")
252 ;;; KLUDGE: It'd be nicer to do this in the table with the other
253 ;;; non-standard packages. -- WHN 19991206
254 #+sb-doc (setf (documentation (find-package "SB-SLOT-ACCESSOR-NAME") t)
255 "private: home of CLOS slot accessor internal names")
257 ;;; FIXME: There doesn't seem to be any easy way to get package doc strings
258 ;;; through the cold boot process. They need to be set somewhere. Maybe the
259 ;;; easiest thing to do is to read them out of package-data-list.lisp-expr
262 ;;;; restoring compilation policy to neutral values in preparation for
263 ;;;; SAVE-LISP-AND-DIE as final SBCL core
265 (sb-int:/show "setting compilation policy to neutral values")
266 (proclaim '(optimize (compilation-speed 1)