Skip to main content

16  CLI and Package Manager (edva.ccl)

The edva binary provides single-file / modular compilation, interactive REPL and inline evaluation (-i, -e), AST/type inspection, canonical code formatting (edva fmt), Language Server Protocol support (edva lsp), and top-level package management (edva init, edva add, edva rm, edva build, edva run, edva test, edva fetch, edva update, edva tree, edva vendor, edva cache).

16.1 Compiler invocation and options

edva [options] [input.dva | dir] [output]
edva <command> [options] [args...]
edva -e "<code_string>" [options]
edva -i
edva fmt [--check] [--stdout] [--stdin] [path...]
edva lsp
Short / Long Option Argument Default Specification
-o, --output <str> <stem> Output binary, .o object, .so shared library, .wasm, or .ll path
-r, --run — <-> Run compiled binary immediately after linking (uses node for .wasm targets)
-g, --debug — <-> Emit DWARF source locations and native panic stack traces
--ir — <-> Emit LLVM IR (.ll) only; do not invoke clang
-c, --compile-only — <-> Compile module to object file (.o) only (implies --no-main)
--shared — <-> Build a shared library (.so, implies --no-main)
--entry — <-> Compile as program entry module (emits main)
-m, --module <str> "" Compile as named module <str> (implies -c and --no-main)
-t, --target <str> Host triple Target triple (e.g. x86_64-unknown-linux-gnu, aarch64-linux-gnu, wasm32-unknown-unknown, wasm32-wasi)
-O, --opt <str> "2" Optimization level (0, 1, 2, 3, s, z, or -O0..-Oz)
-H, --header <str> "" Generate C header file at <str> from #export declarations
-e, --eval <str> "" Compile and evaluate inline Edva code string (auto-prints single non-unit expressions)
-i, --repl — <-> Start interactive terminal REPL (:q, :quit, exit, or Ctrl-D to exit)
--ast — <-> Print parsed AST of target program and exit
--ast-tree — <-> Print parsed AST as an indented tree and exit
--typed-ast — <-> Elaborate and verify typed AST, print elaboration stats, and exit
--typed-ast-tree — <-> Elaborate, verify, and dump typed AST tree
--no-main — <-> Emit main with internal linkage
--no-runtime — <-> Omit standard runtime emission
--check-arena-escapes — <-> Check global stores for values owned by scoped arenas
--import-map <str> "" Path to package import map (.edva/imports.ccl)
--cache <str> ~/.cache/edva/ir Compilation cache directory path
--no-cache — <-> Disable compilation cache
--fuzz-cov — <-> Instrument functions, loops, and branches with coverage bitmap (@__dva_cov_map)
--cflag <str> () Pass additional flag to clang (repeatable, e.g. --cflag -lm --cflag -msimd128)
-v, --version — — Display compiler version (edva <version>) and exit
-h, --help — — Display formatted CLI help and exit

16.1.1 Source-level debugging

Compile with -g -O0 for source breakpoints and stepping in GDB or LLDB. The compiler emits function names and instruction locations in DWARF, including locations in imported and specialized functions. Optimized builds also support -g and may inline or eliminate source statements.

edva -g -O0 src/main.dva -o app
gdb -ex 'break main.dva:10' ./app

Native debug builds write the panic site and Edva caller frames to stderr when a source-level panic or checked runtime abort terminates the program. Each entry shows the file, line, and column. Debug information is also included in --ir and -c output. For separately compiled programs, pass -g when compiling each module whose source you want to inspect.

16.1.2 Compiler configuration

Use --no-typed-opt to skip typed rewrites for differential testing. It leaves LLVM optimization flags in effect. Builds with --no-runtime skip typed rewrites to preserve diagnostics for operations that require the runtime.

With separate compilation, pass --check-arena-escapes when compiling the program entry and each module to be checked.

The standard library is discovered beside the executable or under the installation prefix in lib/edva/std or share/edva/std. The compiler uses the conventional XDG_CACHE_HOME base (default ~/.cache). Use --cache or --store to set specific directories and --no-cache, --offline, --git-bin and --timings for explicit behavior.

16.2 Package and cache subcommands

All package and cache commands are first-class top-level subcommands (edva <command> --help shows command-scoped help):

