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