[ Home ]
SBCL Internals

The pages on this CLiki-driven site can be edited by anybody at any time. No warranty of any kind can therefore be made; any implied warranties of merchantability or fitness for a particular purpose are expressly disclaimed
[ Home ] [ Recent Changes ] [ About CLiki ] [ Text Formatting ]

The Build system in SBCL is significantly different to the one that CMUCL uses. From the web site, "the big advantage is that an SBCL system is built directly from scratch, as an ordinary software system is. As consequences, anyone can build the system, executable code corresponds to the source code in a controlled, verifiable way, and arbitrary changes can be made to the system without causing bootstrapping problems."

$ sh make.sh "/usr/bin/sbcl --core /usr/lib/sbcl.core"

is the summary of how it usually works. When compiling on a host compiler that is not SBCL, there may be Cross-compilation Problems; if you come across these, please report them as bugs.

hair

There is hair in the build process, but you can go for a long time without understanding it. Cross-compiling macros is one such area

Things that happen during the build

From an IRC conversation had with Christophe and "kkhawi" on #lisp:

There are a few phases of compilation. These are:

  1. make-config.sh
  2. make-host-1.sh
  3. make-target-1.sh
  4. make-host-2.sh
  5. make-target-2.sh

So, what is happening in these phases?

The compiler that has been built as an application in the first lisp pass ("make-host-1") is then used (running as an application inside the host lisp) to compile its own sources to SBCL-style fasls ("make-host-2"). Genesis is another application that runs inside the host lisp, which reads sbcl-style fasls, and builds an sbcl-style core out of them. So far, no bootstrapping, only regular lisp applications.

The bootstrapping bit comes next. The initial function of the core written out by genesis is something that sets up compiler-internal datastructures so that it becomes a real compiler. (at the start, the core has no packages, for instance; just about the first thing the initial-function does is set up RANDOM, so that hash-tables work, so that you can create packages, so that you can ...) so that startup ("cold-init") is probably the only bootstrapping bit, and even then we never rely on anything we haven't already created.

the first thing warm-init make-target-2 does is

src/runtime/sbcl --core output/cold-sbcl.core
cold-sbcl.core is the core produced by genesis; src/runtime/sbcl is the C runtime. the initial function of cold-sbcl.core does the fixups described before (note: the fixups done by genesis are those denoted by the specific meaning: "resolving addresses of C functions", loosely; the "fixups" referred to as part of cold-init are basically "installing functionality that we need"), and then is inside "warm" init. make-target-2.sh then builds stuff like PCL and other things not used in the previous build process.

sbcl's boot process does this so that it's not like bootstrapping "other" lisps, where you might rely on some old bits of your host compiler, which then "leak" into the compiled image.

Short cuts

It takes a long time to build. If you're just trying to test a change you made to library or compiler code, you may want to try slam.sh, which attempts to rebuild changed files using the crosscompiler, then runs genesis and make-target-2 as normal. If you really really like to take shortcuts, look at src/cold/chill.lisp?, which can be loaded into a running target SBCL and sets up SB!FOO as aliases for SB-FOO - then you can load parts of SBCL into it without the reader complaining

Cross-Compiling

Cross-compiling SBCL is easy; especially so if you arrange matters (e.g. using NFS) so that host and target systems can see the same build directory. make.sh doesn't cater for it directly, so you run each of the five scripts by hand. For example, cross-compiling to PPC is something like

host$ export SBCL_ARCH=ppc
host$ export SBCL_XC_HOST=sbcl
ppc$ . ./find-gnumake.sh
ppc$ find_gnumake
ppc$ sh make-config?.sh
host$ sh make-host-1?.sh
ppc$ sh make-target-1?.sh
host$ sh make-host-2?.sh
ppc$ sh make-target-2.sh
ppc$ sh make-target-contrib?.sh

If you can't arrange things to be quite so nice with NFS or some other similar filesystem, things are still relatively easy; as at 1.0, the procedure is as follows (variables given different values for variety):

target$ GNUMAKE=make sh ./make-config.sh
host$ GNUMAKE=gmake SBCL_ARCH='arch' sh ./make-config.sh
host$ scp target:sbcl-directory/local-target-features.lisp-expr .
host$ scp target:sbcl-directory/output/build-id.tmp output/
host$ SBCL_XC_HOST='lisp -batch' sh ./make-host-1.sh
host$ scp -r src/runtime/genesis src/runtime/ldso-stubs.S target:sbcl-directory/src/runtime/
target$ GNUMAKE=make sh ./make-target-1.sh
target$ scp src/runtime/sbcl.nm host:sbcl-directory/src/runtime/
target$ scp output/stuff-groveled-from-headers.lisp host:sbcl-directory/output/
host$ SBCL_XC_HOST='lisp -batch' sh ./make-host-2.sh
host$ scp output/cold-sbcl.core target:sbcl-directory/output/
target$ sh ./make-target-2.sh
target$ sh ./make-target-contrib.sh

Building on Windows

See Build on Windows


Pages in this topic: Cross-compilation Problems   genesis   PCL  


Also linked from: Basics   index  

CLiki pages can be edited by anyone at any time. Imagine a fearsomely comprehensive disclaimer of liability. Now fear, comprehensively