compiler/arm/insts: Add support for status-register instructions.
[sbcl/nyef.git] / make-host-2.lisp
blobdf055598ccf06d1a07cbf221b02f56671630fb21
1 ;;; Set up the cross-compiler.
2 (setf *print-level* 5 *print-length* 5)
3 (load "src/cold/shared.lisp")
4 (in-package "SB-COLD")
5 ;;; FIXME: these prefixes look like non-pathnamy ways of defining a
6 ;;; relative pathname. Investigate whether they can be made relative
7 ;;; pathnames.
8 (setf *host-obj-prefix* "obj/from-host/"
9 *target-obj-prefix* "obj/from-xc/")
10 (load "src/cold/set-up-cold-packages.lisp")
11 (load "src/cold/defun-load-or-cload-xcompiler.lisp")
12 (load-or-cload-xcompiler #'host-load-stem)
14 (defun proclaim-target-optimization ()
15 (let ((debug (if (position :sb-show *shebang-features*) 2 1)))
16 (sb-xc:proclaim
17 `(optimize
18 (compilation-speed 1) (debug ,debug)
19 ;; CLISP's pretty-printer is fragile and tends to cause stack
20 ;; corruption or fail internal assertions, as of 2003-04-20; we
21 ;; therefore turn off as many notes as possible.
22 (sb!ext:inhibit-warnings #-clisp 2 #+clisp 3)
23 ;; SAFETY = SPEED (and < 3) should provide reasonable safety,
24 ;; but might skip some unreasonably expensive stuff
25 ;; (e.g. %DETECT-STACK-EXHAUSTION in sbcl-0.7.2).
26 (safety 2) (space 1) (speed 2)
27 ;; sbcl-internal optimization declarations:
29 ;; never insert stepper conditions
30 (sb!c:insert-step-conditions 0)
31 ;; save FP and PC for alien calls -- or not
32 (sb!c:alien-funcall-saves-fp-and-pc #!+x86 3 #!-x86 0)))))
33 (compile 'proclaim-target-optimization)
35 (defun in-target-cross-compilation-mode (fun)
36 "Call FUN with everything set up appropriately for cross-compiling
37 a target file."
38 (let (;; In order to increase microefficiency of the target Lisp,
39 ;; enable old CMU CL defined-function-types-never-change
40 ;; optimizations. (ANSI says users aren't supposed to
41 ;; redefine our functions anyway; and developers can
42 ;; fend for themselves.)
43 #!-sb-fluid
44 (sb!ext:*derive-function-types* t)
45 ;; Let the target know that we're the cross-compiler.
46 (*features* (cons :sb-xc *features*))
47 ;; We need to tweak the readtable..
48 (*readtable* (copy-readtable)))
49 ;; ..in order to make backquotes expand into target code
50 ;; instead of host code.
51 ;; FIXME: Isn't this now taken care of automatically by
52 ;; toplevel forms in the xcompiler backq.lisp file?
53 (set-macro-character #\` #'sb!impl::backquote-macro)
54 (set-macro-character #\, #'sb!impl::comma-macro)
56 (set-dispatch-macro-character #\# #\+ #'she-reader)
57 (set-dispatch-macro-character #\# #\- #'she-reader)
58 ;; Control optimization policy.
59 (proclaim-target-optimization)
60 ;; Specify where target machinery lives.
61 (with-additional-nickname ("SB-XC" "SB!XC")
62 (funcall fun))))
63 (compile 'in-target-cross-compilation-mode)
66 ;; Supress function/macro redefinition warnings under clisp.
67 #+clisp (setf custom:*suppress-check-redefinition* t)
69 (setf *target-compile-file* #'sb-xc:compile-file)
70 (setf *target-assemble-file* #'sb!c:assemble-file)
71 (setf *in-target-compilation-mode-fn* #'in-target-cross-compilation-mode)
73 ;;; Run the cross-compiler to produce cold fasl files.
74 ;; This suppresses ~6000 lines of "undefined function" warnings from the
75 ;; cross-compiler stemming from the calls to INSTANCE-TYPEP that occur before
76 ;; src/code/class gets compiled. It magically converts efficiently,
77 ;; but IR1 is a little bit naive about how it happens.
78 (dolist (f '(sb!kernel:layout-depthoid
79 sb!kernel:layout-inherits))
80 (setf (sb!int:info :function :kind f) :function
81 (sb!int:info :function :where-from f) :declared))
82 (load "src/cold/compile-cold-sbcl.lisp")
84 ;; After cross-compiling, show me a list of types that checkgen
85 ;; would have liked to use primitive traps for but couldn't.
86 #+nil
87 (let ((l (sb-impl::%hash-table-alist sb!c::*checkgen-used-types*)))
88 (format t "~&Types needed by checkgen: ('+' = has internal error number)~%")
89 (setq l (sort l #'> :key #'cadr))
90 (loop for (type-spec . (count . interr-p)) in l
91 do (format t "~:[ ~;+~] ~5D ~S~%" interr-p count type-spec))
92 (format t "~&Error numbers not used by checkgen:~%")
93 (loop for (spec . symbol) across sb!c::*backend-internal-errors*
94 when (and (not (stringp spec))
95 (not (gethash spec sb!c::*checkgen-used-types*)))
96 do (format t " ~S~%" spec)))
98 ;;; miscellaneous tidying up and saving results
99 (let ((filename "output/object-filenames-for-genesis.lisp-expr"))
100 (ensure-directories-exist filename :verbose t)
101 (with-open-file (s filename :direction :output :if-exists :supersede)
102 (write *target-object-file-names* :stream s :readably t)))
104 ;;; Let's check that the type system was reasonably sane. (It's easy
105 ;;; to spend a long time wandering around confused trying to debug
106 ;;; cold init if it wasn't.)
107 (when (position :sb-test *shebang-features*)
108 (load "tests/type.after-xc.lisp"))
110 ;;; If you're experimenting with the system under a cross-compilation
111 ;;; host which supports CMU-CL-style SAVE-LISP, this can be a good
112 ;;; time to run it. The resulting core isn't used in the normal build,
113 ;;; but can be handy for experimenting with the system. (See slam.sh
114 ;;; for an example.)
115 (when (position :sb-after-xc-core *shebang-features*)
116 #+cmu (ext:save-lisp "output/after-xc.core" :load-init-file nil)
117 #+sbcl (sb-ext:save-lisp-and-die "output/after-xc.core")
118 #+openmcl (ccl::save-application "output/after-xc.core")
119 #+clisp (ext:saveinitmem "output/after-xc.core"))
120 #+cmu (ext:quit)
121 #+clisp (ext:quit)
122 #+abcl (ext:quit)