Toolchain -- Complete Reference
The vex CLI provides compilation, analysis, testing, project, and inspection commands. This page describes the 0.4.0 command surface and the workflows for building, checking, inspecting and maintaining a Vex project.
vex CLI
vex <command> [options] [args]All Subcommands
| Command | Description |
|---|---|
vex run <file> | Compile and execute a Vex program |
vex compile <file> | AOT compile to native binary |
vex build | Build a package selected by vex.json |
vex lint [target] | Correctness analysis, semantic lints and verified fixes without codegen |
vex ir <file> | Emit LLVM IR (shorthand for compile --emit-llvm) |
vex test | Run tests or benchmarks |
vex format <file> | Format source code (-i for in-place) |
vex doc | Generate documentation from source |
vex new <name> | Create a new Vex project |
vex init | Initialize vex.json in existing directory |
vex add <dep> | Add a dependency |
vex remove <dep> | Remove a dependency |
vex update | Update all dependencies |
vex list | List all dependencies |
vex watch <file> | Watch and recompile on changes |
vex workspace | Workspace management for monorepos |
vex tool <tool> | Invoke bundled LLVM tools |
vex env | Show environment configuration |
vex setup | Setup VEX_HOME with standard library |
vex clean | Clean cache and build artifacts |
vex repl | Inspect interactive input with retained parsing context |
vex view <type> <file> | Inspect AST, CFG, DFG, layout or escape information |
vex prof <file> | Profile microarchitectural pipeline performance using LLVM-MCA |
vex mod | Dependency graph, verification, and module maintenance commands |
vex vxm | Inspect and verify portable VXM package images |
vex daemon | Manage the compiler daemon |
vex compile -- AOT Compilation
# Basic compilation
vex compile main.vx
# With optimization
vex compile -O 3 main.vx
vex compile --opt-level 3 main.vx
# Emit artifacts
vex compile --emit-llvm main.vx # LLVM IR (.ll)
vex compile --emit-asm main.vx # Assembly (.s)
vex compile --emit-spirv main.vx # SPIR-V (for GPU functions)
# Enable features
vex compile --gpu main.vx # GPU support
# Debug build
vex compile -g main.vx # DWARF debug info
# Output file
vex compile -o mybinary main.vx
# Compile as a dynamic/shared library (.dylib, .so, or .dll)
vex compile --shared lib.vx
# Structured semantic diagnostics
vex lint --format json main.vxData-parallel lowering follows the program, target and optimization pipeline described in the SIMD guide. Use vex lint --format json main.vx for structured semantic diagnostics and retain the command's exit status.
vex run -- Compile and Execute
vex run main.vx # compile and run
vex run -O 3 main.vx # with optimizationCheck the help for the command you use rather than transferring options between commands. For program arguments, use vex run main.vx -- arg1 arg2. The GPU guide explains graph execution and target selection.
Ordinary user vex compile and vex run refresh V1 symbol sidecars from current source and HIR without publishing a complete portable V2 package. Existing V2 images stay unchanged, and fresh V1 metadata does not make a stale V2 image valid. Generated declaration namespaces currently fall back to complete publication. vex build, compiler-runtime compilation and explicit vex lint <package-root> --publish-vxm retain complete publication. Keep source available unless a complete portable image has been successfully published.
vex lint -- Semantic Validation and Cleanup
vex lint main.vx # check and lint one file
vex lint . # check and lint a package
vex lint --deny-warnings . # CI quality gate
vex lint --diff . # preview verified fixes
vex lint --fix . # apply verified fixesvex lint runs parser, resolution, type, borrow and validation queries without LLVM codegen. Fixes are revision-bound structured edits and are committed only after semantic re-analysis. The former vex check, vex analyze and vex fix compatibility commands are removed; use the corresponding vex lint mode. See Linting and Verified Fixes for the complete rule catalog, configuration, suppressions, pointer migration, and transactional fix guarantees.
vex ir -- LLVM IR Quick View
vex ir main.vx # write vex-builds/main.ll
vex ir main.vx -o inspected # write inspected.llIR is written to a file: the compiler replaces the selected output extension with .ll. The informational terminal message is not the IR payload.
vex format -- Code Formatter
vex format main.vx # output formatted to stdout
vex format -i main.vx # format in-place
# Check formatting in CI:
vex format main.vx | diff main.vx -vex test -- Test Runner
# Run all tests
vex test
# Select a test directory and filter function names with a regular expression
vex test --run '^test_addition$' tests/
# Run benchmarks
vex test --bench
# Benchmark with a custom target duration (capped at 1 second)
vex test --bench --benchtime 500ms
# Show memory stats during benchmark
vex test --bench --benchmem
# Fail fast
vex test --failfast
# Filter tests by regex
vex test --run "parser_.*"
# JSON output
vex test --json
# Short mode (skip slow tests)
vex test --shortWriting Tests
Directory discovery includes files named *.test.vx, *_test.vx and *_bench.vx. A positional argument selects a path or glob; --run filters function names. An empty selection does not prove a test passed. See the test reference for discovery and exit behavior.
// tests/arithmetic.test.vx
fn test_addition() {
let result = 1 + 1
$assert(result == 2, "1 + 1 must equal 2")
}
fn test_option_default() {
let opt = Some(42)
$assert(opt.or(0) == 42, "Some(42).or(0) == 42")
}vex new / vex init -- Project Scaffolding
vex new my-project # create new project directory
vex init # initialize in current directoryCreates:
my-project/
├── vex.json # package manifest
├── src/
│ └── lib.vx # starter source and entry point
└── tests/ # test directoryvex add / vex remove -- Dependency Management
vex add github.com/your-org/your-package@v1.2.0
vex remove github.com/your-org/your-package
vex update # resolve dependency updates
vex list # list all dependenciesReplace the example repository and tag with a real package you can access. These commands operate on vex.json and vex.lock in the project directory. Standard-library imports such as http are not instructions to install a registry package with that bare name. Review manifest and lockfile changes after updating, and rerun the application's tests before adopting them.
vex watch -- Watch Mode
vex watch main.vx # recompile on file changesThe current implementation recompiles through its compiler driver when the entry file changes. It does not provide a complete dependency watcher or automatically execute a newly linked application. Use vex run explicitly when you need to exercise runtime behavior.
vex workspace -- Monorepo Management
vex workspace list # list workspace members
vex workspace add ./new-crate # add membervex tool -- Bundled LLVM Tools
vex tool objdump -d mybinary # disassemble
vex tool nm mybinary # list symbols
vex tool ar crs libfoo.a foo.o # create static library
vex tool strip mybinary # strip debug symbols
vex tool lld -- <linker-flags> # invoke lld linker
vex tool info # show toolchain infovex repl -- Interactive REPL
vex repl accepts interactive input and keeps selected declarations as parsing context. For the complete edit/check/run workflow, save a program to a file, check it with vex lint example.vx, then execute it with vex run example.vx.
vex clean -- Clean Artifacts
vex clean # clean build cachevex env / vex setup -- Environment
vex env # show VEX_HOME, toolchain paths
vex setup # setup ~/.vex with stdlibBest Practices
- Use
vex lintfor fast semantic validation during development. - Use
vex format -ibefore committing code. - Run
vex test --benchbefore and after optimization changes. - Test parsers with valid, malformed, truncated and boundary inputs. Compiler developers can also use the compiler testing tools.
- Use
vex watchfor its supported entry-file recompilation, and run the application explicitly when checking behavior.
Build your own language tools
The language-tooling libraries cover lexing, grammar rules, syntax trees, incremental query metadata, diagnostics, document layout, protocol messages and a Vex-written IR toolkit. They are useful for formatters, source browsers, small languages and editor integrations written in Vex.
Editor integration with vex-lsp
vex-lsp serves the Language Server Protocol over standard input/output. Configure your editor's LSP client with the absolute path to the server executable, the Vex file type and the project workspace root. Open the package root containing vex.json so imports and project configuration have the same context as the command-line tools.
For a source build, from the compiler checkout root:
cargo build --release -p vex-lsp --target-dir targetThe server is target/release/vex-lsp (.exe on Windows). The editor launches it as a protocol process; stdout belongs to that protocol. Server logs go to the temporary-directory vex-lsp.log stream. Keep the compiler, standard library and server revisions aligned when checking an editor diagnostic.
The server exposes completion and signature help, hover and navigation, references and rename, symbols and hierarchies, semantic tokens and inlay hints, formatting and code actions. Lint code actions use the same rule identities and verified edit model as command-line linting. Editor diagnostics help during editing; run the program and tests for execution checks.
A useful editor acceptance flow is to open two importing files, navigate to an export, change a referenced type, inspect the resulting diagnostic, apply a verified fix and rerun the package tests. This exercises the relationship between document state, project imports and compiler semantics.
Formatting configuration
vex format uses the formatter library and discovers vexfmt.toml or vexfmt.json from the input file's directory and its ancestors. For example, save this valid configuration as vexfmt.json at the project root:
{
"max_width": 100,
"indent_size": 4,
"brace_style": "same_line",
"trailing_comma": "multiline",
"quote_style": "double"
}Preview a file in the terminal, then write the formatted result when ready:
vex format src/main.vx
vex format -i src/main.vxKeep formatting separate from semantic cleanup: use vex lint --diff to inspect a proposed fix and vex lint --fix to apply verified changes. Re-run the relevant tests after changes that alter program behavior. 6. Use vex lint --format json for structured analysis diagnostics and the language server for editor integration. Check command-specific output contracts before parsing other CLI modes as JSON.