Delete a ton of cruft from the globaldb initialization logic.
[sbcl.git] / src / cold / warm.lisp
blob363a70a48d8ab3bc785f761b4c9634d800943358
1 ;;;; "warm initialization": initialization which comes after cold init
3 ;;;; This software is part of the SBCL system. See the README file for
4 ;;;; more information.
5 ;;;;
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)
18 (inhibit-warnings 2)
19 (safety 2)
20 (space 1)
21 (speed 2)))
24 ;;;; package hacking
26 ;;; Our cross-compilation host is out of the picture now, so we no
27 ;;; longer need to worry about collisions between our package names
28 ;;; and cross-compilation host package names, so now is a good time to
29 ;;; rename any package with a bootstrap-only name SB!FOO to its
30 ;;; permanent name SB-FOO.
31 ;;;
32 ;;; (In principle it might be tidier to do this when dumping the cold
33 ;;; image in genesis, but in practice the logic might be a little
34 ;;; messier because genesis dumps both symbols and packages, and we'd
35 ;;; need to make sure that dumped symbols were renamed in the same way
36 ;;; as dumped packages. Or we could do it in cold init, but it's
37 ;;; easier to experiment with and debug things here in warm init than
38 ;;; in cold init, so we do it here instead.)
39 (let ((boot-prefix "SB!")
40 (perm-prefix "SB-"))
41 (dolist (package (list-all-packages))
42 (let ((old-package-name (package-name package)))
43 (when (and (>= (length old-package-name) (length boot-prefix))
44 (string= boot-prefix old-package-name
45 :end2 (length boot-prefix)))
46 (let ((new-package-name (concatenate 'string
47 perm-prefix
48 (subseq old-package-name
49 (length boot-prefix)))))
50 (rename-package package
51 new-package-name
52 (package-nicknames package)))))))
54 ;;; FIXME: This nickname is a deprecated hack for backwards
55 ;;; compatibility with code which assumed the CMU-CL-style
56 ;;; SB-ALIEN/SB-C-CALL split. That split went away and was deprecated
57 ;;; in 0.7.0, so we should get rid of this nickname after a while.
58 (let ((package (find-package "SB-ALIEN")))
59 (rename-package package
60 (package-name package)
61 (cons "SB-C-CALL" (package-nicknames package))))
63 (let ((package (find-package "SB-SEQUENCE")))
64 (rename-package package (package-name package) (list "SEQUENCE")))
66 ;;;; compiling and loading more of the system
68 ;;; FIXME: CMU CL's pclcom.lisp had extra optional stuff wrapped around
69 ;;; COMPILE-PCL, at least some of which we should probably have too:
70 ;;;
71 ;;; (with-compilation-unit
72 ;;; (:optimize '(optimize (debug #+(and (not high-security) small) .5
73 ;;; #-(or high-security small) 2
74 ;;; #+high-security 3)
75 ;;; (speed 2) (safety #+(and (not high-security) small) 0
76 ;;; #-(or high-security small) 2
77 ;;; #+high-security 3)
78 ;;; (inhibit-warnings 2))
79 ;;; :optimize-interface '(optimize-interface #+(and (not high-security) small)
80 ;;; (safety 1)
81 ;;; #+high-security (safety 3))
82 ;;; :context-declarations
83 ;;; '((:external (declare (optimize-interface (safety #-high-security 2 #+high-
84 ;;; security 3)
85 ;;; (debug #-high-security 1 #+high-s
86 ;;; ecurity 3))))
87 ;;; ((:or :macro (:match "$EARLY-") (:match "$BOOT-"))
88 ;;; (declare (optimize (speed 0))))))
89 ;;;
90 ;;; FIXME: This has mutated into a hack which crudely duplicates
91 ;;; functionality from the existing mechanism to load files from
92 ;;; build-order.lisp-expr, without being quite parallel. (E.g. object
93 ;;; files end up alongside the source files instead of ending up in
94 ;;; parallel directory trees.) Maybe we could merge the filenames here
95 ;;; into build-order.lisp-expr with some new flag (perhaps :WARM) to
96 ;;; indicate that the files should be handled not in cold load but
97 ;;; afterwards.
98 (let ((pcl-srcs
99 '(;; CLOS, derived from the PCL reference implementation
101 ;; This PCL build order is based on a particular
102 ;; (arbitrary) linearization of the declared build
103 ;; order dependencies from the old PCL defsys.lisp
104 ;; dependency database.
105 #+nil "src/pcl/walk" ; #+NIL = moved to build-order.lisp-expr
106 "SRC;PCL;EARLY-LOW"
107 "SRC;PCL;MACROS"
108 "SRC;PCL;COMPILER-SUPPORT"
109 "SRC;PCL;LOW"
110 "SRC;PCL;SLOT-NAME"
111 "SRC;PCL;DEFCLASS"
112 "SRC;PCL;DEFS"
113 "SRC;PCL;FNGEN"
114 "SRC;PCL;WRAPPER"
115 "SRC;PCL;CACHE"
116 "SRC;PCL;DLISP"
117 "SRC;PCL;BOOT"
118 "SRC;PCL;VECTOR"
119 "SRC;PCL;SLOTS-BOOT"
120 "SRC;PCL;COMBIN"
121 "SRC;PCL;DFUN"
122 "SRC;PCL;CTOR"
123 "SRC;PCL;BRAID"
124 "SRC;PCL;DLISP3"
125 "SRC;PCL;GENERIC-FUNCTIONS"
126 "SRC;PCL;SLOTS"
127 "SRC;PCL;INIT"
128 "SRC;PCL;STD-CLASS"
129 "SRC;PCL;CPL"
130 "SRC;PCL;FSC"
131 "SRC;PCL;METHODS"
132 "SRC;PCL;FIXUP"
133 "SRC;PCL;DEFCOMBIN"
134 "SRC;PCL;CTYPES"
135 "SRC;PCL;ENV"
136 "SRC;PCL;DOCUMENTATION"
137 "SRC;PCL;PRINT-OBJECT"
138 "SRC;PCL;PRECOM1"
139 "SRC;PCL;PRECOM2"))
140 (other-srcs
141 '(;; miscellaneous functionality which depends on CLOS
142 "SRC;CODE;FORCE-DELAYED-DEFBANGMETHODS"
143 "SRC;CODE;LATE-CONDITION"
145 ;; CLOS-level support for the Gray OO streams
146 ;; extension (which is also supported by various
147 ;; lower-level hooks elsewhere in the code)
148 "SRC;PCL;GRAY-STREAMS-CLASS"
149 "SRC;PCL;GRAY-STREAMS"
151 ;; CLOS-level support for User-extensible sequences.
152 "SRC;PCL;SEQUENCE"
154 ;; other functionality not needed for cold init, moved
155 ;; to warm init to reduce peak memory requirement in
156 ;; cold init
157 "SRC;CODE;DESCRIBE"
158 "SRC;CODE;DESCRIBE-POLICY"
159 "SRC;CODE;INSPECT"
160 "SRC;CODE;PROFILE"
161 "SRC;CODE;NTRACE"
162 "SRC;CODE;STEP"
163 "SRC;CODE;WARM-LIB"
164 #+win32 "SRC;CODE;WARM-MSWIN"
165 "SRC;CODE;RUN-PROGRAM")))
166 (declare (special *compile-files-p*))
167 (flet
168 ((do-srcs (list)
169 (dolist (stem list)
170 (let ((fullname (concatenate 'string "SYS:" stem ".LISP")))
171 (sb-int:/show "about to compile" fullname)
172 (flet ((report-recompile-restart (stream)
173 (format stream "Recompile file ~S" fullname))
174 (report-continue-restart (stream)
175 (format stream
176 "Continue, using possibly bogus file ~S"
177 (compile-file-pathname fullname))))
178 (tagbody
179 retry-compile-file
180 (multiple-value-bind (output-truename warnings-p failure-p)
181 (if *compile-files-p*
182 (compile-file fullname)
183 (compile-file-pathname fullname))
184 (declare (ignore warnings-p))
185 (sb-int:/show "done compiling" fullname)
186 (cond ((not output-truename)
187 (error "COMPILE-FILE of ~S failed." fullname))
188 (failure-p
189 (unwind-protect
190 (restart-case
191 (error "FAILURE-P was set when creating ~S."
192 output-truename)
193 (recompile ()
194 :report report-recompile-restart
195 (go retry-compile-file))
196 (continue ()
197 :report report-continue-restart
198 (setf failure-p nil)))
199 ;; Don't leave failed object files lying around.
200 (when (and failure-p (probe-file output-truename))
201 (delete-file output-truename)
202 (format t "~&deleted ~S~%" output-truename))))
203 ;; Otherwise: success, just fall through.
204 (t nil))
205 (unless (handler-bind
206 ((sb-kernel:redefinition-with-defgeneric
207 #'muffle-warning))
208 (load output-truename))
209 (error "LOAD of ~S failed." output-truename))
210 (sb-int:/show "done loading" output-truename))))))))
212 (let* ((ppd (copy-pprint-dispatch))
213 (sb-debug:*debug-print-variable-alist*
214 (list (cons '*print-pprint-dispatch* ppd)))
215 (*print-pprint-dispatch* ppd))
216 (set-pprint-dispatch
217 'sb-kernel:layout (lambda (stream obj)
218 (print-unreadable-object (obj stream :type t)
219 (write (sb-int:awhen (sb-kernel:layout-classoid obj)
220 (sb-kernel:classoid-name sb-int:it))
221 :stream stream))))
222 (set-pprint-dispatch
223 'sb-kernel:classoid (lambda (stream obj)
224 (print-unreadable-object (obj stream :type t)
225 (write (sb-kernel:classoid-name obj) :stream stream))))
226 (set-pprint-dispatch
227 'package (lambda (stream obj)
228 (print-unreadable-object (obj stream :type t)
229 (write (package-name obj) :stream stream))))
230 (set-pprint-dispatch
231 'pathname (lambda (stream obj)
232 (write-string "#P" stream)
233 (write (namestring obj) :stream stream)))
234 (set-pprint-dispatch
235 'sb-thread:thread (lambda (stream obj)
236 (declare (ignore obj))
237 (write-string "#<main-thread>" stream)))
238 (set-pprint-dispatch
239 'restart (lambda (stream obj)
240 (print-unreadable-object (obj stream :type t :identity t)
241 (write (restart-name obj) :stream stream))))
242 (with-compilation-unit ()
243 (let ((*compile-print* nil))
244 (do-srcs pcl-srcs)))
245 (when *compile-files-p*
246 (format t "~&; Done with PCL compilation~2%"))
247 (do-srcs other-srcs))))
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")