0.pre8.112:
[sbcl.git] / src / cold / warm.lisp
1 ;;;; "warm initialization": initialization which comes after cold init
2
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.
11
12 (in-package "COMMON-LISP-USER")
13 \f
14 ;;;; general warm init compilation policy
15
16
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)))
23 \f
24 ;;;; package hacking
25
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)))))))
53
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))))
62 \f
63 ;;;; compiling and loading more of the system
64
65 ;;; FIXME: CMU CL's pclcom.lisp had extra optional stuff wrapped around
66 ;;; COMPILE-PCL, at least some of which we should probably have too:
67 ;;;
68 ;;; (with-compilation-unit
69 ;;;     (:optimize '(optimize (debug #+(and (not high-security) small) .5
70 ;;;                               #-(or high-security small) 2
71 ;;;                               #+high-security 3)
72 ;;;                        (speed 2) (safety #+(and (not high-security) small) 0
73 ;;;                                          #-(or high-security small) 2
74 ;;;                                          #+high-security 3)
75 ;;;                        (inhibit-warnings 2))
76 ;;;      :optimize-interface '(optimize-interface #+(and (not high-security) small)
77 ;;; (safety 1)
78 ;;;                                            #+high-security (safety 3))
79 ;;;      :context-declarations
80 ;;;      '((:external (declare (optimize-interface (safety #-high-security 2 #+high-
81 ;;; security 3)
82 ;;;                                             (debug #-high-security 1 #+high-s
83 ;;; ecurity 3))))
84 ;;;     ((:or :macro (:match "$EARLY-") (:match "$BOOT-"))
85 ;;;     (declare (optimize (speed 0))))))
86 ;;;
87 ;;; FIXME: This has mutated into a hack which crudely duplicates
88 ;;; functionality from the existing mechanism to load files from
89 ;;; build-order.lisp-expr, without being quite parallel. (E.g. object
90 ;;; files end up alongside the source files instead of ending up in
91 ;;; parallel directory trees.) Maybe we could merge the filenames here
92 ;;; into build-order.lisp-expr with some new flag (perhaps :WARM) to
93 ;;; indicate that the files should be handled not in cold load but
94 ;;; afterwards. 
95 (dolist (stem '(;; CLOS, derived from the PCL reference implementation
96                 ;;
97                 ;; This PCL build order is based on a particular
98                 ;; (arbitrary) linearization of the declared build
99                 ;; order dependencies from the old PCL defsys.lisp
100                 ;; dependency database.
101                 #+nil "src/pcl/walk" ; #+NIL = moved to build-order.lisp-expr
102                 "src/pcl/early-low"
103                 "src/pcl/macros"
104                 "src/pcl/compiler-support"
105                 "src/pcl/low"
106                 "src/pcl/slot-name"
107                 "src/pcl/defclass"
108                 "src/pcl/defs"
109                 "src/pcl/fngen"
110                 "src/pcl/cache"
111                 "src/pcl/dlisp"
112                 "src/pcl/dlisp2"
113                 "src/pcl/boot"
114                 "src/pcl/vector"
115                 "src/pcl/slots-boot"
116                 "src/pcl/combin"
117                 "src/pcl/dfun"
118                 "src/pcl/ctor"
119                 "src/pcl/braid"
120                 "src/pcl/dlisp3"
121                 "src/pcl/generic-functions"
122                 "src/pcl/slots"
123                 "src/pcl/init"
124                 "src/pcl/std-class"
125                 "src/pcl/cpl"
126                 "src/pcl/fsc"
127                 "src/pcl/methods"
128                 "src/pcl/fixup"
129                 "src/pcl/defcombin"
130                 "src/pcl/ctypes"
131                 "src/pcl/env"
132                 "src/pcl/documentation"
133                 "src/pcl/print-object"
134                 "src/pcl/precom1"
135                 "src/pcl/precom2"
136
137                 ;; miscellaneous functionality which depends on CLOS
138                 "src/code/force-delayed-defbangmethods"
139
140                 ;; CLOS-level support for the Gray OO streams
141                 ;; extension (which is also supported by various
142                 ;; lower-level hooks elsewhere in the code)
143                 "src/pcl/gray-streams-class"
144                 "src/pcl/gray-streams"
145
146                 ;; other functionality not needed for cold init, moved
147                 ;; to warm init to reduce peak memory requirement in
148                 ;; cold init
149                 "src/code/describe"
150                 "src/code/describe-policy"
151                 "src/code/inspect"
152                 "src/code/profile"
153                 "src/code/ntrace"
154                 "src/code/foreign"
155                 "src/code/run-program"
156
157                 ;; Code derived from PCL's pre-ANSI DESCRIBE-OBJECT
158                 ;; facility is still used in our ANSI DESCRIBE
159                 ;; facility, and should be compiled and loaded after
160                 ;; our DESCRIBE facility is compiled and loaded.
161                 "src/pcl/describe"))
162
163   (let ((fullname (concatenate 'string stem ".lisp")))
164     (sb-int:/show "about to compile" fullname)
165     (multiple-value-bind
166         (compiled-truename compilation-warnings-p compilation-failure-p)
167         (compile-file fullname)
168       (declare (ignore compilation-warnings-p))
169       (sb-int:/show "done compiling" fullname)
170       (cond (compilation-failure-p
171              (error "COMPILE-FILE of ~S failed." fullname))
172             (t
173              (unless (load compiled-truename)
174                (error "LOAD of ~S failed." compiled-truename))
175              (sb-int:/show "done loading" compiled-truename))))))
176 \f
177 ;;;; setting package documentation
178
179 ;;; While we were running on the cross-compilation host, we tried to
180 ;;; be portable and not overwrite the doc strings for the standard
181 ;;; packages. But now the cross-compilation host is only a receding
182 ;;; memory, and we can have our way with the doc strings.
183 (sb-int:/show "setting package documentation")
184 #+sb-doc (setf (documentation (find-package "COMMON-LISP") t)
185 "public: home of symbols defined by the ANSI language specification")
186 #+sb-doc (setf (documentation (find-package "COMMON-LISP-USER") t)
187                "public: the default package for user code and data")
188 #+sb-doc (setf (documentation (find-package "KEYWORD") t)
189                "public: home of keywords")
190
191 ;;; KLUDGE: It'd be nicer to do this in the table with the other
192 ;;; non-standard packages. -- WHN 19991206
193 #+sb-doc (setf (documentation (find-package "SB-SLOT-ACCESSOR-NAME") t)
194                "private: home of CLOS slot accessor internal names")
195
196 ;;; FIXME: There doesn't seem to be any easy way to get package doc strings
197 ;;; through the cold boot process. They need to be set somewhere. Maybe the
198 ;;; easiest thing to do is to read them out of package-data-list.lisp-expr
199 ;;; now?