vex-cli Reference
This document describes vex-cli architecture, command pipeline, and extension points.
Purpose
vex-cli is the primary developer-facing command-line entry for:
- compile (
vex compile) - run (
vex run) - test (
vex test) - toolchain integration with diagnostics, optimizer remarks, and package/native resolution
Command Surface
Main command modules are under:
tools/vex-cli/src/commands/compile.rstools/vex-cli/src/commands/run.rstools/vex-cli/src/commands/test.rstools/vex-cli/src/commands/pipeline.rs
vex compile
Responsibilities:
- Resolve dependencies via
vex-pm - Build compiler pipeline via
CompilerDriver - Generate object file from LLVM module
- Link executable with:
- runtime linker args (
vex_runtime::get_linker_args()) - native package linker args (
vex_pm::get_native_linker_args_for_source(...))
- runtime linker args (
- Emit optional artifacts (
.ll, CFG, coverage)
vex run
Responsibilities:
- Resolve deps + compile module
- Decide JIT vs subprocess mode
- If native external deps exist, switch to subprocess mode automatically
- Link temporary executable with runtime + merged native linker args
- Execute and report timings
vex test
Responsibilities:
- Discover
*.test.vx/_test.vx - Generate test runner main when needed
- Execute each test function with pass/fail markers
- Handle compile errors and summarize results
Compiler Integration
vex-cli delegates language pipeline to CompilerDriver:
- parsing
- lowering
- type/borrow checks
- codegen
This keeps command handlers thin while preserving shared compilation behavior.
Linking Model
At link stage, vex-cli merges:
- runtime args (
vex_runtime) - native args from package manifests (
vex-pm)
For optimized builds, ThinLTO is enabled where appropriate to reduce FFI overhead while preserving dynamic linking flexibility.
JIT Behavior and Safety
JIT is used when possible for speed, but:
- if external native dependencies are detected,
runswitches to no-JIT subprocess - this avoids hardcoded symbol tables for arbitrary package-defined C APIs
JIT path still registers core runtime + libc/libm/platform symbols needed by runtime.
Diagnostics and UX
vex-cli supports:
- JSON/non-JSON output modes
- optimization remarks
- sanitizer flags
- coverage emission
- lock-file aware dependency workflows
Key Extension Points
- Add new command:
tools/vex-cli/src/commands/ - Extend CLI flags: command handler signatures + argument parser wiring
- Add new link behavior: compile/run link stage argument builders
- Add test behavior:
tools/vex-cli/src/commands/test.rs
Operational Notes
- Native linking behavior is package-manifest driven (
vex.json/native) tools/vex-cli/build.rsis intentionally no-op for package native logic (to avoid package-specific hardcoding)