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
17 (proclaim '(optimize (compilation-speed 1)
18 (debug #+sb-show 2 #-sb-show 1)
24 ;;;; KLUDGE: Compile and load files which really belong in cold load but are
25 ;;;; here for various unsound reasons. We handle them here, before the package
26 ;;;; hacking below, because they use the SB!FOO cold package name convention
27 ;;;; instead of the SB-FOO final package name convention (since they really
28 ;;;; do belong in cold load and will hopefully make it back there reasonably
29 ;;;; soon). -- WHN 19991207
31 (dolist (stem '(;; FIXME: The assembly files here probably belong in
32 ;; cold load instead of warm load. They ended up here
33 ;; as a quick hack to work around the consequences of
34 ;; my misunderstanding how ASSEMBLE-FILE works when I
35 ;; wrote the cold build code. The cold build code
36 ;; expects only one FASL filename per source file,
37 ;; when it turns out we really need one FASL file for
38 ;; ASSEMBLE-FILE output and another for COMPILE-FILE
39 ;; output. It would probably be good to redo the cold
40 ;; build code so that the COMPILE-FILE stuff generated
41 ;; here can be loaded at the same time as the
42 ;; ASSEMBLE-FILE stuff generated there.
43 "src/assembly/target/assem-rtns"
44 "src/assembly/target/array"
45 "src/assembly/target/arith"
46 "src/assembly/target/alloc"))
47 ;; KLUDGE: Cut-and-paste programming, the sign of a true professional.:-|
48 ;; (Hopefully this will go away as we move the files above into cold load.)
50 (let ((fullname (concatenate 'string stem ".lisp")))
51 ;; (Now that we use byte compiler for interpretation, /SHOW
52 ;; doesn't get compiled properly until the src/assembly files have
53 ;; been loaded, so we use PRINT instead.)
54 #+sb-show (print "/about to compile src/assembly file")
55 #+sb-show (print fullname)
57 (compiled-truename compilation-warnings-p compilation-failure-p)
58 (compile-file fullname)
59 (declare (ignore compilation-warnings-p))
60 #+sb-show (print "/done compiling src/assembly file")
61 (if compilation-failure-p
62 (error "COMPILE-FILE of ~S failed." fullname)
63 (unless (load compiled-truename)
64 (error "LOAD of ~S failed." compiled-truename))))))
68 ;;; Our cross-compilation host is out of the picture now, so we no
69 ;;; longer need to worry about collisions between our package names
70 ;;; and cross-compilation host package names, so now is a good time to
71 ;;; rename any package with a bootstrap-only name SB!FOO to its
72 ;;; permanent name SB-FOO.
74 ;;; (In principle it might be tidier to do this when dumping the cold
75 ;;; image in genesis, but in practice the logic might be a little
76 ;;; messier because genesis dumps both symbols and packages, and we'd
77 ;;; need to make sure that dumped symbols were renamed in the same way
78 ;;; as dumped packages. Or we could do it in cold init, but it's
79 ;;; easier to experiment with and debug things here in warm init than
80 ;;; in cold init, so we do it here instead.)
81 (let ((boot-prefix "SB!")
83 (dolist (package (list-all-packages))
84 (let ((old-package-name (package-name package)))
85 (when (and (>= (length old-package-name) (length boot-prefix))
86 (string= boot-prefix old-package-name
87 :end2 (length boot-prefix)))
88 (let ((new-package-name (concatenate 'string
90 (subseq old-package-name
91 (length boot-prefix)))))
92 (rename-package package
94 (package-nicknames package)))))))
96 ;;; FIXME: This nickname is a deprecated hack for backwards
97 ;;; compatibility with code which assumed the CMU-CL-style
98 ;;; SB-ALIEN/SB-C-CALL split. That split went away and was deprecated
99 ;;; in 0.7.0, so we should get rid of this nickname after a while.
100 (let ((package (find-package "SB-ALIEN")))
101 (rename-package package
102 (package-name package)
103 (cons "SB-C-CALL" (package-nicknames package))))
105 ;;; KLUDGE: This is created here (instead of in package-data-list.lisp-expr)
106 ;;; because it doesn't have any symbols in it, so even if it's
107 ;;; present at cold load time, genesis thinks it's unimportant
108 ;;; and doesn't dump it. There's gotta be a better way, but for now
109 ;;; I'll just do it here. (As noted below, I'd just as soon have this
110 ;;; go away entirely, so I'm disinclined to fiddle with it too much.)
113 ;;; FIXME: Why do slot accessor names need to be interned anywhere? For
114 ;;; low-level debugging? Perhaps this should go away, or at least
115 ;;; be optional, controlled by SB-SHOW or something.
116 (defpackage "SB-SLOT-ACCESSOR-NAME"
119 ;;;; compiling and loading more of the system
121 ;;; KLUDGE: In SBCL, almost all in-the-flow-of-control package hacking has
122 ;;; gone away in favor of package setup controlled by tables. However, that
123 ;;; mechanism isn't smart enough to handle shadowing, and since this shadowing
124 ;;; is inherently a non-ANSI KLUDGE anyway (i.e. there ought to be no
125 ;;; difference between e.g. CL:CLASS and SB-PCL:CLASS) there's not much
126 ;;; point in trying to polish it by implementing a non-KLUDGEy way of
127 ;;; setting it up. -- WHN 19991203
128 (let ((*package* (the package (find-package "SB-PCL"))))
129 (shadow '(;; CLASS itself and operations thereon
130 "CLASS" "CLASS-NAME" "CLASS-OF" "FIND-CLASS"
131 ;; some system classes
132 "BUILT-IN-CLASS" "STANDARD-CLASS" "STRUCTURE-CLASS"))
133 ;; Of the shadowing symbols above, these are external symbols in CMU CL ca.
134 ;; 19991203. I'm not sure what's the basis of the decision to export some and
135 ;; not others; we'll just follow along..
136 (export (mapcar #'intern '("CLASS-NAME" "CLASS-OF" "FIND-CLASS"))))
138 ;;; FIXME: CMU CL's pclcom.lisp had extra optional stuff wrapped around
139 ;;; COMPILE-PCL, at least some of which we should probably have too:
141 ;;; (with-compilation-unit
142 ;;; (:optimize '(optimize (debug #+(and (not high-security) small) .5
143 ;;; #-(or high-security small) 2
144 ;;; #+high-security 3)
145 ;;; (speed 2) (safety #+(and (not high-security) small) 0
146 ;;; #-(or high-security small) 2
147 ;;; #+high-security 3)
148 ;;; (inhibit-warnings 2))
149 ;;; :optimize-interface '(optimize-interface #+(and (not high-security) small)
151 ;;; #+high-security (safety 3))
152 ;;; :context-declarations
153 ;;; '((:external (declare (optimize-interface (safety #-high-security 2 #+high-
155 ;;; (debug #-high-security 1 #+high-s
157 ;;; ((:or :macro (:match "$EARLY-") (:match "$BOOT-"))
158 ;;; (declare (optimize (speed 0))))))
160 ;;; FIXME: This has mutated into a hack which crudely duplicates
161 ;;; functionality from the existing mechanism to load files from
162 ;;; build-order.lisp-expr, without being quite parallel. (E.g. object
163 ;;; files end up alongside the source files instead of ending up in
164 ;;; parallel directory trees.) Maybe we could merge the filenames here
165 ;;; into build-order.lisp-expr with some new flag (perhaps :WARM) to
166 ;;; indicate that the files should be handled not in cold load but
168 (dolist (stem '(;; CLOS, derived from the PCL reference implementation
170 ;; This PCL build order is based on a particular
171 ;; (arbitrary) linearization of the declared build
172 ;; order dependencies from the old PCL defsys.lisp
173 ;; dependency database.
177 "src/pcl/compiler-support"
194 "src/pcl/generic-functions"
205 "src/pcl/documentation"
206 "src/pcl/print-object"
210 ;; miscellaneous functionality which depends on CLOS
211 "src/code/force-delayed-defbangmethods"
213 ;; CLOS-level support for the Gray OO streams
214 ;; extension (which is also supported by various
215 ;; lower-level hooks elsewhere in the code)
216 "src/pcl/gray-streams-class"
217 "src/pcl/gray-streams"
219 ;; other functionality not needed for cold init, moved
220 ;; to warm init to reduce peak memory requirement in
227 "src/code/run-program"
229 ;; Code derived from PCL's pre-ANSI DESCRIBE-OBJECT
230 ;; facility is still used in our ANSI DESCRIBE
231 ;; facility, and should be compiled and loaded after
232 ;; our DESCRIBE facility is compiled and loaded.
235 (let ((fullname (concatenate 'string stem ".lisp")))
236 (sb-int:/show "about to compile" fullname)
238 (compiled-truename compilation-warnings-p compilation-failure-p)
239 (compile-file fullname)
240 (declare (ignore compilation-warnings-p))
241 (sb-int:/show "done compiling" fullname)
242 (cond (compilation-failure-p
243 (error "COMPILE-FILE of ~S failed." fullname))
245 (unless (load compiled-truename)
246 (error "LOAD of ~S failed." compiled-truename))
247 (sb-int:/show "done loading" compiled-truename))))))
249 ;;;; setting package documentation
251 ;;; While we were running on the cross-compilation host, we tried to
252 ;;; be portable and not overwrite the doc strings for the standard
253 ;;; packages. But now the cross-compilation host is only a receding
254 ;;; memory, and we can have our way with the doc strings.
255 (sb-int:/show "setting package documentation")
256 #+sb-doc (setf (documentation (find-package "COMMON-LISP") t)
257 "public: home of symbols defined by the ANSI language specification")
258 #+sb-doc (setf (documentation (find-package "COMMON-LISP-USER") t)
259 "public: the default package for user code and data")
260 #+sb-doc (setf (documentation (find-package "KEYWORD") t)
261 "public: home of keywords")
263 ;;; KLUDGE: It'd be nicer to do this in the table with the other
264 ;;; non-standard packages. -- WHN 19991206
265 #+sb-doc (setf (documentation (find-package "SB-SLOT-ACCESSOR-NAME") t)
266 "private: home of CLOS slot accessor internal names")
268 ;;; FIXME: There doesn't seem to be any easy way to get package doc strings
269 ;;; through the cold boot process. They need to be set somewhere. Maybe the
270 ;;; easiest thing to do is to read them out of package-data-list.lisp-expr
273 ;;;; resetting compilation policy to neutral values in preparation for
274 ;;;; SAVE-LISP-AND-DIE as final SBCL core
276 (sb-int:/show "setting compilation policy to neutral values")
277 (proclaim '(optimize (compilation-speed 1)