Building the compiler
Beans is self-hosted: the compiler is written in Beans. To build it from source
you need an existing beansc to compile it with. The build is driven by the
project Makefile, and compiler/version.h is the single version source.
What you need
Section titled “What you need”- clang
- lld
- make
- git
On Debian or Ubuntu:
sudo apt-get install clang lld make gitOn macOS, native builds also need the command-line tools:
xcode-select --installBuilding on a public checkout
Section titled “Building on a public checkout”A public checkout has no private bootstrap, so make builds build/beansc
using an already-installed beansc: the one on your PATH, or at
$BEANS_HOME/bin/beansc. Under the hood it runs:
beansc build compiler/beans/main.b -o build/beansc.newThe full loop:
# 1. install a release compiler first (the one-line installer)# 2. get the sourcegit clone https://github.com/beans-lang/beans.gitcd beans# 3. buildmake# 4. check it./build/beansc --version./build/beansc run examples/hello.bChoose which compiler bootstraps the build with BEANSC_BOOT:
make BEANSC_BOOT=/path/to/beanscSee Install Beans for the one-line installer.
The C++ bootstrap
Section titled “The C++ bootstrap”With the private C++ bootstrap submodule present, make runs the full
stage0 -> stage1 -> stage2 -> stage3 chain:
beansc0is the C++ stage-0 compiler.- Stages 2 and 3 must be byte-identical. That fixed point proves the self-hosted compiler reproduces itself.
make test adds the differential gates on top (see Running the
tests).
beansc0 is never installed, never packaged, and never on your PATH. It only
exists to bootstrap the build.
Installing
Section titled “Installing”sudo make install PREFIX=/usr/localThis installs beansc (never beansc0), the runtime sources, and the standard
library.
See Running the tests and Contributing for the change workflow.