Debug builds are the default during development. For deployment, use release mode to produce fast, small binaries.
| Profile | Compiler flags | Behavior |
|---|---|---|
| Debug (default) | -O0 -g |
Full debug symbols, bounds checks enabled |
| Release | -O3 -flto -DNDEBUG |
Maximum optimization, checks elided |
mako build --release main.mko -o server
The binary is optimized with link-time optimization (LTO) across all compilation units.
Remove debug symbols for smaller binaries:
MAKO_STRIP=1 mako build --release main.mko -o server
Speed up builds by compiling object files in parallel:
mako build --release -j 8 main.mko -o server
Or set it globally:
export MAKO_JOBS=8
mako build --release main.mko -o server
See where time is spent:
mako build --release --time main.mko -o server
Mako caches compiled object files under .mako/cache/. Unchanged packages
reuse their cached .o files. This is on by default.
To force a clean build:
mako build --release --no-incremental main.mko -o server
On supported targets, produce a fully static binary with no runtime dependencies:
mako build --release --static-link main.mko -o server
This is the default for Linux musl targets. On other platforms, use
--static-link explicitly when supported.
To force dynamic linking:
mako build --release --no-static-link main.mko -o server
Build for a different target triple:
# Linux (static musl)
mako build --release --target x86_64-unknown-linux-musl main.mko -o server
# WebAssembly
mako build --target wasm32-wasi main.mko -o app.wasm
The target triple follows the pattern: arch-vendor-os-env.
Generate a multi-stage Dockerfile for containerized deployment:
mako deploy docker . --entry main.mko --bin server --port 8080
This creates:
Dockerfile -- multi-stage build (compile in builder, copy to scratch).dockerignore -- excludes build artifactsDefault mode builds a static x86_64-unknown-linux-musl binary and copies it
into a scratch container (minimal image size).
For applications that need CA certificates or shell access:
mako deploy docker . --entry main.mko --bin server --port 8080 --mode debian
This uses debian:bookworm-slim as the runtime image.
Generate provider-specific deployment manifests:
# Google Cloud Run
mako deploy serverless . --provider cloud-run --name my-api
# Fly.io
mako deploy serverless . --provider fly --name my-api
These build on the Docker scaffold and add the appropriate service configuration files.
For the fastest runtime performance:
let mut s = make([]int, 0, 1000) // avoid repeated growth
let mut m = make(map[string]int, 64) // hint expected size
arena req {
let mut buf = make([]byte, 0, 4096)
// all allocations freed at block end
}
Prefer hold over share (zero overhead vs reference counting)
Measure with now_ns:
let t0 = now_ns()
do_work()
let elapsed = now_ns() - t0
print_int(elapsed)
Run benchmarks to measure performance:
mako bench .
mako bench . -p app --json # JSON output for CI
./scripts/bench.sh # comparative benchmarks
Use black_box(x) to prevent the optimizer from eliminating benchmark work:
fn main() {
let t0 = now_ns()
let mut sum = 0
for i in range 1000000 {
sum = sum + black_box(i)
}
let _ = black_box(sum)
let elapsed = now_ns() - t0
print_int(elapsed)
}
# Development (fast compile, debug symbols)
mako build main.mko -o app
# Release (optimized, no debug)
mako build --release main.mko -o app
# Release stripped (smallest binary)
MAKO_STRIP=1 mako build --release main.mko -o app
# Release with sanitizer (find bugs in optimized code)
mako build --release --sanitize=address main.mko -o app
# Static release for deployment
mako build --release --static-link --target x86_64-unknown-linux-musl main.mko -o app
Inspect the generated C code (useful for debugging codegen):
mako build --emit-c main.mko
# Writes the intermediate .c file alongside the output