Signal floating-point-overflow from bignum-to-float.
[sbcl.git] / make-host-2.lisp
blobe72aacc14b03756b5b0cea117033b5ee561ad4c1
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 ;; Supress function/macro redefinition warnings under clisp.
15 #+clisp (setf custom:*suppress-check-redefinition* t)
17 ;;; Run the cross-compiler to produce cold fasl files.
18 (setq sb!c::*track-full-called-fnames* :minimal) ; Change this as desired
19 (let (fail
20 variables
21 functions
22 types)
23 (sb!xc:with-compilation-unit ()
24 (load "src/cold/compile-cold-sbcl.lisp")
25 ;; Enforce absence of unexpected forward-references to warm loaded code.
26 ;; Looking into a hidden detail of this compiler seems fair game.
27 #!+(or x86 x86-64 arm64) ; until all the rest are clean
28 (when sb!c::*undefined-warnings*
29 (setf fail t)
30 (dolist (warning sb!c::*undefined-warnings*)
31 (case (sb!c::undefined-warning-kind warning)
32 (:variable (setf variables t))
33 (:type (setf types t))
34 (:function (setf functions t))))))
35 ;; Exit the compilation unit so that the summary is printed. Then complain.
36 (when fail
37 #!-win32 ; build is known to be unclean
38 (cerror "Proceed anyway"
39 "Undefined ~:[~;variables~] ~:[~;types~]~
40 ~:[~;functions (incomplete SB-COLD::*UNDEFINED-FUN-WHITELIST*?)~]"
41 variables types functions)))
43 (when sb!c::*track-full-called-fnames*
44 (let (possibly-suspicious likely-suspicious)
45 (sb!int:call-with-each-globaldb-name
46 (lambda (name)
47 (let* ((cell (sb!int:info :function :emitted-full-calls name))
48 (inlinep (eq (sb!int:info :function :inlinep name) :inline))
49 (info (sb!int:info :function :info name)))
50 (if (and cell
51 (or inlinep
52 (and info (sb!c::fun-info-templates info))
53 (sb!int:info :function :compiler-macro-function name)
54 (sb!int:info :function :source-transform name)))
55 (if inlinep
56 ;; A full call to an inline function almost always indicates
57 ;; an out-of-order definition. If not an inline function,
58 ;; the call could be due to an inapplicable transformation.
59 (push (cons name cell) likely-suspicious)
60 (push (cons name cell) possibly-suspicious))))))
61 (flet ((show (label list)
62 (when list
63 (format t "~%~A suspicious calls:~:{~%~4d ~S~@{~% ~S~}~}~%"
64 label
65 (mapcar (lambda (x) (list* (ash (cadr x) -2) (car x) (cddr x)))
66 (sort list #'> :key #'cadr))))))
67 ;; Called inlines not in the presence of a declaration to the contrary
68 ;; indicate that perhaps the function definition appeared too late.
69 (show "Likely" likely-suspicious)
70 ;; Failed transforms are considered not quite as suspicious
71 ;; because it could either be too late, or that the transform failed.
72 (show "Possibly" possibly-suspicious))
73 ;; As each platform's build becomes warning-free,
74 ;; it should be added to the list here to prevent regresssions.
75 #!+(and (or x86 x86-64) (or linux darwin))
76 (when likely-suspicious
77 (warn "Expected zero inlinining failures"))))
79 ;; After cross-compiling, show me a list of types that checkgen
80 ;; would have liked to use primitive traps for but couldn't.
81 #+nil
82 (let ((l (sb-impl::%hash-table-alist sb!c::*checkgen-used-types*)))
83 (format t "~&Types needed by checkgen: ('+' = has internal error number)~%")
84 (setq l (sort l #'> :key #'cadr))
85 (loop for (type-spec . (count . interr-p)) in l
86 do (format t "~:[ ~;+~] ~5D ~S~%" interr-p count type-spec))
87 (format t "~&Error numbers not used by checkgen:~%")
88 (loop for (spec symbol) across sb!c:+backend-internal-errors+
89 when (and (not (stringp spec))
90 (not (gethash spec sb!c::*checkgen-used-types*)))
91 do (format t " ~S~%" spec)))
93 ;; Print some information about how well the function caches performed
94 (when sb!impl::*profile-hash-cache*
95 (sb!impl::show-hash-cache-statistics))
97 Sample output
98 -------------
99 Seek Hit (%) Evict (%) Size full
100 23698219 18382256 ( 77.6%) 5313915 ( 22.4%) 2048 100.0% TYPE=-CACHE
101 23528751 23416735 ( 99.5%) 46242 ( 0.2%) 1024 20.1% VALUES-SPECIFIER-TYPE-CACHE
102 16755212 13072420 ( 78.0%) 3681768 ( 22.0%) 1024 100.0% CSUBTYPEP-CACHE
103 9913114 8374965 ( 84.5%) 1537893 ( 15.5%) 256 100.0% MAKE-VALUES-TYPE-CACHED-CACHE
104 7718160 4702069 ( 60.9%) 3675019 ( 47.6%) 512 100.0% TYPE-INTERSECTION2-CACHE
105 5184706 1626512 ( 31.4%) 3557973 ( 68.6%) 256 86.3% %TYPE-INTERSECTION-CACHE
106 5156044 3986450 ( 77.3%) 1169338 ( 22.7%) 256 100.0% VALUES-SUBTYPEP-CACHE
107 4550163 2969409 ( 65.3%) 1580498 ( 34.7%) 256 100.0% VALUES-TYPE-INTERSECTION-CACHE
108 3544211 2607658 ( 73.6%) 936300 ( 26.4%) 256 98.8% %TYPE-UNION-CACHE
109 2545070 2110741 ( 82.9%) 433817 ( 17.0%) 512 100.0% PRIMITIVE-TYPE-AUX-CACHE
110 2164841 1112785 ( 51.4%) 1706097 ( 78.8%) 256 100.0% TYPE-UNION2-CACHE
111 1568022 1467575 ( 93.6%) 100191 ( 6.4%) 256 100.0% TYPE-SINGLETON-P-CACHE
112 779941 703208 ( 90.2%) 76477 ( 9.8%) 256 100.0% %COERCE-TO-VALUES-CACHE
113 618605 448427 ( 72.5%) 169922 ( 27.5%) 256 100.0% VALUES-TYPE-UNION-CACHE
114 145805 29403 ( 20.2%) 116206 ( 79.7%) 256 76.6% %%MAKE-UNION-TYPE-CACHED-CACHE
115 118634 76203 ( 64.2%) 42188 ( 35.6%) 256 94.9% %%MAKE-ARRAY-TYPE-CACHED-CACHE
116 12319 12167 ( 98.8%) 47 ( 0.4%) 128 82.0% WEAKEN-TYPE-CACHE
117 10416 9492 ( 91.1%) 668 ( 6.4%) 256 100.0% TYPE-NEGATION-CACHE
120 ;;; miscellaneous tidying up and saving results
121 (let ((filename "output/object-filenames-for-genesis.lisp-expr"))
122 (ensure-directories-exist filename :verbose t)
123 (with-open-file (s filename :direction :output :if-exists :supersede)
124 (write *target-object-file-names* :stream s :readably t)))
126 ;;; Let's check that the type system was reasonably sane. (It's easy
127 ;;; to spend a long time wandering around confused trying to debug
128 ;;; cold init if it wasn't.)
129 (load "tests/type.after-xc.lisp")
131 ;;; If you're experimenting with the system under a cross-compilation
132 ;;; host which supports CMU-CL-style SAVE-LISP, this can be a good
133 ;;; time to run it. The resulting core isn't used in the normal build,
134 ;;; but can be handy for experimenting with the system. (See slam.sh
135 ;;; for an example.)
136 (when (position :sb-after-xc-core *shebang-features*)
137 #+cmu (ext:save-lisp "output/after-xc.core" :load-init-file nil)
138 #+sbcl (sb-ext:save-lisp-and-die "output/after-xc.core")
139 #+openmcl (ccl::save-application "output/after-xc.core")
140 #+clisp (ext:saveinitmem "output/after-xc.core"))