0.9.0.26:
[sbcl.git] / make-target-2.sh
1 #!/bin/sh
2
3 # This is a script to be run as part of make.sh. The only time you'd
4 # want to run it by itself is if you're trying to cross-compile the
5 # system or if you're doing some kind of troubleshooting.
6
7 # This software is part of the SBCL system. See the README file for
8 # more information.
9 #
10 # This software is derived from the CMU CL system, which was
11 # written at Carnegie Mellon University and released into the
12 # public domain. The software is in the public domain and is
13 # provided with absolutely no warranty. See the COPYING and CREDITS
14 # files for more information.
15
16 echo //entering make-target-2.sh
17
18 LANG=C
19 export LANG
20
21 # Do warm init stuff, e.g. building and loading CLOS, and stuff which
22 # can't be done until CLOS is running.
23 #
24 # Note that it's normal for the newborn system to think rather hard at
25 # the beginning of this process (e.g. using nearly 100Mb of virtual memory
26 # and >30 seconds of CPU time on a 450MHz CPU), and unless you built the
27 # system with the :SB-SHOW feature enabled, it does it rather silently,
28 # without trying to tell you about what it's doing. So unless it hangs
29 # for much longer than that, don't worry, it's likely to be normal.
30 echo //doing warm init
31 ./src/runtime/sbcl \
32 --core output/cold-sbcl.core \
33 --sysinit /dev/null --userinit /dev/null <<-'EOF' || exit 1
34         ;; Now that we use the compiler for macros, interpreted
35         ;; /SHOW doesn't work until later in init.
36         #+sb-show (print "/hello, world!")
37         (sb!ext:purify)
38
39         ;; Until PRINT-OBJECT and other machinery is set up,
40         ;; we want limits on printing to avoid infinite output.
41         ;; (Don't forget to undo these tweaks after the printer
42         ;; is set up. It'd be cleaner to use LET to make sure 
43         ;; that happens automatically, but LET is implemented
44         ;; in terms of the compiler, and the compiler isn't 
45         ;; initialized yet.)
46         (setq *print-length* 10)
47         (setq *print-level* 5)
48         (setq *print-circle* t)
49
50         ;; Do warm init.
51         #+sb-show (print "/about to LOAD warm.lisp")
52         (load "src/cold/warm.lisp")
53
54         ;; Unintern no-longer-needed stuff before the possible PURIFY
55         ;; in SAVE-LISP-AND-DIE.
56         #-sb-fluid (sb-impl::!unintern-init-only-stuff)
57
58         ;; Now that the whole system is built, we don't need to 
59         ;; hobble the printer any more, so we can restore printer 
60         ;; control variables to their ANSI defaults.
61         (setq *print-length* nil)
62         (setq *print-level* nil)
63         (setq *print-circle* nil)
64
65         ;; FIXME: Why is it that, at least on x86 sbcl-0.6.12.46,
66         ;; GC :FULL T isn't nearly as effective as PURIFY here?
67         ;; (GC :FULL T gets us down to about 38 Mbytes, but PURIFY
68         ;; gets us down to about 19 Mbytes.)
69         (sb-int:/show "done with warm.lisp, about to GC :FULL T")
70         (gc :full t)
71
72         ;; resetting compilation policy to neutral values in
73         ;; preparation for SAVE-LISP-AND-DIE as final SBCL core (not
74         ;; in warm.lisp because SB-C::*POLICY* has file scope)
75         (sb-int:/show "setting compilation policy to neutral values")
76         (proclaim '(optimize (compilation-speed 1)
77                              (debug 1)
78                              (inhibit-warnings 1)
79                              (safety 1)
80                              (space 1)
81                              (speed 1)))
82
83         ;; Lock internal packages
84         #+sb-package-locks
85         (dolist (p (list-all-packages))
86           (unless (member p (mapcar #'find-package '(:keyword :cl-user)))
87              (lock-package p)))
88
89         (sb-int:/show "done with warm.lisp, about to SAVE-LISP-AND-DIE")
90         ;; Even if /SHOW output was wanted during build, it's probably
91         ;; not wanted by default after build is complete. (And if it's
92         ;; wanted, it can easily be turned back on.)
93         #+sb-show (setf sb-int:*/show* nil)
94         ;; The system is complete now, all standard functions are
95         ;; defined.
96         (sb-kernel::ctype-of-cache-clear)
97         (setq sb-c::*flame-on-necessarily-undefined-function* t)
98         (sb-ext:save-lisp-and-die "output/sbcl.core" :purify t)
99         EOF