#9. Execution / tools overview
On this page
This block specifies the Nabi compiler nabic, the front-end nabi, and the execution environments (REPL / Jupyter kernel). It covers how the two engines (JIT / AOT) and the three user surfaces (REPL / Jupyter / direct execution of AOT output) defined in Execution engines and user surfaces are implemented.
#Contents
- 9.1.
nabicCLI interface - 9.2. AOT build pipeline
- 9.3. Package archive (.a) format
- 9.4. NABIHIR format
- 9.5. Symbol mangling scheme
- 9.6. JIT engine
- 9.7. JIT cell execution flow and state management
- 9.8. Jupyter kernel integration
- 9.9. Debug / diagnostic tools
- 9.10.
nabi- package / build front-end and tools - 9.11. nabi-mir file format
- 9.12. Plugins
- 9.13.
nabicc- the C compiler - 9.14. Hot reload
#Tool surface
The tool surface is organized as follows.
nabi (front-end, cargo-like; the compiler linked in)
│ new / init, add / remove / update / deps (nabi.nabion, nabi.lock), env, toolchain
│
├── tools (run in nabi itself)
│ ├── nabi run : build, then run
│ ├── nabi dev : run, applying edits while it runs (hot reload)
│ ├── nabi lint : linter
│ ├── nabi repl : terminal REPL (each cell runs once)
│ ├── nabi jupyter : Jupyter kernel (REPL cell session + ZMQ)
│ ├── nabi lsp : LSP server (IDE integration)
│ ├── nabi fmt : formatter
│ ├── nabi doc : API documentation
│ ├── nabi clean : remove build artifacts
│ ├── nabi bindgen : C header bindings
│ ├── nabi inspect : package inspect
│ ├── nabi demangle : symbol demangle
│ └── nabi completions : shell completion
│
│ build / check / emit / test / bench
│ └── resolve deps, then call nabic ... --extern <dep roots>
│ cc
│ └── run nabicc with the arguments unchanged
▼
nabic (compiler)
│
├── nabic build : AOT compile .nabi source to .a / executable
├── nabic emit : intermediate output
├── nabic test : collect + build the #[test] harness (nabi test runs it)
├── nabic bench : collect + build the #[bench] harness (nabi bench runs it)
├── nabic check : front end, lints and code generation (no native build)
└── nabic version / help / --print / --explain
nabicc (= nabi cc, the C compiler)
nabils (= nabi lsp, for editors)
libnabir.a (runtime, nabir)
The toolchain consists of the compiler nabic (the counterpart of rustc), the cargo-style front-end nabi, the C compiler nabicc (9.13), the editor LSP executable nabils, and the runtime libnabir.a. nabi owns the manifest nabi.nabion / nabi.lock, dependencies, environments and the toolchain pin; build commands are delegated to nabic with the resolved dependency packages attached via --extern, and the tools run in nabi itself with the compiler linked in (9.10). There are no separate tools (nabi-fmt etc.).
#Implementation of the two engines
The two engines defined in Execution engines and user surfaces are divided as follows.
JIT engine ── used by nabi repl / jupyter
AOT engine ── used by nabic build / test, nabi run
Both engines go through the same compile pipeline (nabi-hir → nabi-mir → machine code) and diverge only in what happens to the code: loaded into a session's host, or linked into an executable. See Execution engines and user surfaces and Compile pipeline for details.
#Implementation of the three user surfaces
The three user surfaces and the commands that implement them are:
surface command
──────── ──────
REPL nabi repl
Jupyter nabi jupyter (invoked by Jupyter, not directly)
AOT direct exec nabic build → run artifact
The implementation of each surface is covered in the following documents.
#Package build output
A library package of a source unit compiles to libfoo.a and the interface foo.nabihir.
foo/
├── src/
│ ├── lib.nabi <- input
│ └── ...
v nabic build
foo/target/debug/
├── libfoo.a <- artifact (static archive)
├── foo.nabihir <- interface (NABIHIR)
├── build/ <- intermediates (foo.o, ...)
└── ...
The per-profile layout is defined in 9.2.15, and the archive format in Package archive.
#NABIHIR: portable IR for generic functions
Generic functions must be monomorphized at the call site, so binary code alone is not enough. An interface file, NABIHIR, therefore sits next to the library. NABIHIR holds the package source with concrete function bodies stripped (because monomorphization takes the AST as input).
The detailed format is defined in NABIHIR format.
#Single dependency: libnabir.a
An executable links the user package's libfoo.a, the runtime libnabir.a, and the standard library functions it reaches, compiled from source with it or taken from the toolchain's function cache (9.3.6). There are no further dependencies beyond external OS libraries.
The detailed build flow is defined in AOT build pipeline.
Found a mistake? Edit this page on GitHub. Last updated