# Runtime and Tooling

The Vex repository is more than a compiler. The runtime and tools layer determines how code is linked, executed, tested, formatted, and surfaced in editors.

## Runtime Layer

Runtime support lives primarily under `lib/runtime/`.

This layer includes infrastructure for:

- allocation and heap management
- async and task runtime support
- scheduler state
- runtime symbols used by CLI execution paths
- platform integration for native execution

## Execution Model

Vex compiles to native code ahead-of-time (AOT). Both `vex run` and `vex compile` produce native binaries via LLVM. `vex run` compiles to a temporary executable and runs it as a subprocess; `vex compile` produces a standalone binary.

VexArch is rehydrated from the compiler's embedded VRI and lowered into the
same backend module as user and prelude code. Release packages do not carry a
VexArch bitcode module or static/dynamic runtime library. A tiny
target-selected native support object may be materialized for irreducible
assembly. The macOS build also has a native Objective-C CoreML bridge; that
platform integration is distinct from VexArch semantic runtime code. System
and package-native dependencies remain explicit in the final link plan.

## CLI Tooling

`tools/vex-cli/` is the main developer-facing entry point.

Important commands:

- `vex run`
- `vex compile`
- `vex test`

The CLI owns orchestration around:

- dependency resolution
- compiler-driver invocation
- embedded VRI target selection and semantic fusion
- linking
- execution model selection
- test discovery and execution

## Other Tooling

The repository also contains:

- `tools/vex-lsp/` for editor integration
- formatter tooling
- docs tooling and site generation

These tools matter because they all depend on the same semantic model staying aligned with the compiler.

## Why This Layer Matters

Many user-facing “language” issues are actually toolchain or runtime issues:

- requested-target ABI and native-support selection
- reachable provider/link-plan differences
- fused runtime reachability constraints
- test-runner discovery assumptions
- editor/compiler semantic drift

Understanding this layer makes debugging much faster.

## Related Pages

- [CLI Reference](../references/vex-cli-reference.md)
- [Test Reference](../references/vex-test-reference.md)
- [Compiler Pipeline](compiler-pipeline.md)
