Build the toolchain from source
A checkout builds torb with one script - it takes a seed, the torb of an earlier commit, builds the compiler with it, builds it again with the result, and compares the two.
Diese Seite gibt es noch nicht auf Deutsch, deshalb steht sie hier auf Englisch. Zur englischen Seite
Somebody who only writes TorbScript installs it with the installer and never builds it. This page
is for working on the toolchain itself. The compiler is written in TorbScript and compiles itself, so building it takes
a torb that already exists: the seed.
Steps#
Have a C compiler, and
curlorwget. The compiler is$TORB_CC, or the first ofclang,gccandccon thePATH. On Windows the scripts run in Git Bash.Clone the repository from git.torb.dev.
Run the bootstrap from the root of the checkout:
$ sh tools/bootstrap.shIt takes the first seed it finds:
$TORB_SEED, thenseed/, then the newest archive in../torbscript-seeds/, thenbuild/seed/. A fresh clone has none of them, so the script runssh tools/fetch-seed.sh, which downloads the newest published seed, checks its SHA-256 and compiles it intobuild/seed/torb.TORB_SEED_FETCH=0forbids the download.Use
build/release/torb. That is the compiler that comes out. It finds thestd/andruntime/of its checkout by itself.Run the gates before a commit:
sh tools/gates.sh aon every change, andsh tools/gates.sh bas well when the change touches the IR, a back end orruntime/(compiler/CONTRIBUTING.md).
The build takes two steps, not one. The seed builds the current sources; the binary that comes out builds them again;
and the two generated C programs have to be identical. That comparison is the fixpoint: it proves that the compiler
builds itself the same way the seed built it. Only then does build/release/ get the new binary.
Full example#
A fresh clone on a machine with no seed:
$ git clone https://git.torb.dev/torbscript/language.git torbscript
$ cd torbscript
$ sh tools/bootstrap.sh
no seed on this machine: fetching the newest published seed (sh tools/fetch-seed.sh)
seed: build/seed/torb
step 1: the seed builds the compiler
step 2: that compiler builds the compiler again
the fixpoint holds: both steps emitted the same C.
torb: build/release/torb
$ build/release/torb check examples/tour
14 files, no problemsA checkout that already has a torb elsewhere on the machine names it instead of downloading one:
$ TORB_SEED=/path/to/torb sh tools/bootstrap.shRelated#
- Install TorbScript - the installer, for everybody who does not work on the toolchain.
- Cut a release - how seeds and releases are published.
- README.md - the layout of the repository and the two kinds of seed.