0f8c8e63ebfec544c09776dafe8b368900e488fb
[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 '("ARRAY-RANK-LIMIT"
26                     "ARRAY-DIMENSION-LIMIT"
27                     "ARRAY-TOTAL-SIZE-LIMIT"
28                     "BUILT-IN-CLASS"
29                     "CLASS" "CLASS-NAME" "CLASS-OF"
30                     "COMPILE-FILE"
31                     "COMPILE-FILE-PATHNAME"
32                     "*COMPILE-FILE-PATHNAME*"
33                     "*COMPILE-FILE-TRUENAME*"
34                     "*COMPILE-PRINT*"
35                     "*COMPILE-VERBOSE*"
36                     "COMPILER-MACRO-FUNCTION"
37                     "CONSTANTP"
38                     "DEFCONSTANT"
39                     "DEFINE-MODIFY-MACRO"
40                     "DEFINE-SETF-EXPANDER"
41                     "DEFMACRO" "DEFSETF" "DEFSTRUCT" "DEFTYPE"
42                     "FBOUNDP" "FDEFINITION" "FMAKUNBOUND"
43                     "FIND-CLASS"
44                     "GET-SETF-EXPANSION"
45                     "LAMBDA-LIST-KEYWORDS"
46                     "LISP-IMPLEMENTATION-TYPE" "LISP-IMPLEMENTATION-VERSION"
47                     "MACRO-FUNCTION"
48                     "MACROEXPAND" "MACROEXPAND-1" "*MACROEXPAND-HOOK*"
49                     "MAKE-LOAD-FORM"
50                     "PACKAGE" "PACKAGEP"
51                     "PROCLAIM"
52                     "SPECIAL-OPERATOR-P"
53                     "STANDARD-CLASS"
54                     "STRUCTURE-CLASS"
55                     "SUBTYPEP"
56                     "TYPE-OF" "TYPEP"
57                     "WITH-COMPILATION-UNIT"))
58       (export (intern name package-name) package-name)))
59
60   ;; Build a version of Python to run in the host Common Lisp, to be
61   ;; used only in cross-compilation.
62   ;;
63   ;; Note that files which are marked :ASSEM, to cause them to be
64   ;; processed with SB!C:ASSEMBLE-FILE when we're running under the
65   ;; cross-compiler or the target lisp, are still processed here, just
66   ;; with the ordinary Lisp compiler, and this is intentional, in
67   ;; order to make the compiler aware of the definitions of assembly
68   ;; routines.
69   (for-stems-and-flags (stem flags)
70     (unless (find :not-host flags)
71       (funcall load-or-cload-stem
72                stem
73                :ignore-failure-p (find :ignore-failure-p flags))
74       #!+sb-show (warn-when-cl-snapshot-diff *cl-snapshot*)))
75
76   ;; If the cross-compilation host is SBCL itself, we can use the
77   ;; PURIFY extension to freeze everything in place, reducing the
78   ;; amount of work done on future GCs. In machines with limited
79   ;; memory, this could help, by reducing the amount of memory which
80   ;; needs to be juggled in a full GC. And it can hardly hurt, since
81   ;; (in the ordinary build procedure anyway) essentially everything
82   ;; which is reachable at this point will remain reachable for the
83   ;; entire run.
84   #+sbcl (sb-ext:purify)
85
86   (values))