Install¶
Requirements¶
- macOS on Apple Silicon (AArch64)
- Xcode Command Line Tools (
xcode-select --install) — providesasandclang, which compiles the C runtime and links every program
From source¶
Building the self-hosted compiler¶
The Makefile bootstraps everything from scratch:
make bootstrap # clean rebuild of stage0 + stage1 (sh_kodc)
make stage1 # incremental rebuild
make test # rebuild, then run the full test suite
Running¶
kod is the native tool build/apps/kod/kod. Build it once with make kod, then start it through ./kod, a link to it at the repository root (until it is built, ./kod fails with the shell's no such file or directory):
make kod
./kod build hello.kod # compile to a native binary
./kod run hello.kod # build + execute
./kod test hello.kod # run any `test "..." {}` blocks
./kod check hello.kod # parse + codegen; report errors but emit nothing
Started through ./kod, it runs make stage1 kod first when something is out of date, so edits to the compiler, the C runtime, the always-linked stdlib modules or the tool itself are picked up automatically (see CLI reference). Run kod from the repository root.
Linking¶
link.cfg at the repository root says how programs are linked: the clang command and the C files and Kod modules every program contains. Nothing in it is specific to one machine, so most machines never touch it. One that needs something else (a Homebrew LLVM clang first on PATH that does not find the SDK, an unusual SDK) puts the names it changes in link.local.cfg next to it (only names link.cfg sets), for example:
link.local.cfg is not tracked by git, so each new git worktree needs its own copy (cp ../link.local.cfg .). See Self-hosting for the format.
See CLI reference for the full command surface.