Korr is written in Rust. The core language has no third-party dependencies; the database drivers, regex engine and HTTPS client are optional feature flags that are on by default.
The easiest way is to let the installer handle everything: inside a clone,
./install.sh installs or updates Rust, installs a C compiler and Git when they
are missing (after asking), builds Korr and installs it. See
Installation.
To do it by hand:
| Requirement | Why |
|---|---|
| Rust, latest stable (minimum 1.85) | The crate uses the Rust 2024 edition. Always build with the latest stable release: rustup update stable. |
| A C compiler and linker | Rust uses the system linker, and the default build compiles SQLite (C) and the TLS crypto library: build-essential (Debian/Ubuntu), gcc make (Fedora/RHEL), base-devel (Arch), build-base (Alpine), Xcode Command Line Tools (macOS), or the MSVC Build Tools (Windows). |
| Internet access on the first build | Cargo downloads the dependencies from crates.io once (cargo fetch pre-downloads them for offline builds). |
Install or update Rust with rustup:
# Linux / macOS: install (once)
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source "$HOME/.cargo/env"
# Update to the latest stable release (before building)
rustup update stable
rustc --version
# C compiler
sudo apt install build-essential # Debian / Ubuntu
xcode-select --install # macOS
On Windows, download rustup-init.exe from https://rustup.rs and accept the
prompt to install the Visual Studio C++ Build Tools; update later with
rustup update stable.
A Rust installed by your Linux distribution (apt install rustc) is often too old;
prefer rustup.
cd korr
cargo build --release
The binary is target/release/korr (target\release\korr.exe on Windows): about
8 MB with every feature, about 1.4 MB with none. Check it:
./target/release/korr version # korr 0.8.1
./target/release/korr -e 'print("ok")'
The release profile in Cargo.toml is already tuned:
[profile.release]
opt-level = 3 # maximum optimisation
lto = "fat" # whole-program link-time optimisation
codegen-units = 1 # better optimisation, slower compile
strip = true # remove symbols for a smaller binary
A debug build (cargo build) compiles faster but runs Korr programs much more
slowly; use it only while working on the interpreter itself.
| Feature | Adds | Extra build requirement |
|---|---|---|
sqlite |
db.open("sqlite:...") |
C compiler (SQLite is compiled in, nothing to install at runtime) |
postgres |
db.open("postgres://...") |
none |
mysql |
db.open("mysql://...") / mariadb:// |
none |
regex |
the re module |
none |
http-client |
http.get/post/fetch with HTTPS (rustls) |
C compiler (for the ring crypto library) |
fast-alloc |
the mimalloc memory allocator: string- and collection-heavy programs run 1.2 to 3x faster | C compiler (mimalloc is compiled in) |
All are enabled by default. Pick only what you need:
cargo build --release --no-default-features # pure Rust, zero dependencies, system allocator
cargo build --release --no-default-features --features sqlite,regex
A module whose feature is disabled explains it at runtime, e.g.
This Korr was built without SQLite support (feature 'sqlite').
cargo test --release # Rust unit tests + integration tests
./target/release/korr test tests # the Korr test suites
./install.sh --no-rust-update # build + install + editor support (inside the clone)
./target/release/korr setup # or: install the binary you just built
cargo install --path . # or: into ~/.cargo/bin
All installation options are in Installation; running and shipping programs in Getting started and Deployment.
Add the target, then build with --target:
| Target triple | Produces | Notes |
|---|---|---|
x86_64-unknown-linux-gnu |
Linux x86-64 | default on most Linux PCs |
x86_64-unknown-linux-musl |
fully static Linux binary | runs on any distro, ideal for servers/containers; needs musl-tools |
aarch64-unknown-linux-gnu |
Linux ARM64 (Raspberry Pi 4/5, Graviton) | needs gcc-aarch64-linux-gnu, or use cross |
x86_64-pc-windows-msvc |
Windows x86-64 | build on Windows |
x86_64-pc-windows-gnu |
Windows x86-64 from Linux | needs mingw-w64 |
aarch64-apple-darwin / x86_64-apple-darwin |
macOS Apple Silicon / Intel | build on macOS |
Static Linux binary (recommended for deployment):
sudo apt install musl-tools
rustup target add x86_64-unknown-linux-musl
cargo build --release --target x86_64-unknown-linux-musl
file target/x86_64-unknown-linux-musl/release/korr # "statically linked"
Windows from Linux:
sudo apt install mingw-w64
rustup target add x86_64-pc-windows-gnu
cargo build --release --target x86_64-pc-windows-gnu
# creates target/x86_64-pc-windows-gnu/release/korr.exe
Linux ARM64 from x86-64:
sudo apt install gcc-aarch64-linux-gnu
rustup target add aarch64-unknown-linux-gnu
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc \
cargo build --release --target aarch64-unknown-linux-gnu
Or skip the toolchain setup with cross
(uses Docker): cargo install cross && cross build --release --target aarch64-unknown-linux-gnu.
macOS universal binary (on a Mac):
rustup target add aarch64-apple-darwin x86_64-apple-darwin
cargo build --release --target aarch64-apple-darwin
cargo build --release --target x86_64-apple-darwin
lipo -create -output korr \
target/aarch64-apple-darwin/release/korr \
target/x86_64-apple-darwin/release/korr
korr build copies a Korr runtime and appends your program to it. By default it
uses the running korr; --runtime lets you pick a runtime built for another
platform:
korr build app.krr --runtime target/x86_64-pc-windows-gnu/release/korr.exe -o app.exe
korr build app.krr --runtime target/aarch64-unknown-linux-gnu/release/korr -o app-arm64
| Goal | How |
|---|---|
| Fastest binary for this machine only | RUSTFLAGS="-C target-cpu=native" cargo build --release |
| Smallest binary | set opt-level = "z" and add panic = "abort" in [profile.release] (slower, and a crash inside the interpreter can no longer be reported as an exit code) |
| Faster compile while developing | cargo build (debug) or cargo check |
Two workflows ship with the repository:
.github/workflows/ci.yml: on every push to
main and every pull request: cargo test, the Korr test suites and a minimal
build, on Linux, macOS and Windows..github/workflows/release.yml: on a tag
v*: builds Linux (x86_64, ARM64), macOS (Apple Silicon, Intel) and Windows
(x64), runs a smoke test, packages archives plus korr-setup-* installers,
writes SHA256SUMS.txt and publishes the GitHub release with the notes from
.github/release-notes.md.To publish a release, bump version in Cargo.toml, commit, then:
git tag v0.8.0
git push origin v0.8.0
| Problem | Fix |
|---|---|
feature edition2024 is required |
Rust is too old: rustup update stable. |
linker 'cc' not found |
Install build-essential (Linux) or Xcode CLT (macOS). |
failed to run custom build command for libsqlite3-sys or ring |
A C compiler is missing: install build-essential / Xcode CLT / MSVC Build Tools, or build without those features. |
linking with link.exe failed (Windows) |
Install “Desktop development with C++” from the Visual Studio Build Tools. |
musl build fails with musl-gcc not found |
sudo apt install musl-tools. |
error: could not find Cargo.toml |
Run commands from the repository root. |
| Programs run slowly | Make sure you built with --release. |
| Folder | Responsibility |
|---|---|
src/main.rs |
entry point |
src/cli/ |
the korr command: run, REPL, korr test, korr build, korr new |
src/syntax/ |
lexer, parser, syntax tree types |
src/compiler/ |
name resolution and checks (resolver.rs), bytecode compiler |
src/runtime/ |
virtual machine (vm.rs), values (value.rs), runtime services (interp.rs) |
src/stdlib/ |
built-in functions and modules (http, db, json, crypto, …) |
src/tools/ |
package manager (pkg.rs), korr setup (setup.rs) |
src/error.rs |
error reporting |
How these parts work together is explained in the internals documentation.
| Previous: Security model | Docs index | Next: Extending Korr with Rust |