Skip to main content

Prerequisites

To build Walrus from source, you’ll need:
  • Rust (latest stable version)
  • Git

Clone the repository

git clone https://github.com/sb2bg/walrus.git
cd walrus

Basic build

1

Build in debug mode

For development and debugging:
cargo build
The binary will be located at target/debug/walrus.
2

Run directly with Cargo

You can also build and run in one command:
# Execute a file
cargo run -- file.walrus

# Start REPL
cargo run

Release builds

For optimal performance, build with release optimizations:
cargo build --release
The optimized binary will be at target/release/walrus.

Release profile configuration

Walrus includes debug symbols even in release builds for better profiling:
[profile.release]
debug = true

Build features

JIT compilation support

Walrus includes an optional Just-In-Time (JIT) compiler powered by Cranelift that can dramatically speed up hot loops:
# Build with JIT feature enabled
cargo build --release --features jit
The JIT feature includes the following dependencies:
  • cranelift-codegen
  • cranelift-frontend
  • cranelift-jit
  • cranelift-module
  • cranelift-native
  • target-lexicon

JIT profiling

Enable JIT profiling output for performance analysis:
cargo build --release --features "jit,jit-profiling"

Memory profiling

Build with heap profiling support using dhat:
cargo build --release --features dhat-heap

Binaries

The Walrus workspace produces two binaries:

Main interpreter

cargo build --release
./target/release/walrus
Supports multiple execution modes:
  • Tree-walking interpreter (default)
  • Bytecode VM with -c flag
  • Disassembler with -d flag
  • JIT compilation with --jit flag (if built with jit feature)

Language server

cargo build --release --bin walrus-lsp
./target/release/walrus-lsp
Used by the VS Code extension for LSP features.

Custom allocator

Walrus uses mimalloc as a custom allocator for improved allocation performance. This is automatically included in all builds.

Build dependencies

Key dependencies compiled during the build:
  • LALRPOP - Parser generator (build-time)
  • SlotMap - Arena-based memory management
  • rustc-hash - Fast hashing (FxHashMap/FxHashSet)
  • strena - String interning
  • tower-lsp - LSP server implementation
  • tokio - Async runtime for LSP
See Cargo.toml for the complete dependency list.

Build troubleshooting

Parser generation

If you modify the grammar files, LALRPOP will automatically regenerate the parser during build. This happens via the build script.

Rust edition

Walrus uses Rust edition 2024:
[package]
edition = "2024"
Ensure you have a compatible Rust version installed.

Clean rebuild

If you encounter build issues, try a clean rebuild:
cargo clean
cargo build --release

Build docs developers (and LLMs) love