1 ;;;; This software is part of the SBCL system. See the README file for
4 ;;;; This software is derived from the CMU CL system, which was
5 ;;;; written at Carnegie Mellon University and released into the
6 ;;;; public domain. The software is in the public domain and is
7 ;;;; provided with absolutely no warranty. See the COPYING and CREDITS
8 ;;;; files for more information.
10 (in-package "SB-COLD")
12 (defparameter *full-calls-to-warn-about
*
13 '(;mask-signed-field ;; Too many to fix
16 ;;; Set of function names whose definition will never be seen in make-host-2,
17 ;;; as they are deferred until warm load.
18 ;;; The table is populated later in this file.
19 (defparameter *undefined-fun-whitelist
* (make-hash-table :test
'equal
))
21 (defvar *symbol-values-for-genesis
*)
22 (export '*symbol-values-for-genesis
*)
23 (let ((pathname "output/init-symbol-values.lisp-expr"))
24 (setq *symbol-values-for-genesis
*
25 (and (probe-file pathname
) (read-from-file pathname
)))
26 (defun save-initial-symbol-values ()
27 (with-open-file (f pathname
:direction
:output
:if-exists
:supersede
)
28 (write *symbol-values-for-genesis
* :stream f
:readably t
))))
30 (when (make-host-1-parallelism)
32 #+#.
(cl:if
(cl:find-package
"SB-POSIX") '(and) '(or))
33 (defun parallel-make-host-1 (max-jobs)
34 (let ((subprocess-count 0)
35 (subprocess-list nil
))
37 (multiple-value-bind (pid status
) (sb-posix:wait
)
38 (format t
"~&; Subprocess ~D exit status ~D~%" pid status
)
39 (setq subprocess-list
(delete pid subprocess-list
)))
40 (decf subprocess-count
)))
41 (do-stems-and-flags (stem flags
)
42 (unless (position :not-host flags
)
43 (when (>= subprocess-count max-jobs
)
45 (let ((pid (sb-posix:fork
)))
47 (in-host-compilation-mode
48 (lambda () (compile-stem stem flags
:host-compile
)))
49 ;; FIXME: convey exit code based on COMPILE result.
51 (nth-value 1 (find-symbol "OS-EXIT" :sb-sys
)))
52 `(,(find-symbol "OS-EXIT" :sb-sys
) 0)
53 `(sb-unix:unix-exit
0)))
54 (push pid subprocess-list
)
55 (incf subprocess-count
)
56 ;; Do not wait for the compile to finish. Just load as source.
57 (let ((source (merge-pathnames (stem-remap-target stem
)
58 (make-pathname :type
"lisp"))))
59 (let ((sb-ext:*evaluator-mode
* :interpret
))
60 (in-host-compilation-mode
62 (load source
:verbose t
:print nil
))))))))
63 (loop (if (plusp subprocess-count
) (wait) (return)))))
65 ;; We want to load compiled files, because that's what this function promises.
66 ;; Reloading is tricky because constructors for interned ctypes will construct
67 ;; new objects via their LOAD-TIME-VALUE forms, but globaldb already stored
68 ;; some objects from the interpreted pre-load.
69 ;; So wipe everything out that causes problems down the line.
70 ;; (Or perhaps we could make their effects idempotent)
71 (format t
"~&; Parallel build: Clearing globaldb~%")
73 (when (get s
:sb-xc-globaldb-info
)
74 (remf (symbol-plist s
) :sb-xc-globaldb-info
)))
75 (fill (symbol-value 'sb
!c
::*info-types
*) nil
)
76 (clrhash (symbol-value 'sb
!kernel
::*forward-referenced-layouts
*))
77 (setf (symbol-value 'sb
!kernel
:*type-system-initialized
*) nil
)
78 (makunbound 'sb
!c
::*backend-primitive-type-names
*)
79 (makunbound 'sb
!c
::*backend-primitive-type-aliases
*)
81 (format t
"~&; Parallel build: Reloading compilation artifacts~%")
82 ;; Now it works to load fasls.
83 (in-host-compilation-mode
85 (handler-bind ((sb-kernel:redefinition-warning
#'muffle-warning
))
86 (do-stems-and-flags (stem flags
)
87 (unless (position :not-host flags
)
88 (load (stem-object-path stem flags
:host-compile
)
89 :verbose t
:print nil
))))))
90 (format t
"~&; Parallel build: Fasl loading complete~%"))
92 ;;; Either load or compile-then-load the cross-compiler into the
93 ;;; cross-compilation host Common Lisp.
94 (defun load-or-cload-xcompiler (load-or-cload-stem)
96 (declare (type function load-or-cload-stem
))
98 ;; The running-in-the-host-Lisp Python cross-compiler defines its
99 ;; own versions of a number of functions which should not overwrite
100 ;; host-Lisp functions. Instead we put them in a special package.
102 ;; The common theme of the functions, macros, constants, and so
103 ;; forth in this package is that they run in the host and affect the
104 ;; compilation of the target.
105 (let ((package-name "SB-XC"))
106 (make-package package-name
:use nil
:nicknames nil
)
107 (dolist (name '(;; the constants (except for T and NIL which have
108 ;; a specially hacked correspondence between
109 ;; cross-compilation host Lisp and target Lisp)
110 "ARRAY-DIMENSION-LIMIT"
112 "ARRAY-TOTAL-SIZE-LIMIT"
129 "CALL-ARGUMENTS-LIMIT"
131 "DOUBLE-FLOAT-EPSILON"
132 "DOUBLE-FLOAT-NEGATIVE-EPSILON"
133 "INTERNAL-TIME-UNITS-PER-SECOND"
134 "LAMBDA-LIST-KEYWORDS"
135 "LAMBDA-PARAMETERS-LIMIT"
136 "LEAST-NEGATIVE-DOUBLE-FLOAT"
137 "LEAST-NEGATIVE-LONG-FLOAT"
138 "LEAST-NEGATIVE-NORMALIZED-DOUBLE-FLOAT"
139 "LEAST-NEGATIVE-NORMALIZED-LONG-FLOAT"
140 "LEAST-NEGATIVE-NORMALIZED-SHORT-FLOAT"
141 "LEAST-NEGATIVE-NORMALIZED-SINGLE-FLOAT"
142 "LEAST-NEGATIVE-SHORT-FLOAT"
143 "LEAST-NEGATIVE-SINGLE-FLOAT"
144 "LEAST-POSITIVE-DOUBLE-FLOAT"
145 "LEAST-POSITIVE-LONG-FLOAT"
146 "LEAST-POSITIVE-NORMALIZED-DOUBLE-FLOAT"
147 "LEAST-POSITIVE-NORMALIZED-LONG-FLOAT"
148 "LEAST-POSITIVE-NORMALIZED-SHORT-FLOAT"
149 "LEAST-POSITIVE-NORMALIZED-SINGLE-FLOAT"
150 "LEAST-POSITIVE-SHORT-FLOAT"
151 "LEAST-POSITIVE-SINGLE-FLOAT"
153 "LONG-FLOAT-NEGATIVE-EPSILON"
154 "MOST-NEGATIVE-DOUBLE-FLOAT"
155 "MOST-NEGATIVE-FIXNUM"
156 "MOST-NEGATIVE-LONG-FLOAT"
157 "MOST-NEGATIVE-SHORT-FLOAT"
158 "MOST-NEGATIVE-SINGLE-FLOAT"
159 "MOST-POSITIVE-DOUBLE-FLOAT"
160 "MOST-POSITIVE-FIXNUM"
161 "MOST-POSITIVE-LONG-FLOAT"
162 "MOST-POSITIVE-SHORT-FLOAT"
163 "MOST-POSITIVE-SINGLE-FLOAT"
164 "MULTIPLE-VALUES-LIMIT"
166 "SHORT-FLOAT-EPSILON"
167 "SHORT-FLOAT-NEGATIVE-EPSILON"
168 "SINGLE-FLOAT-EPSILON"
169 "SINGLE-FLOAT-NEGATIVE-EPSILON"
171 ;; everything else which needs a separate
172 ;; existence in xc and target
175 "BYTE" "BYTE-POSITION" "BYTE-SIZE"
177 "CLASS" "CLASS-NAME" "CLASS-OF"
180 "COMPILE-FILE-PATHNAME"
181 "*COMPILE-FILE-PATHNAME*"
182 "*COMPILE-FILE-TRUENAME*"
185 "COMPILER-MACRO-FUNCTION"
188 "DEFINE-MODIFY-MACRO"
189 "DEFINE-SETF-EXPANDER"
190 "DEFMACRO" "DEFSETF" "DEFSTRUCT" "DEFTYPE"
191 "DEPOSIT-FIELD" "DPB"
192 "FBOUNDP" "FDEFINITION" "FMAKUNBOUND"
194 "GENSYM" "*GENSYM-COUNTER*"
197 "LISP-IMPLEMENTATION-TYPE" "LISP-IMPLEMENTATION-VERSION"
199 "MACROEXPAND" "MACROEXPAND-1" "*MACROEXPAND-HOOK*"
201 "MAKE-LOAD-FORM-SAVING-SLOTS"
209 "UPGRADED-ARRAY-ELEMENT-TYPE"
210 "UPGRADED-COMPLEX-PART-TYPE"
211 "WITH-COMPILATION-UNIT"))
212 (export (intern name package-name
) package-name
)))
214 (dolist (package (list-all-packages))
215 (when (= (mismatch (package-name package
) "SB!") 3)
217 (mapcar (lambda (name) (find-symbol name
"SB-XC"))
218 '("BYTE" "BYTE-POSITION" "BYTE-SIZE"
219 "DPB" "LDB" "LDB-TEST"
220 "DEPOSIT-FIELD" "MASK-FIELD"))
223 ;; Build a version of Python to run in the host Common Lisp, to be
224 ;; used only in cross-compilation.
226 ;; Note that files which are marked :ASSEM, to cause them to be
227 ;; processed with SB!C:ASSEMBLE-FILE when we're running under the
228 ;; cross-compiler or the target lisp, are still processed here, just
229 ;; with the ordinary Lisp compiler, and this is intentional, in
230 ;; order to make the compiler aware of the definitions of assembly
232 (if (and (make-host-1-parallelism)
233 (eq load-or-cload-stem
#'host-cload-stem
))
234 (funcall (intern "PARALLEL-MAKE-HOST-1" 'sb-cold
)
235 (make-host-1-parallelism))
236 (do-stems-and-flags (stem flags
)
237 (unless (find :not-host flags
)
238 (funcall load-or-cload-stem stem flags
)
239 #!+sb-show
(warn-when-cl-snapshot-diff *cl-snapshot
*))))
241 ;; If the cross-compilation host is SBCL itself, we can use the
242 ;; PURIFY extension to freeze everything in place, reducing the
243 ;; amount of work done on future GCs. In machines with limited
244 ;; memory, this could help, by reducing the amount of memory which
245 ;; needs to be juggled in a full GC. And it can hardly hurt, since
246 ;; (in the ordinary build procedure anyway) essentially everything
247 ;; which is reachable at this point will remain reachable for the
250 ;; (Except that purifying actually slows down GENCGC). -- JES, 2006-05-30
251 #+(and sbcl
(not gencgc
))
256 ;; Keep these in order by package, then symbol.
261 compute-applicable-methods
263 make-load-form-saving-slots
265 sb
!kernel
:profile-deinit
)
266 ;; CLOS implementation
267 '(sb!mop
:class-finalized-p
268 sb
!mop
:class-prototype
270 sb
!mop
:eql-specializer-object
271 sb
!mop
:finalize-inheritance
272 sb
!mop
:generic-function-name
273 sb
!mop
:slot-definition-allocation
274 sb
!mop
:slot-definition-name
275 sb
!pcl
::%force-cache-flushes
276 sb
!pcl
::check-wrapper-validity
277 sb
!pcl
::class-has-a-forward-referenced-superclass-p
278 sb
!pcl
::class-wrapper
279 sb
!pcl
::compute-gf-ftype
280 sb
!pcl
::definition-source
281 sb
!pcl
:ensure-class-finalized
)
282 ;; CLOS-based packages
283 '(sb!gray
:stream-clear-input
284 sb
!gray
:stream-clear-output
285 sb
!gray
:stream-file-position
286 sb
!gray
:stream-finish-output
287 sb
!gray
:stream-force-output
288 sb
!gray
:stream-fresh-line
289 sb
!gray
:stream-line-column
290 sb
!gray
:stream-line-length
291 sb
!gray
:stream-listen
292 sb
!gray
:stream-peek-char
293 sb
!gray
:stream-read-byte
294 sb
!gray
:stream-read-char
295 sb
!gray
:stream-read-char-no-hang
296 sb
!gray
:stream-read-line
297 sb
!gray
:stream-read-sequence
298 sb
!gray
:stream-terpri
299 sb
!gray
:stream-unread-char
300 sb
!gray
:stream-write-byte
301 sb
!gray
:stream-write-char
302 sb
!gray
:stream-write-sequence
303 sb
!gray
:stream-write-string
304 sb
!sequence
:concatenate
308 sb
!sequence
:count-if-not
310 sb
!sequence
:delete-duplicates
311 sb
!sequence
:delete-if
312 sb
!sequence
:delete-if-not
313 (setf sb
!sequence
:elt
)
319 sb
!sequence
:find-if-not
320 (setf sb
!sequence
:iterator-element
)
321 sb
!sequence
:iterator-endp
322 sb
!sequence
:iterator-step
324 sb
!sequence
:make-sequence-iterator
325 sb
!sequence
:make-sequence-like
330 sb
!sequence
:nsubstitute
331 sb
!sequence
:nsubstitute-if
332 sb
!sequence
:nsubstitute-if-not
334 sb
!sequence
:position-if
335 sb
!sequence
:position-if-not
338 sb
!sequence
:remove-duplicates
339 sb
!sequence
:remove-if
340 sb
!sequence
:remove-if-not
345 sb
!sequence
:stable-sort
347 sb
!sequence
:substitute
348 sb
!sequence
:substitute-if
349 sb
!sequence
:substitute-if-not
)
352 '(sb!interpreter
:%fun-type
353 sb
!interpreter
:env-policy
354 sb
!interpreter
:eval-in-environment
355 sb
!interpreter
:find-lexical-fun
356 sb
!interpreter
:find-lexical-var
357 sb
!interpreter
::flush-everything
358 sb
!interpreter
::fun-lexically-notinline-p
359 sb
!interpreter
:lexenv-from-env
360 sb
!interpreter
::lexically-unlocked-symbol-p
361 sb
!interpreter
:list-locals
362 sb
!interpreter
:prepare-for-compile
363 sb
!interpreter
::reconstruct-syntactic-closure-env
)
365 '(sb!debug
::find-interrupted-name-and-frame
366 sb
!impl
::encapsulate-generic-function
367 sb
!impl
::encapsulated-generic-function-p
368 sb
!impl
::get-processes-status-changes
371 sb
!impl
::unencapsulate-generic-function
)))
372 (setf (gethash sym
*undefined-fun-whitelist
*) t
))