Be careful with zeros when propagating the results of *.
[sbcl.git] / make.sh
blob0a912b88f53255b63d7a054b492bff26bb343c9a
1 #!/bin/sh
2 set -e
4 LANG=C
5 LC_ALL=C
6 export LANG LC_ALL
8 # "When we build software, it's a good idea to have a reliable method
9 # for getting an executable from it. We want any two reconstructions
10 # starting from the same source to end up in the same result. That's
11 # just a basic intellectual premise."
12 # -- Christian Queinnec, in _Lisp In Small Pieces_, p. 313
14 # This software is part of the SBCL system. See the README file for
15 # more information.
17 # This software is derived from the CMU CL system, which was
18 # written at Carnegie Mellon University and released into the
19 # public domain. The software is in the public domain and is
20 # provided with absolutely no warranty. See the COPYING and CREDITS
21 # files for more information.
23 # If you're cross-compiling, make-config.sh should "do the right
24 # thing" when run on the target machine, with the minor caveat that
25 # any --xc-host parameter should be suitable for the host machine
26 # instead of the target.
27 sh make-config.sh "$@" --check-host-lisp || exit $?
29 . output/prefix.def
30 . output/build-config
32 echo //building host tools
33 # Build the perfect-hash-generator. It's actually OK if this fails,
34 # as long as xperfecthash.lisp-expr is up-to-date
35 $GNUMAKE -C tools-for-build perfecthash || true
37 build_started=`date`
38 echo "//Starting build: $build_started"
39 # Apparently option parsing succeeded. Print out the results.
40 echo "//Options: --prefix='$SBCL_PREFIX' --xc-host='$SBCL_XC_HOST'"
42 # Enforce the source policy for no bogus whitespace
43 $SBCL_XC_HOST < tools-for-build/canonicalize-whitespace.lisp || exit 1
45 # The make-host-*.sh scripts are run on the cross-compilation host,
46 # and the make-target-*.sh scripts are run on the target machine. In
47 # ordinary compilation, we just do these phases consecutively on the
48 # same machine, but if you wanted to cross-compile from one machine
49 # which supports Common Lisp to another which does not (yet:-) support
50 # Common Lisp, you could do something like this:
51 # Create copies of the source tree on both the host and the target.
52 # Read the make-config.sh script carefully and emulate it by hand
53 # on both machines (e.g. creating "target"-named symlinks to
54 # identify the target architecture).
55 # On the host system:
56 # SBCL_XC_HOST=<whatever> sh make-host-1.sh
57 # Copy src/runtime/genesis/*.h from the host system to the target
58 # system.
59 # On the target system:
60 # sh make-target-1.sh
61 # Copy output/stuff-groveled-from-headers.lisp
62 # from the target system to the host system.
63 # On the host system:
64 # SBCL_XC_HOST=<whatever> sh make-host-2.sh
65 # Copy output/cold-sbcl.core from the host system to the target system.
66 # On the target system:
67 # sh make-target-2.sh
68 # sh make-target-contrib.sh
69 # Or, if you can set up the files somewhere shared (with NFS, AFS, or
70 # whatever) between the host machine and the target machine, the basic
71 # procedure above should still work, but you can skip the "copy" steps.
72 # If you can use rsync on the host machine, you can call make-config.sh
73 # with:
74 # --host-location=user@host-machine:<rsync path to host sbcl directory>
75 # and the make-target-*.sh scripts will take care of transferring the
76 # necessary files.
77 maybetime() {
78 if command -v time > /dev/null ; then
79 time $@
80 else
84 maybetime sh make-host-1.sh
85 maybetime sh make-target-1.sh
86 maybetime sh make-host-2.sh
87 maybetime sh make-target-2.sh
88 maybetime sh make-target-contrib.sh
90 # Confirm that default evaluation strategy is :INTERPRET if sb-fasteval was built
91 src/runtime/sbcl --core output/sbcl.core --lose-on-corruption --noinform \
92 --no-sysinit --no-userinit --disable-debugger \
93 --eval '(when (find-package "SB-INTERPRETER") (assert (eq *evaluator-mode* :interpret)))' \
94 --quit
96 ./src/runtime/sbcl --core output/sbcl.core \
97 --lose-on-corruption --noinform $SBCL_MAKE_TARGET_2_OPTIONS --no-sysinit --no-userinit --eval '
98 (progn
99 #-sb-devel
100 (restart-case
101 (let (l1 l2)
102 (sb-vm:map-allocated-objects
103 (lambda (obj type size)
104 (declare (ignore size))
105 (when (and (= type sb-vm:symbol-widetag) (not (symbol-package obj))
106 (search "!" (string obj)))
107 (push obj l1))
108 (when (and (= type sb-vm:fdefn-widetag)
109 (not (symbol-package
110 (sb-int:fun-name-block-name
111 (sb-kernel:fdefn-name obj)))))
112 (push obj l2)))
113 :all)
114 (when l1 (format t "Found ~D:~%~S~%" (length l1) l1))
115 ;; Assert that a chosen few symbols not named using the ! convention are removed
116 ;; by tree-shaking. This list was made by hand-checking various macros that seemed
117 ;; not to be needed after the build. I would have thought
118 ;; (EVAL-WHEN (:COMPILE-TOPLEVEL)) to be preferable, but revision fb1ba6de5e makes
119 ;; a case for not doing that. Either way is less than fabulous.
120 (sb-int:awhen
121 (mapcan (quote apropos-list)
122 (quote ("DEFINE-INFO-TYPE" "LVAR-TYPE-USING"
123 "TWO-ARG-+/-"
124 "PPRINT-TAGBODY-GUTS" "WITH-DESCRIPTOR-HANDLERS"
125 "SUBTRACT-BIGNUM-LOOP" "BIGNUM-REPLACE" "WITH-BIGNUM-BUFFERS"
126 "GCD-ASSERT" "BIGNUM-NEGATE-LOOP"
127 "SHIFT-RIGHT-UNALIGNED"
128 "STRING-LESS-GREATER-EQUAL-TESTS")))
129 (format t "~&Leftover from [disabled?] tree-shaker:~%~S~%" sb-int:it))
130 (when l2
131 (format t "Found ~D fdefns named by uninterned symbols:~%~S~%" (length l2) l2)))
132 (abort-build ()
133 :report "Abort building SBCL."
134 (sb-ext:exit :code 1))))' --quit
136 # contrib/Makefile shouldn't be counted in NCONTRIBS nor should asdf and uiop.
137 # The asdf directory produces 2 fasls, so is unlike all our other contribs
138 # and would therefore mess up the accounting here if included.
139 NCONTRIBS=`ls -1 contrib/sb-*/Makefile | wc -l`
140 NPASSED=`ls obj/sbcl-home/contrib/sb-*.fasl | wc -l`
141 echo
142 echo "The build seems to have finished successfully, including $NPASSED (out of $NCONTRIBS)"
143 echo "contributed modules. If you would like to run more extensive tests on"
144 echo "the new SBCL, you can try:"
145 echo
146 echo " cd ./tests && sh ./run-tests.sh"
147 echo
148 echo "To build documentation:"
149 echo
150 echo " cd ./doc/manual && make"
151 echo
152 echo "To install SBCL (more information in INSTALL):"
153 echo
154 echo " sh install.sh"
156 build_finished=`date`
157 echo
158 echo "//build started: $build_started"
159 echo "//build finished: $build_finished"