Skip to content

Building from Source

Build Zeus from source if you want to contribute, work on unreleased features, or debug the compiler and runtime. For everyday use, install via Homebrew instead.

Prerequisites

ToolVersionInstallUsed for
Xcode Command Line Toolslatestxcode-select --installC compiler & linker
Go1.25+brew install gothe compiler (zeus.go)
LLVM19brew install llvm@19native code generation (via CGO)
Zig0.13.xbrew install zigthe runtime (zig build-lib)
CMake3.xbrew install cmakebuilding the bundled Boehm GC

Configure LLVM for CGO

The Go LLVM bindings need to find LLVM 19. Add this to your ~/.zshrc (or ~/.bashrc):

Terminal window
# LLVM 19 for Zeus
export LLVM_PATH="$(brew --prefix llvm@19)"
export PATH="$LLVM_PATH/bin:$PATH"
export CGO_CFLAGS="-I$LLVM_PATH/include"
export CGO_LDFLAGS="-L$LLVM_PATH/lib -Wl,-rpath,$LLVM_PATH/lib"

Reload and verify:

Terminal window
source ~/.zshrc
llvm-config --version # 19.x.x

Building

  1. Clone the repository

    Terminal window
    git clone https://github.com/ameerthehacker/zeus.git
    cd zeus
  2. Build the compiler

    Terminal window
    make build

    This produces a zeus binary in the project root. Verify it:

    Terminal window
    ./zeus --help
  3. Compile and run a program

    The make run target orchestrates the full toolchain — it builds the Boehm GC with CMake, the Zig runtime, then compiles and runs a file from playground/:

    Terminal window
    echo 'function main(): i32 { return 42; }' > playground/test.zs
    make run file=test
    echo $? # 42

Development workflow

Running tests

Terminal window
make test # runtime + Go unit tests + runtime tests
make test-go # Go unit tests only
make test-e2e # end-to-end tests (compiles real programs)

Compiling playground files

Terminal window
make compile file=test # compile only, no run
make run file=test # compile and run
make zeus-fmt file=test # format playground/test.zs in place

Build flags

Append these to make compile / make run:

FlagEffect
debug=trueEmit Zeus IR and LLVM IR, enable GC debug output
nogc=trueDisable garbage collection
release=trueBuild the optimized (ReleaseSmall) runtime
Terminal window
make run file=test debug=true

Project structure

zeus/
├── zeus.go # CLI entry point
├── Makefile # Build & test targets
├── CMakeLists.txt # Builds the bundled Boehm GC (bdwgc)
├── cmd/ # Cobra CLI commands (build, run, check, lsp, ...)
├── internal/ # Compiler implementation
│ ├── token/ lexer/ ast/ parser/
│ ├── ir/ # HIR/LIR, type checking, lowering
│ ├── codegen/ # LLVM IR generation
│ ├── zeus_value/ # Zeus type system
│ ├── module/ symbol_table/
│ ├── prelude/ # Self-hosted primordials (Console, ...)
│ ├── zeus_compiler/ # Pass orchestration
│ └── lsp/ # Language Server Protocol
├── runtime/ # Zig runtime (GC glue, arrays, timers via libxev)
├── lib/std/ # Standard library modules
├── playground/ # Scratch .zs files for make compile/run
├── test/ # Go + end-to-end test suites
├── zeus-vscode/ # VS Code extension
└── docs/ # This documentation site

Troubleshooting

llvm-config: command not found or CGO link errors — LLVM 19 isn’t on your PATH. Confirm brew --prefix llvm@19 resolves, re-export the variables above, and check go env CGO_ENABLED returns 1.

Runtime build fails — make sure you’re on Zig 0.13.x (zig version); newer Zig releases are incompatible with the pinned libxev.

GC link errors (-lgc) — the Boehm GC is built by CMake on first make run/make compile. Ensure CMake is installed and you have network access (it’s fetched via CMake FetchContent).

Tests failing — build the runtime first with make build-runtime, then make test.

Contributing

  1. Fork the repository and create a feature branch.
  2. Make your change and format Go code with make fmt.
  3. Run make test (and make test-e2e for language changes).
  4. Open a pull request.

Makefile reference

CommandDescription
make buildBuild the zeus compiler binary
make build-runtimeBuild the Zig runtime
make run file=<name>Compile and run playground/<name>.zs
make compile file=<name>Compile playground/<name>.zs without running
make check file=<name>Type-check and emit IR
make testRun the full test suite
make test-e2eRun end-to-end tests
make lspBuild and start the language server
make fmtFormat Go source
make cleanRemove build artifacts