0.8.8.2:
[sbcl/lichteblau.git] / src / cold / warm.lisp
blobf6892a95cc736c8dd38bca4143939786404b239a
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
17 (proclaim '(optimize (compilation-speed 1)
18 (debug #+sb-show 2 #-sb-show 1)
19 (inhibit-warnings 2)
20 (safety 2)
21 (space 1)
22 (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 ;;;; compiling and loading more of the system
65 (let* ((sys *default-pathname-defaults*)
66 (src
67 (merge-pathnames
68 (make-pathname :directory '(:relative "src" :wild-inferiors)
69 :name :wild :type :wild)
70 sys))
71 (contrib
72 (merge-pathnames
73 (make-pathname :directory '(:relative "contrib" :wild-inferiors)
74 :name :wild :type :wild)
75 sys)))
76 (setf (logical-pathname-translations "SYS")
77 `(("SYS:SRC;**;*.*.*" ,src)
78 ("SYS:CONTRIB;**;*.*.*" ,contrib))))
80 ;;; FIXME: CMU CL's pclcom.lisp had extra optional stuff wrapped around
81 ;;; COMPILE-PCL, at least some of which we should probably have too:
82 ;;;
83 ;;; (with-compilation-unit
84 ;;; (:optimize '(optimize (debug #+(and (not high-security) small) .5
85 ;;; #-(or high-security small) 2
86 ;;; #+high-security 3)
87 ;;; (speed 2) (safety #+(and (not high-security) small) 0
88 ;;; #-(or high-security small) 2
89 ;;; #+high-security 3)
90 ;;; (inhibit-warnings 2))
91 ;;; :optimize-interface '(optimize-interface #+(and (not high-security) small)
92 ;;; (safety 1)
93 ;;; #+high-security (safety 3))
94 ;;; :context-declarations
95 ;;; '((:external (declare (optimize-interface (safety #-high-security 2 #+high-
96 ;;; security 3)
97 ;;; (debug #-high-security 1 #+high-s
98 ;;; ecurity 3))))
99 ;;; ((:or :macro (:match "$EARLY-") (:match "$BOOT-"))
100 ;;; (declare (optimize (speed 0))))))
102 ;;; FIXME: This has mutated into a hack which crudely duplicates
103 ;;; functionality from the existing mechanism to load files from
104 ;;; build-order.lisp-expr, without being quite parallel. (E.g. object
105 ;;; files end up alongside the source files instead of ending up in
106 ;;; parallel directory trees.) Maybe we could merge the filenames here
107 ;;; into build-order.lisp-expr with some new flag (perhaps :WARM) to
108 ;;; indicate that the files should be handled not in cold load but
109 ;;; afterwards.
110 (dolist (stem '(;; CLOS, derived from the PCL reference implementation
112 ;; This PCL build order is based on a particular
113 ;; (arbitrary) linearization of the declared build
114 ;; order dependencies from the old PCL defsys.lisp
115 ;; dependency database.
116 #+nil "src/pcl/walk" ; #+NIL = moved to build-order.lisp-expr
117 "SRC;PCL;EARLY-LOW"
118 "SRC;PCL;MACROS"
119 "SRC;PCL;COMPILER-SUPPORT"
120 "SRC;PCL;LOW"
121 "SRC;PCL;SLOT-NAME"
122 "SRC;PCL;DEFCLASS"
123 "SRC;PCL;DEFS"
124 "SRC;PCL;FNGEN"
125 "SRC;PCL;CACHE"
126 "SRC;PCL;DLISP"
127 "SRC;PCL;DLISP2"
128 "SRC;PCL;BOOT"
129 "SRC;PCL;VECTOR"
130 "SRC;PCL;SLOTS-BOOT"
131 "SRC;PCL;COMBIN"
132 "SRC;PCL;DFUN"
133 "SRC;PCL;CTOR"
134 "SRC;PCL;BRAID"
135 "SRC;PCL;DLISP3"
136 "SRC;PCL;GENERIC-FUNCTIONS"
137 "SRC;PCL;SLOTS"
138 "SRC;PCL;INIT"
139 "SRC;PCL;STD-CLASS"
140 "SRC;PCL;CPL"
141 "SRC;PCL;FSC"
142 "SRC;PCL;METHODS"
143 "SRC;PCL;FIXUP"
144 "SRC;PCL;DEFCOMBIN"
145 "SRC;PCL;CTYPES"
146 "SRC;PCL;ENV"
147 "SRC;PCL;DOCUMENTATION"
148 "SRC;PCL;PRINT-OBJECT"
149 "SRC;PCL;PRECOM1"
150 "SRC;PCL;PRECOM2"
152 ;; miscellaneous functionality which depends on CLOS
153 "SRC;CODE;FORCE-DELAYED-DEFBANGMETHODS"
154 "SRC;CODE;LATE-CONDITION"
156 ;; CLOS-level support for the Gray OO streams
157 ;; extension (which is also supported by various
158 ;; lower-level hooks elsewhere in the code)
159 "SRC;PCL;GRAY-STREAMS-CLASS"
160 "SRC;PCL;GRAY-STREAMS"
162 ;; other functionality not needed for cold init, moved
163 ;; to warm init to reduce peak memory requirement in
164 ;; cold init
165 "SRC;CODE;DESCRIBE"
166 "SRC;CODE;DESCRIBE-POLICY"
167 "SRC;CODE;INSPECT"
168 "SRC;CODE;PROFILE"
169 "SRC;CODE;NTRACE"
170 "SRC;CODE;FOREIGN"
171 "SRC;CODE;RUN-PROGRAM"
173 ;; Code derived from PCL's pre-ANSI DESCRIBE-OBJECT
174 ;; facility is still used in our ANSI DESCRIBE
175 ;; facility, and should be compiled and loaded after
176 ;; our DESCRIBE facility is compiled and loaded.
177 "SRC;PCL;DESCRIBE"))
179 (let ((fullname (concatenate 'string "SYS:" stem ".LISP")))
180 (sb-int:/show "about to compile" fullname)
181 (flet ((report-recompile-restart (stream)
182 (format stream "Recompile file ~S" fullname))
183 (report-continue-restart (stream)
184 (format stream
185 "Continue, using possibly bogus file ~S"
186 (compile-file-pathname fullname))))
187 (tagbody
188 retry-compile-file
189 (multiple-value-bind (output-truename warnings-p failure-p)
190 (compile-file fullname)
191 (declare (ignore warnings-p))
192 (sb-int:/show "done compiling" fullname)
193 (cond ((not output-truename)
194 (error "COMPILE-FILE of ~S failed." fullname))
195 (failure-p
196 (unwind-protect
197 (restart-case
198 (error "FAILURE-P was set when creating ~S."
199 output-truename)
200 (recompile ()
201 :report report-recompile-restart
202 (go retry-compile-file))
203 (continue ()
204 :report report-continue-restart
205 (setf failure-p nil)))
206 ;; Don't leave failed object files lying around.
207 (when (and failure-p (probe-file output-truename))
208 (delete-file output-truename)
209 (format t "~&deleted ~S~%" output-truename))))
210 ;; Otherwise: success, just fall through.
211 (t nil))
212 (unless (load output-truename)
213 (error "LOAD of ~S failed." output-truename))
214 (sb-int:/show "done loading" output-truename))))))
216 ;;;; setting package documentation
218 ;;; While we were running on the cross-compilation host, we tried to
219 ;;; be portable and not overwrite the doc strings for the standard
220 ;;; packages. But now the cross-compilation host is only a receding
221 ;;; memory, and we can have our way with the doc strings.
222 (sb-int:/show "setting package documentation")
223 #+sb-doc (setf (documentation (find-package "COMMON-LISP") t)
224 "public: home of symbols defined by the ANSI language specification")
225 #+sb-doc (setf (documentation (find-package "COMMON-LISP-USER") t)
226 "public: the default package for user code and data")
227 #+sb-doc (setf (documentation (find-package "KEYWORD") t)
228 "public: home of keywords")