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