Command Arguments & Options Behavior Diagnostics
edva init [dir] [-n/--name <name>] [--lib] Scaffolds edva.ccl, src/<name>.dva, and (unless --lib) src/main.dva in [dir] (default: .) E7020: edva.ccl already exists
edva add [<alias>] <spec> [--as <alias>] [--rev <r>]
[<alias>] --path <p>
[<alias>] --git <url> [--rev <r>]
[<alias>] --url <u> --hash <h>
Transactionally adds dependency to edva.ccl (auto-inferring alias from edva.ccl name or repo/dir basename when omitted, supporting <spec>@<rev>, owner/repo, and host/owner/repo shorthand), resolves graph, and updates edva.lock.ccl (rolls back edva.ccl on failure) E7021: rollback on fetch/resolve failure
edva rm <alias> [dir] (alias remove) Removes <alias> from edva.ccl and updates edva.lock.ccl and .edva/imports.ccl E7004: dependency not found
edva build [dir \| file.dva] [-o <out>] [-t <triple>] [-O <opt>] [-g] [--cflag <f>] [--locked] [--offline] [--store <d>] [--cache <d>] [--no-cache] Dual-mode: builds package targets from edva.ccl (or src/main.dva \(\to\) ./<name>) or compiles a single .dva file E5039: missing pkg-config lib
edva run [dir \| file.dva] [options] [-- <args...>] Dual-mode: builds and executes the package binary or single .dva file, forwarding arguments after -- to the program E7019: missing source or target
edva test [dir \| file.dva] [--fuzz] [--locked] [--offline] [--store <d>] [--cache <d>] [--no-cache] Compiles and runs all tests/*.dva in a package, or a single test .dva file (--fuzz enables coverage instrumentation and runs the test in fuzz mode) —
edva fetch [dir] [--locked] [--offline] [--store <d>] [--cache <d>] [--no-cache] Resolves dependencies, populates content store, writes edva.lock.ccl and .edva/imports.ccl E7007: lockfile out of date (--locked)
edva update [pkg_name] [dir] Refreshes moving Git branches/tags in edva.lock.ccl (all or single <pkg_name>) —
edva tree [dir] (alias graph) Prints ASCII dependency tree with provenance, duplicate versions, and cycle checks —
edva vendor [dir] Materializes external dependencies into vendor/<id>/ + vendor/vendor.ccl for air-gapped --offline --locked builds E7005: tree hash mismatch
edva cache [dir \| ls \| clean] [--cache <d>] Prints cache directory (default), lists cached .ll entries, or cleans cached IR artifacts —

16.3 Formatter and Language Server (edva fmt, edva lsp)

Command Arguments & Options Behavior
edva fmt [--check] [--stdout] [--stdin] [path...] Canonical Edva source formatter. Normalizes block indentation, delimiter spacing, blank lines, and trailing whitespace while preserving intentional horizontal alignment and verifying AST equivalence via show::show_expr. Formats . recursively when no paths are given. --check exits 1 if any file differs; --stdin formats stdin to stdout
edva lsp — JSON-RPC 2.0 Language Server Protocol server over stdio (Content-Length framing). Provides live diagnostics (textDocument/publishDiagnostics), inferred-type hover (textDocument/hover), same-file and cross-module go-to-definition (textDocument/definition), document symbols (textDocument/documentSymbol), completion (textDocument/completion), and canonical formatting (textDocument/formatting)

16.3.1 edva fmt formatting rules

Rule Construct Indentation / Behavior
Standard blocks (+3 spaces) Function/lambda bodies (=>, !=>, | x =>), cycle bodies (@, @@, >--), [guard] arm bodies, choice arms relative to the choice head, and #type / #foreign / #public / #private blocks Indented by +3 spaces relative to the enclosing statement or inline-started block opener (my_fn = a, b => first_line followed by second_line at +3 spaces)
Inline choice arm bodies (+2 spaces) Choice arm starting on the same line as | or !| (| first_line) Subsequent statements of the arm block indent by +2 spaces relative to |, aligning directly under first_line
Expression continuations (+2 spaces) Multi-line expressions wrapped after a trailing binary or continuation operator (+, -, *, /, &&, ||, ,, $, etc.) Indented by +2 spaces relative to the statement’s starting column
Horizontal alignment Multi-space column alignment in [guard] tables, #type / #foreign declarations, and inline comments Preserved intact

16.4 Package directory layout and edva.ccl manifest schema

16.4.1 Standard package layout

Path Role
edva.ccl Package manifest (name, version, dependencies, native libs, build targets)
edva.lock.ccl Deterministic lockfile pinning commit hashes and canonical sha256-<hex> tree digests
.edva/imports.ccl Generated import map linking @alias imports (#use @pkg) to resolved store/vendor paths
src/<name>.dva Root library module imported when dependents write #use @<name>
src/main.dva Default executable entry point when targets = is omitted
tests/*.dva Independent test executables discovered by edva test

16.4.2 edva.ccl configuration keys

The manifest uses CCL (Categorical Configuration Language) syntax (key = value with indentation-scoped sections):

Section / Key Example Specification
name, version, edva name = my_app Package identifier, semantic version, and minimum compiler version
dependencies.<alias>.path path = ../math_utils Local relative or absolute directory containing edva.ccl
dependencies.<alias>.git / rev git = https://...
rev = v1.2.0
Git repository URL and branch, tag, or commit (pinned with tree hash in edva.lock.ccl)
dependencies.<alias>.url / hash url = https://.../a.tar.gz
hash = sha256-<hex>
Tarball archive verified against sha256-<hex> digest
overrides.<alias> path = ../local_fork Root-manifest override replacing direct or transitive dependency <alias> across the graph
native.libs = sqlite3
= pthread
Portable library names forwarded as -l<lib> to Clang (host paths and .a/.so/.dylib filenames are rejected for portability; supply machine-specific directories via EDVA_LIB_PATH, LIBRARY_PATH, or gitignored .edva.local.ccl native.search-paths)
native.pkg-config = libssl List of packages resolved via pkg-config --libs <name> (E5039 if missing on host)
native.<os> native.linux, native.macos, native.windows Optional per-OS blocks containing libs and pkg-config merged only when building on that host OS
targets.<id>.src src = src/client.dva Entry .dva source file for build target <id> (default: src/main.dva)
targets.<id>.out out = dist/client.wasm Output binary path for build target <id> (default: <id>)
targets.<id>.target target = wasm32-unknown-unknown Target triple passed via -t / --target
targets.<id>.opt opt = -O3 Optimization level (0..3, s, z, or -O0..-O3)
targets.<id>.cflags = -msimd128 List or space-separated string of flags forwarded via --cflag
generate.<step>.src src = views/index.vid Input source file for pre-build/pre-test code generation step <step>
generate.<step>.out out = src/index.vid.dva Generated output path (skipped when up to date with src and generator tool binary)
generate.<step>.cmd cmd = @vid $src $out Command executed in package root ($src/$out expand to step paths; @<alias> or @<alias>/<target> resolves and builds dependency tool binaries on demand)
// Importing external packages declared in edva.ccl:
#use @term
#use @term/colors

term::print("ok")

16.5 Build reproducibility, cache invalidation, and parallel isolation

Edva caches generated LLVM IR under ~/.cache/edva/ir/entries/<sha256> (key_version = 4) and atomically renames completed temporary files into place so concurrent readers never observe partial .ll or cache metadata:

  • Invalidation inputs: Every key hashes the canonical target path, sorted canonical source paths and file content digests across #use dependencies, target triple, optimization level (-O0..-Oz), compiler executable fingerprint, LLVM major version, module/runtime codegen flags (is_module, is_shared, no_runtime, no_main, module_name), native libs/pkg-config, --fuzz-cov, --debug, --cflag values, #export symbols, and #use(dynamic) modules.
  • Native optimization: Profile-use builds hash a private snapshot of the indexed profile. Native PGO and LTO builds also fingerprint Clang, its linker, and explicit object inputs. See the native optimization workflow.
  • Parallel isolation: Without --ir, -c --module <name> -o dir/mod.o writes its transient IR at <outpath>.ll rather than <module>.ll in the current working directory, allowing parallel make -j and concurrent package builds to share a cache directory without colliding on CWD files.
  • Offline & locked builds: edva vendor copies all resolved Git, archive, and path dependencies into vendor/ alongside vendor/vendor.ccl; subsequent edva fetch --offline --locked, edva build --offline --locked, and edva test --offline --locked verify recorded tree hashes with zero network access. Generator tools invoked via @<alias> automatically rebuild when dependency sources or the active edva compiler binary become newer than the cached tool binary.

16.6 Host & target support matrix

Target Triple Status Native Linker / Runner Supported Stdlib & Tooling Notes
x86_64-unknown-linux-gnu Tier 1 (Primary) clang + LLVM 18 + POSIX libc Full stdlib (io_uring, POSIX sockets, task::spawn, ThreadSanitizer), edva fmt, edva lsp, --fuzz-cov
aarch64-unknown-linux-gnu Supported Target clang --target=... Linux System V ABI, modular builds, package manager
x86_64-apple-darwin Supported Target clang (-Wl,-export_dynamic, __error) POSIX sockets/kqueue-compatible polling, --shared (dynamic_lookup), package manager
aarch64-apple-darwin Supported Target clang (aarch64-apple-darwin) Apple Silicon native ABI & --shared
wasm32-unknown-unknown Tier 1 (Wasm) clang -c + wasm-ld (node host / browser) Pure compute, @vid/std/dom (.dom.js bridge), -target wasm32-unknown-unknown
wasm32-wasi Supported Target clang -c + wasm-ld Standalone WASI modules (--no-entry --allow-undefined)