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 ;;; Either load or compile-then-load the cross-compiler into the
13 ;;; cross-compilation host Common Lisp.
14 (defun load-or-cload-xcompiler (load-or-cload-stem)
16 ;; The running-in-the-host-Lisp Python cross-compiler defines its
17 ;; own versions of a number of functions which should not overwrite
18 ;; host-Lisp functions. Instead we put them in a special package.
20 ;; The common theme of the functions, macros, constants, and so
21 ;; forth in this package is that they run in the host and affect the
22 ;; compilation of the target.
23 (let ((package-name "SB-XC"))
24 (make-package package-name :use nil :nicknames nil)
25 (dolist (name '(;; the constants (except for T and NIL which have
26 ;; a specially hacked correspondence between
27 ;; cross-compilation host Lisp and target Lisp)
28 "ARRAY-DIMENSION-LIMIT"
30 "ARRAY-TOTAL-SIZE-LIMIT"
47 "CALL-ARGUMENTS-LIMIT"
49 "DOUBLE-FLOAT-EPSILON"
50 "DOUBLE-FLOAT-NEGATIVE-EPSILON"
51 "INTERNAL-TIME-UNITS-PER-SECOND"
52 "LAMBDA-LIST-KEYWORDS"
53 "LAMBDA-PARAMETERS-LIMIT"
54 "LEAST-NEGATIVE-DOUBLE-FLOAT"
55 "LEAST-NEGATIVE-LONG-FLOAT"
56 "LEAST-NEGATIVE-NORMALIZED-DOUBLE-FLOAT"
57 "LEAST-NEGATIVE-NORMALIZED-LONG-FLOAT"
58 "LEAST-NEGATIVE-NORMALIZED-SHORT-FLOAT"
59 "LEAST-NEGATIVE-NORMALIZED-SINGLE-FLOAT"
60 "LEAST-NEGATIVE-SHORT-FLOAT"
61 "LEAST-NEGATIVE-SINGLE-FLOAT"
62 "LEAST-POSITIVE-DOUBLE-FLOAT"
63 "LEAST-POSITIVE-LONG-FLOAT"
64 "LEAST-POSITIVE-NORMALIZED-DOUBLE-FLOAT"
65 "LEAST-POSITIVE-NORMALIZED-LONG-FLOAT"
66 "LEAST-POSITIVE-NORMALIZED-SHORT-FLOAT"
67 "LEAST-POSITIVE-NORMALIZED-SINGLE-FLOAT"
68 "LEAST-POSITIVE-SHORT-FLOAT"
69 "LEAST-POSITIVE-SINGLE-FLOAT"
71 "LONG-FLOAT-NEGATIVE-EPSILON"
72 "MOST-NEGATIVE-DOUBLE-FLOAT"
73 "MOST-NEGATIVE-FIXNUM"
74 "MOST-NEGATIVE-LONG-FLOAT"
75 "MOST-NEGATIVE-SHORT-FLOAT"
76 "MOST-NEGATIVE-SINGLE-FLOAT"
77 "MOST-POSITIVE-DOUBLE-FLOAT"
78 "MOST-POSITIVE-FIXNUM"
79 "MOST-POSITIVE-LONG-FLOAT"
80 "MOST-POSITIVE-SHORT-FLOAT"
81 "MOST-POSITIVE-SINGLE-FLOAT"
82 "MULTIPLE-VALUES-LIMIT"
85 "SHORT-FLOAT-NEGATIVE-EPSILON"
86 "SINGLE-FLOAT-EPSILON"
87 "SINGLE-FLOAT-NEGATIVE-EPSILON"
89 ;; everything else which needs a separate
90 ;; existence in xc and target
92 "BYTE" "BYTE-POSITION" "BYTE-SIZE"
93 "CLASS" "CLASS-NAME" "CLASS-OF"
95 "COMPILE-FILE-PATHNAME"
96 "*COMPILE-FILE-PATHNAME*"
97 "*COMPILE-FILE-TRUENAME*"
100 "COMPILER-MACRO-FUNCTION"
103 "DEFINE-MODIFY-MACRO"
104 "DEFINE-SETF-EXPANDER"
105 "DEFMACRO" "DEFSETF" "DEFSTRUCT" "DEFTYPE"
106 "DEPOSIT-FIELD" "DPB"
107 "FBOUNDP" "FDEFINITION" "FMAKUNBOUND"
111 "LISP-IMPLEMENTATION-TYPE" "LISP-IMPLEMENTATION-VERSION"
113 "MACROEXPAND" "MACROEXPAND-1" "*MACROEXPAND-HOOK*"
115 "MAKE-LOAD-FORM-SAVING-SLOTS"
124 "WITH-COMPILATION-UNIT"))
125 (export (intern name package-name) package-name)))
127 (dolist (package-name '("SB!ALIEN"
135 #!+sb-dyncount "SB!DYNCOUNT"
152 (shadowing-import (mapcar (lambda (name) (find-symbol name "SB-XC"))
153 '("BYTE" "BYTE-POSITION" "BYTE-SIZE"
154 "DPB" "LDB" "LDB-TEST"
155 "DEPOSIT-FIELD" "MASK-FIELD"))
158 ;; Build a version of Python to run in the host Common Lisp, to be
159 ;; used only in cross-compilation.
161 ;; Note that files which are marked :ASSEM, to cause them to be
162 ;; processed with SB!C:ASSEMBLE-FILE when we're running under the
163 ;; cross-compiler or the target lisp, are still processed here, just
164 ;; with the ordinary Lisp compiler, and this is intentional, in
165 ;; order to make the compiler aware of the definitions of assembly
167 (do-stems-and-flags (stem flags)
168 (unless (find :not-host flags)
169 (funcall load-or-cload-stem
171 :ignore-failure-p (find :ignore-failure-p flags))
172 #!+sb-show (warn-when-cl-snapshot-diff *cl-snapshot*)))
174 ;; If the cross-compilation host is SBCL itself, we can use the
175 ;; PURIFY extension to freeze everything in place, reducing the
176 ;; amount of work done on future GCs. In machines with limited
177 ;; memory, this could help, by reducing the amount of memory which
178 ;; needs to be juggled in a full GC. And it can hardly hurt, since
179 ;; (in the ordinary build procedure anyway) essentially everything
180 ;; which is reachable at this point will remain reachable for the
182 #+sbcl (sb-ext:purify)