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 ;;; FIXME: This nickname is a deprecated hack for backwards
93 ;;; compatibility with code which assumed the CMU-CL-style
94 ;;; SB-ALIEN/SB-C-CALL split. That split went away and was deprecated
95 ;;; in 0.7.0, so we should get rid of this nickname after a while.
96 (let ((package (find-package "SB-ALIEN")))
97 (rename-package package
98 (package-name package)
99 (cons "SB-C-CALL" (package-nicknames package))))
101 ;;; KLUDGE: This is created here (instead of in package-data-list.lisp-expr)
102 ;;; because it doesn't have any symbols in it, so even if it's
103 ;;; present at cold load time, genesis thinks it's unimportant
104 ;;; and doesn't dump it. There's gotta be a better way, but for now
105 ;;; I'll just do it here. (As noted below, I'd just as soon have this
106 ;;; go away entirely, so I'm disinclined to fiddle with it too much.)
109 ;;; FIXME: Why do slot accessor names need to be interned anywhere? For
110 ;;; low-level debugging? Perhaps this should go away, or at least
111 ;;; be optional, controlled by SB-SHOW or something.
112 (defpackage "SB-SLOT-ACCESSOR-NAME"
115 ;;;; compiling and loading more of the system
117 ;;; KLUDGE: In SBCL, almost all in-the-flow-of-control package hacking has
118 ;;; gone away in favor of package setup controlled by tables. However, that
119 ;;; mechanism isn't smart enough to handle shadowing, and since this shadowing
120 ;;; is inherently a non-ANSI KLUDGE anyway (i.e. there ought to be no
121 ;;; difference between e.g. CL:CLASS and SB-PCL:CLASS) there's not much
122 ;;; point in trying to polish it by implementing a non-KLUDGEy way of
123 ;;; setting it up. -- WHN 19991203
124 (let ((*package* (the package (find-package "SB-PCL"))))
125 (shadow '(;; CLASS itself and operations thereon
126 "CLASS" "CLASS-NAME" "CLASS-OF" "FIND-CLASS"
127 ;; some system classes
128 "BUILT-IN-CLASS" "STANDARD-CLASS" "STRUCTURE-CLASS"))
129 ;; Of the shadowing symbols above, these are external symbols in CMU CL ca.
130 ;; 19991203. I'm not sure what's the basis of the decision to export some and
131 ;; not others; we'll just follow along..
132 (export (mapcar #'intern '("CLASS-NAME" "CLASS-OF" "FIND-CLASS"))))
134 ;;; FIXME: CMU CL's pclcom.lisp had extra optional stuff wrapped around
135 ;;; COMPILE-PCL, at least some of which we should probably have too:
137 ;;; (with-compilation-unit
138 ;;; (:optimize '(optimize (debug #+(and (not high-security) small) .5
139 ;;; #-(or high-security small) 2
140 ;;; #+high-security 3)
141 ;;; (speed 2) (safety #+(and (not high-security) small) 0
142 ;;; #-(or high-security small) 2
143 ;;; #+high-security 3)
144 ;;; (inhibit-warnings 2))
145 ;;; :optimize-interface '(optimize-interface #+(and (not high-security) small)
147 ;;; #+high-security (safety 3))
148 ;;; :context-declarations
149 ;;; '((:external (declare (optimize-interface (safety #-high-security 2 #+high-
151 ;;; (debug #-high-security 1 #+high-s
153 ;;; ((:or :macro (:match "$EARLY-") (:match "$BOOT-"))
154 ;;; (declare (optimize (speed 0))))))
156 ;;; FIXME: This has mutated into a hack which crudely duplicates
157 ;;; functionality from the existing mechanism to load files from
158 ;;; build-order.lisp-expr, without being quite parallel. (E.g. object
159 ;;; files end up alongside the source files instead of ending up in
160 ;;; parallel directory trees.) Maybe we could merge the filenames here
161 ;;; into build-order.lisp-expr with some new flag (perhaps :WARM) to
162 ;;; indicate that the files should be handled not in cold load but
164 (dolist (stem '(;; CLOS, derived from the PCL reference implementation
166 ;; This PCL build order is based on a particular
167 ;; linearization of the declared build order
168 ;; dependencies from the old PCL defsys.lisp
169 ;; dependency database.
171 ;; "src/pcl/iterate" removed 2001-12-20 njf
174 "src/pcl/compiler-support"
176 ;; "src/pcl/fin" merged into "src/pcl/low" in 0.6.11.43
191 "src/pcl/generic-functions"
202 "src/pcl/documentation"
203 "src/pcl/print-object"
207 ;; miscellaneous functionality which depends on CLOS
208 "src/code/force-delayed-defbangmethods"
210 ;; CLOS-level support for the Gray OO streams
211 ;; extension (which is also supported by various
212 ;; lower-level hooks elsewhere in the code)
213 "src/pcl/gray-streams-class"
214 "src/pcl/gray-streams"
216 ;; other functionality not needed for cold init, moved
217 ;; to warm init to reduce peak memory requirement in
224 "src/code/run-program"
226 ;; Code derived from PCL's pre-ANSI DESCRIBE-OBJECT
227 ;; facility is still used in our ANSI DESCRIBE
228 ;; facility, and should be compiled and loaded after
229 ;; our DESCRIBE facility is compiled and loaded.
232 (let ((fullname (concatenate 'string stem ".lisp")))
233 (sb-int:/show "about to compile" fullname)
235 (compiled-truename compilation-warnings-p compilation-failure-p)
236 (compile-file fullname)
237 (declare (ignore compilation-warnings-p))
238 (sb-int:/show "done compiling" fullname)
239 (cond (compilation-failure-p
240 (error "COMPILE-FILE of ~S failed." fullname))
242 (unless (load compiled-truename)
243 (error "LOAD of ~S failed." compiled-truename))
244 (sb-int:/show "done loading" compiled-truename))))))
246 ;;;; setting package documentation
248 ;;; While we were running on the cross-compilation host, we tried to
249 ;;; be portable and not overwrite the doc strings for the standard
250 ;;; packages. But now the cross-compilation host is only a receding
251 ;;; memory, and we can have our way with the doc strings.
252 (sb-int:/show "setting package documentation")
253 #+sb-doc (setf (documentation (find-package "COMMON-LISP") t)
254 "public: home of symbols defined by the ANSI language specification")
255 #+sb-doc (setf (documentation (find-package "COMMON-LISP-USER") t)
256 "public: the default package for user code and data")
257 #+sb-doc (setf (documentation (find-package "KEYWORD") t)
258 "public: home of keywords")
260 ;;; KLUDGE: It'd be nicer to do this in the table with the other
261 ;;; non-standard packages. -- WHN 19991206
262 #+sb-doc (setf (documentation (find-package "SB-SLOT-ACCESSOR-NAME") t)
263 "private: home of CLOS slot accessor internal names")
265 ;;; FIXME: There doesn't seem to be any easy way to get package doc strings
266 ;;; through the cold boot process. They need to be set somewhere. Maybe the
267 ;;; easiest thing to do is to read them out of package-data-list.lisp-expr
270 ;;;; restoring compilation policy to neutral values in preparation for
271 ;;;; SAVE-LISP-AND-DIE as final SBCL core
273 (sb-int:/show "setting compilation policy to neutral values")
274 (proclaim '(optimize (compilation-speed 1)