8fcc696af264e44420a2afa2cbfc1f85e22b635e
[sbcl.git] / src / cold / defun-load-or-cload-xcompiler.lisp
1 ;;;; This software is part of the SBCL system. See the README file for
2 ;;;; more information.
3 ;;;;
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.
9
10 (in-package "SB-COLD")
11
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)
15
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.
19   ;;
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"
29                     "ARRAY-RANK-LIMIT" 
30                     "ARRAY-TOTAL-SIZE-LIMIT" 
31                     "BOOLE-1" 
32                     "BOOLE-2" 
33                     "BOOLE-AND" 
34                     "BOOLE-ANDC1" 
35                     "BOOLE-ANDC2" 
36                     "BOOLE-C1" 
37                     "BOOLE-C2" 
38                     "BOOLE-CLR" 
39                     "BOOLE-EQV" 
40                     "BOOLE-IOR" 
41                     "BOOLE-NAND" 
42                     "BOOLE-NOR" 
43                     "BOOLE-ORC1" 
44                     "BOOLE-ORC2" 
45                     "BOOLE-SET" 
46                     "BOOLE-XOR" 
47                     "CALL-ARGUMENTS-LIMIT" 
48                     "CHAR-CODE-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" 
70                     "LONG-FLOAT-EPSILON" 
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" 
83                     "PI" 
84                     "SHORT-FLOAT-EPSILON" 
85                     "SHORT-FLOAT-NEGATIVE-EPSILON" 
86                     "SINGLE-FLOAT-EPSILON" 
87                     "SINGLE-FLOAT-NEGATIVE-EPSILON" 
88
89                     ;; everything else which needs a separate
90                     ;; existence in xc and target
91                     "BUILT-IN-CLASS"
92                     "CLASS" "CLASS-NAME" "CLASS-OF"
93                     "COMPILE-FILE"
94                     "COMPILE-FILE-PATHNAME"
95                     "*COMPILE-FILE-PATHNAME*"
96                     "*COMPILE-FILE-TRUENAME*"
97                     "*COMPILE-PRINT*"
98                     "*COMPILE-VERBOSE*"
99                     "COMPILER-MACRO-FUNCTION"
100                     "CONSTANTP"
101                     "DEFCONSTANT"
102                     "DEFINE-MODIFY-MACRO"
103                     "DEFINE-SETF-EXPANDER"
104                     "DEFMACRO" "DEFSETF" "DEFSTRUCT" "DEFTYPE"
105                     "FBOUNDP" "FDEFINITION" "FMAKUNBOUND"
106                     "FIND-CLASS"
107                     "GET-SETF-EXPANSION"
108                     "LISP-IMPLEMENTATION-TYPE" "LISP-IMPLEMENTATION-VERSION"
109                     "MACRO-FUNCTION"
110                     "MACROEXPAND" "MACROEXPAND-1" "*MACROEXPAND-HOOK*"
111                     "MAKE-LOAD-FORM"
112                     "MAKE-LOAD-FORM-SAVING-SLOTS"
113                     "PACKAGE" "PACKAGEP"
114                     "PROCLAIM"
115                     "SPECIAL-OPERATOR-P"
116                     "STANDARD-CLASS"
117                     "STRUCTURE-CLASS"
118                     "SUBTYPEP"
119                     "TYPE-OF" "TYPEP"
120                     "WITH-COMPILATION-UNIT"))
121       (export (intern name package-name) package-name)))
122
123   ;; Build a version of Python to run in the host Common Lisp, to be
124   ;; used only in cross-compilation.
125   ;;
126   ;; Note that files which are marked :ASSEM, to cause them to be
127   ;; processed with SB!C:ASSEMBLE-FILE when we're running under the
128   ;; cross-compiler or the target lisp, are still processed here, just
129   ;; with the ordinary Lisp compiler, and this is intentional, in
130   ;; order to make the compiler aware of the definitions of assembly
131   ;; routines.
132   (do-stems-and-flags (stem flags)
133     (unless (find :not-host flags)
134       (funcall load-or-cload-stem
135                stem
136                :ignore-failure-p (find :ignore-failure-p flags))
137       #!+sb-show (warn-when-cl-snapshot-diff *cl-snapshot*)))
138
139   ;; If the cross-compilation host is SBCL itself, we can use the
140   ;; PURIFY extension to freeze everything in place, reducing the
141   ;; amount of work done on future GCs. In machines with limited
142   ;; memory, this could help, by reducing the amount of memory which
143   ;; needs to be juggled in a full GC. And it can hardly hurt, since
144   ;; (in the ordinary build procedure anyway) essentially everything
145   ;; which is reachable at this point will remain reachable for the
146   ;; entire run.
147   #+sbcl (sb-ext:purify)
148
149   (values))