improve the SB-EXT:GC docstring(s)
[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 (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)))
22
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
63 (let ((package (find-package "SB-SEQUENCE")))
64   (rename-package package (package-name package) (list "SEQUENCE")))
65 \f
66 ;;;; compiling and loading more of the system
67
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 (dolist (stem '(;; CLOS, derived from the PCL reference implementation
99                 ;;
100                 ;; This PCL build order is based on a particular
101                 ;; (arbitrary) linearization of the declared build
102                 ;; order dependencies from the old PCL defsys.lisp
103                 ;; dependency database.
104                 #+nil "src/pcl/walk" ; #+NIL = moved to build-order.lisp-expr
105                 "SRC;PCL;EARLY-LOW"
106                 "SRC;PCL;MACROS"
107                 "SRC;PCL;COMPILER-SUPPORT"
108                 "SRC;PCL;LOW"
109                 "SRC;PCL;SLOT-NAME"
110                 "SRC;PCL;DEFCLASS"
111                 "SRC;PCL;DEFS"
112                 "SRC;PCL;FNGEN"
113                 "SRC;PCL;WRAPPER"
114                 "SRC;PCL;CACHE"
115                 "SRC;PCL;DLISP"
116                 "SRC;PCL;BOOT"
117                 "SRC;PCL;VECTOR"
118                 "SRC;PCL;SLOTS-BOOT"
119                 "SRC;PCL;COMBIN"
120                 "SRC;PCL;DFUN"
121                 "SRC;PCL;CTOR"
122                 "SRC;PCL;BRAID"
123                 "SRC;PCL;DLISP3"
124                 "SRC;PCL;GENERIC-FUNCTIONS"
125                 "SRC;PCL;SLOTS"
126                 "SRC;PCL;INIT"
127                 "SRC;PCL;STD-CLASS"
128                 "SRC;PCL;CPL"
129                 "SRC;PCL;FSC"
130                 "SRC;PCL;METHODS"
131                 "SRC;PCL;FIXUP"
132                 "SRC;PCL;DEFCOMBIN"
133                 "SRC;PCL;CTYPES"
134                 "SRC;PCL;ENV"
135                 "SRC;PCL;DOCUMENTATION"
136                 "SRC;PCL;PRINT-OBJECT"
137                 "SRC;PCL;PRECOM1"
138                 "SRC;PCL;PRECOM2"
139
140                 ;; miscellaneous functionality which depends on CLOS
141                 "SRC;CODE;FORCE-DELAYED-DEFBANGMETHODS"
142                 "SRC;CODE;LATE-CONDITION"
143
144                 ;; CLOS-level support for the Gray OO streams
145                 ;; extension (which is also supported by various
146                 ;; lower-level hooks elsewhere in the code)
147                 "SRC;PCL;GRAY-STREAMS-CLASS"
148                 "SRC;PCL;GRAY-STREAMS"
149
150                 ;; CLOS-level support for User-extensible sequences.
151                 "SRC;PCL;SEQUENCE"
152
153                 ;; other functionality not needed for cold init, moved
154                 ;; to warm init to reduce peak memory requirement in
155                 ;; cold init
156                 "SRC;CODE;DESCRIBE"
157                 "SRC;CODE;DESCRIBE-POLICY"
158                 "SRC;CODE;INSPECT"
159                 "SRC;CODE;PROFILE"
160                 "SRC;CODE;NTRACE"
161                 "SRC;CODE;STEP"
162                 "SRC;CODE;RUN-PROGRAM"))
163
164   (let ((fullname (concatenate 'string "SYS:" stem ".LISP")))
165     (sb-int:/show "about to compile" fullname)
166     (flet ((report-recompile-restart (stream)
167              (format stream "Recompile file ~S" fullname))
168            (report-continue-restart (stream)
169              (format stream
170                      "Continue, using possibly bogus file ~S"
171                      (compile-file-pathname fullname))))
172       (tagbody
173        retry-compile-file
174          (multiple-value-bind (output-truename warnings-p failure-p)
175              (if *compile-files-p*
176                  (compile-file fullname)
177                  (compile-file-pathname fullname))
178            (declare (ignore warnings-p))
179            (sb-int:/show "done compiling" fullname)
180            (cond ((not output-truename)
181                   (error "COMPILE-FILE of ~S failed." fullname))
182                  (failure-p
183                   (unwind-protect
184                        (restart-case
185                            (error "FAILURE-P was set when creating ~S."
186                                   output-truename)
187                          (recompile ()
188                            :report report-recompile-restart
189                            (go retry-compile-file))
190                          (continue ()
191                            :report report-continue-restart
192                            (setf failure-p nil)))
193                     ;; Don't leave failed object files lying around.
194                     (when (and failure-p (probe-file output-truename))
195                           (delete-file output-truename)
196                           (format t "~&deleted ~S~%" output-truename))))
197                  ;; Otherwise: success, just fall through.
198                  (t nil))
199            (unless (load output-truename)
200              (error "LOAD of ~S failed." output-truename))
201            (sb-int:/show "done loading" output-truename))))))
202 \f
203 ;;;; setting package documentation
204
205 ;;; While we were running on the cross-compilation host, we tried to
206 ;;; be portable and not overwrite the doc strings for the standard
207 ;;; packages. But now the cross-compilation host is only a receding
208 ;;; memory, and we can have our way with the doc strings.
209 (sb-int:/show "setting package documentation")
210 #+sb-doc (setf (documentation (find-package "COMMON-LISP") t)
211 "public: home of symbols defined by the ANSI language specification")
212 #+sb-doc (setf (documentation (find-package "COMMON-LISP-USER") t)
213                "public: the default package for user code and data")
214 #+sb-doc (setf (documentation (find-package "KEYWORD") t)
215                "public: home of keywords")
216 \f
217