Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

The compiler

Actions

vxc runs one action per invocation. The default is run-jit.

FlagWhat it does
--runCompile and execute immediately, propagating the program’s exit code
-cCompile to an object file
--emit-mlirEmit the MLIR representation
--emit-llvmEmit LLVM IR
--print-astParse and typecheck, then print the AST
--parse-onlyLex and parse only
--emit-interfaceSerialize this module’s import interface to a .vxlib
vxc --run program.vx
vxc -c program.vx -o program.o
vxc --emit-mlir program.vx

Optimization is -O0 through -O3, defaulting to -O0.

Hardware and machine models

FlagWhat it does
--machine <FILE>Compile against a declared machine — see machine files
--host <FILE|default>Declare the host the program runs on
--diagnostics-json [PATH]Write the admission verdict as one structured JSON record
--verify-seamsDischarge asynchronous-visibility obligations with z3

--diagnostics-json is the one to reach for in a build script or a CI job. The schema is versioned, and a capacity rejection carries the space, the requirement, the availability and the margin as fields rather than as prose you would have to parse out of a message.

Note that with --verify-seams and no solver on PATH, the compile fails rather than certifying seams it could not check. VX_ALLOW_UNVERIFIED=1 downgrades that to a warning.

Separate compilation

--emit-interface writes a .vxlib: the module’s frozen registry and portable flat-HIR bodies. A downstream compile consumes it with --link-interface and resolves calls into that module without parsing its source.

vxc --emit-interface lib.vx -o lib.vxlib
vxc --link-interface lib.vxlib main.vx -o main

The .vxlib format carries a version tag, and a compiler rejects artifacts written by a different one. Regenerate them when you upgrade the toolchain rather than keeping them in a cache.

The other tools

ToolPurpose
vx-formatThe canonical source formatter
vx-optMLIR pass driver for the Vx dialect
vx-analyzerLanguage server
cargo vx-benchBenchmark harness that injects timing into the AST to measure real hardware execution time

vx-format has no options worth learning: there is one canonical style, and it applies it.

vx-format src/*.vx

The standard library

21 modules, imported as std::<name>. Every type and function is listed in the standard library reference, generated from the sources.

Coreoption, result, box, alloc, closure, iter
Collectionsvec, hash_map, hash_set, string
Numericsmath, simd, tensor
Systemio, fs, net, mmap, time, libc
Testinggoogletest

Beyond std the toolchain ships graph, imported as graph::traversal and friends.

The repository also carries examples/llama.vx, a Llama 2 inference port, and an early packages/vx_linalg. Several other package directories exist under packages/ but are still empty placeholders — do not plan around them yet.

Environment variables

VariableEffect
VX_STD_PATHLibrary search path. A PATH-style list, not a single directory
VX_RUNTIME_LIB_DIRWhere to find the Vx runtime library
LLVM_CONFIG_PATH, MLIR_TRANSLATE_PATH, OPT_PATH, LLC_PATH, CLANG_PATHAbsolute paths to the LLVM tools, if they are not on PATH
VX_DISPATCH_LIBThe accelerator dispatch backend to load
ENZYME_LIBThe Enzyme plugin, for autodiff
VX_ALLOW_UNVERIFIEDDowngrade an undischarged seam obligation to a warning

An installed toolchain sets the first several of these for you through a wrapper script, so you normally need none of them.