Skip to main content

Prerequisites

Unix Prerequisites

Installation via package manager:
sudo apt-get install python3 python3-pip gcc-14 g++-14 ninja-build cmake \
  pkg-config uuid-dev libssl-dev libsodium-dev nodejs npm
pip3 install meson
You will also need Rust and Zig installed:
# Rust (via rustup)
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

# Zig (download from https://ziglang.org/download/)
# Or via package manager if available

macOS Prerequisites

1

Install Xcode Command Line Tools

Provides Apple Clang compiler:
xcode-select --install
2

Install tools via Homebrew

Install remaining build tools:
brew install meson ninja llvm openssl@3 libsodium node
3

Install Rust and Zig

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
brew install zig

Building Ant

If the path to your build directory contains a space, the build will likely fail.
1

Download subprojects

meson subprojects download
2

Configure the build

meson setup build
3

Compile

meson compile -C build

Alternative: Using maid

If you have maid installed, you can use the task runner:
maid setup       # downloads subprojects + configures with ccache and lld
maid build       # compiles
maid run <file>  # builds and runs a JS file
maid setup automatically configures ccache and lld for faster builds. Use maid run <file> during development to build and execute in one step.

Verifying the Build

To verify the build:
./build/ant --version
./build/ant -e "console.log('Hello from Ant ' + Ant.version)"

Installing Ant

You can install the built binary using:
maid install
This copies the binary to the directory of an existing ant installation, or falls back to ~/.ant/bin/. It also creates an antx symlink. Alternatively, copy the binary manually:
cp ./build/ant /usr/local/bin/ant

Running Tests

To run a single test:
./build/ant tests/test_async.cjs
To run the spec suite:
./build/ant examples/spec/run.js
Remember to recompile with meson compile -C build (or maid build) between test runs if you change code in the src/ directory.

Building a Debug Build

A debug build disables optimizations and LTO, and preserves debug symbols:
meson subprojects download
CC="ccache $(which clang)" \
  meson setup build --wipe --buildtype=debug \
  -Doptimization=0 -Db_lto=false -Dstrip=false -Db_lundef=false -Dunity=off
meson compile -C build
When using the debug build, core dumps will be generated in case of crashes. Use lldb or gdb with the debug binary to inspect them:
lldb ./build/ant core.ant
(lldb) bt

Building an ASan Build

ASan can help detect memory bugs.
ASan builds are significantly slower than release builds. The debug flags are not required but can produce clearer stack traces when ASan detects an issue.
meson subprojects download
CC="ccache $(which clang)" \
  meson setup build --wipe \
  -Db_sanitize=address -Doptimization=0 -Db_lto=false -Dstrip=false -Db_lundef=false
meson compile -C build
Then run tests against the ASan build:
./build/ant tests/test_gc.js

Speeding Up Frequent Rebuilds

If you plan to frequently rebuild Ant, installing ccache can greatly reduce build times. The maid setup task configures ccache automatically.
Using both ccache and lld together provides the best rebuild performance. ccache caches compilation, while lld speeds up linking (which cannot be cached).
sudo apt install ccache
export CC="ccache gcc"    # add to your .profile
Using lld as the linker also speeds up link times:
export CC_LD="$(which ld64.lld)"  # macOS with brew llvm
# or
export CC_LD="$(which lld)"       # Linux
LTO is enabled by default with 8 threads (b_lto=true, b_lto_threads=8). Disable it with -Db_lto=false for faster iteration during development.

Troubleshooting

Stale builds can sometimes result in errors. Clean the build directory and reconfigure:
rm -rf build
meson setup build
meson compile -C build
If you encounter “file not found” errors for vendored dependencies:
meson subprojects download
If the build runs out of memory, reduce parallelism:
meson compile -C build -j2

Build docs developers (and LLMs) love