One binary does everything: compiling, linking, serving editors, cleaning up. Every flag has a short and a long spelling (-c and --compile are the same flag), values are case-insensitive where they name a choice, and flags that take a list separate its items with commas. A flag that takes a list — --source, --external-contract, --optimize and --quality — may also be given more than once, in either spelling, and each occurrence adds its items to the ones before it. Every other flag takes one value: giving it a second, different value is refused by name, and the same value given twice stands.

the flag '--platform' takes one value and was given two, 'linux,amd64,utf-8' and 'linux,arm64,utf-8'; give it once, with the value meant

A representative build:

mica --compile --link --optimize release,full_optimizations \
     --platform linux,amd64,utf-8 \
     --source Hello.mica --build build

Modes

FlagEffect
-c | --compilecompile source files to assembly
-l | --linklink the compiled objects into the output program or library — requires --compile
-r | --runcompile one source file and immediately execute it, like a script; --run - reads the source from standard input. With --platform naming the other architecture, the program starts under that architecture’s user-mode emulator, qemu-x86_64 or qemu-aarch64 from the qemu-user package, with the cross C library under /usr/<triple>; with --sanitize, it runs checked
-lsp | --language-serverrun as a language server over standard input and output; the former spelling --lsp stays accepted as an alias; the VS Code extension is the packaged client, and any LSP-capable editor can be pointed at the command
-in | --inspectprint the manifest a linked program, archive or shared object carries, as one line of JSON, without starting it: among its members its own version and the libraries it was built against with theirs, for a program or a shared object image, the memory the program image needs before it starts, and for a library contract, the contract it carries inside it
-fm | --formatformat Mica source files in place to the house layout and print each rewritten path; a directory formats every .mica file beneath it, and - reads standard input and writes standard output; combines only with --check
-ck | --checkwith --format: write nothing, print every path that is not formatted, and exit with 1 when one is not
-p | --purgeempty the build directory first — requires --build, and may run without --compile
-v | --versionprint version information and exit
-h | --helpprint the flag summary and exit

At least one of --compile or --purge must be present; everything else qualifies them. --language-server stands alone: it claims standard output for the protocol and prints no banner. --inspect stands alone too: it reads one program file, prints its manifest and no banner, and refuses any other flag and any further word. --format is a mode of its own: it combines only with --check, and the paths it formats follow the flags, mica --format --check src; it changes white space only, so every token, every comment and every line break stays.

The run mode

mica --run tool.mica compiles the file into a temporary directory at the debug tier — checks maximal, latency milliseconds — executes it, forwards the program’s exit code as its own, and removes the directory, an interrupted run included. Nothing is cached and nothing lands beside your file. Two roads leave the directory behind: a run killed outright, which has no chance to remove it, and an internal compiler error, which keeps it because its message names the crash report written there, mica-run-…/mica-crash-report.tar.gz in your temporary directory, as the file to send; the directory is yours to remove once the report is sent.

mica --run tool.mica alpha beta      # everything after the file belongs to the program
mica tool.mica alpha beta            # the bare spelling means the same
mica --optimize O2 tool.mica         # the run mode's flags may precede the file
mica --run --optimize O2 tool.mica   # before or after --run
mica --run - << 'EOF'                # a here-document is a program
program Hi; imp WriteLn : std; begin WriteLn("hi"); end.
EOF

The rules, each of which is the scripting convention:

  • Arguments. Everything after the source file belongs to the program (readable through the process unit’s ArgCount and Arg); an optional -- between file and arguments is accepted. Compiler flags come before the file: ahead of --run or between --run and the file, and before the file in the bare spelling. A word between --run and the file that starts with - and is no flag is refused by name.
  • Exit code. The program’s exit code is the process exit code — callers branch on it.
  • Streams. The program owns standard output. The compiler is silent on success, keeps warnings, and speaks on standard error only.
  • Shebang. A leading #! line belongs to the operating system, and the compiler’s source preparation removes it on every road — the build, the editor, and the run mode all read the file identically, with line numbers preserved. The bare spelling makes #!/usr/bin/env mica a working first line — chmod +x and the file runs — and it also accepts an existing file with no extension, so a script installed under a command name stays a command.
  • Projects. The nearest mica.project up the directory tree contributes its encoding and contracts — a script beside your project imports your libraries with no flags — and when the file is one of the project’s own sources, the whole source set compiles with it.
  • Flags. The run mode owns compilation, linking, and the build directory; it combines with --optimize, --stdlib, --memory-class, --tasking, --processes, --runtime-flags, --platform, --sanitize, --stack-size, and --remarks, and refuses everything else with one line. Everything after the file is the program’s; a runtime-flag group at the head of it reaches the program’s runtime. It targets the host architecture; cross builds go through --compile.

Inputs and outputs

FlagValueEffect
-s | --sourcefile.mica,file.mica,…the source files of the build, comma-separated
-pj | --projectpath to mica.project or its directoryread the compilation’s facts — sources, encoding, consumed contracts, version — from a project file; every explicit flag overrides its entry
-b | --builddirectorywhere every generated file lands; the linked binary is named after the first source file’s program or library
-sl | --stdlibpath to an archivename a standard library explicitly; when omitted, the compiler resolves mica-stdlib-<arch>.a next to its own executable first, then under /usr/lib/
-xc | --external-contractone or more paths to mica.external, its directory, or a library’s archive or shared object, comma-separatedconsume external libraries’ interop contracts from explicit locations instead of the source-directory lookup; several paths let one program import several separately built libraries, each through its own contract, and a repeated --external-contract adds its paths to the ones before it, as the comma-separated form does; a library binary is read through the contract inside it

The project file. A mica.project beside the sources states what belongs to the source tree rather than to any one invocation:

{
    "sources": ["Consumer.mica"],
    "encoding": "utf-8",
    "contracts": ["../build/Utilities", "../build/LibB"],
    "version": "1.4.0",
    "requires": {"Utilities": "2.0"}
}

--project reads it, explicit flags override its entries one by one, and a --platform that names no encoding — linux,arm64 — completes its encoding from the file. The version has no flag: it is the program’s or library’s own, written as Semantic Versioning writes one. A library is linked only under a version, so a library’s build names its project file, and a build that reads a project file reads the version it states. requires states which versions of each library the build accepts, "2.0" every version from 2.0.0 up to 3.0.0, and a library outside its requirement refuses the build by name. A library’s build carries its version into the contract it emits, and every program built against the library names it in its build, Using library 'Utilities' 2.0.0, and in its manifest. The language server discovers the project on its own by walking up from the open file, so the editor analyzes each source under the same sources, encoding, and contracts the build uses, with no configuration. The file is ignored by compilers older than 6.12.5.

Naming a standard library explicitly is also a statement of trust: a mica-stdlib-<encoding>.external contract beside the named archive is used as that library’s import surface. An auto-resolved standard library uses only the surface embedded in the compiler binary — no file on disk changes what an installed compiler believes. One contradiction is refused rather than honoured: an archive that does not match the declared --memory-class — a hosted archive for a fixed-arena program, or the reverse — is refused with the consequence spelled out, because honouring it would link a fixed-arena program with no arena at all.

What is built

FlagValuesEffect
-om | --output-modifiernone · archive · objectthe library output kind: archive produces a static library (.a), object a shared object (.so), none (default) an executable program — requires --link. A shared object names the shared runtime floor the mica-dragon-rt package installs beside the archives, libmica-dragon-rt-<arch>.so.<release> or one of its variants, instead of carrying a copy, so every Mica shared object a process loads runs on one floor with one scheduler and one carrier pool; the floor stays loaded once a process has loaded it, and a second floor, which a library built by another release, at another tier or with another tasking flavor or memory class would bring, is refused by name as it loads. A library that exports a task, or places work on processes, links as an archive: a program starts a task at the address of its entry, which a position-independent program cannot take from a shared object, and no program starts a process server for the floor beneath a shared object
-ext | --externalstatic · sharedhow external C libraries are linked; the default is static, which needs no rpath and ships as one artifact — requires --link
-ec | --emit-contractwhen linking a library, emit its interop contract (mica.external) beside the archive as well; the archive or shared object carries the same contract inside it with or without the flag — requires --link
-np | --no-piedisable position-independent-executable output — requires --link
-st | --staticlink the program wholly statically, so the binary carries its own libc and runs on a machine that has none — program outputs only, requires --link
-sp | --stripstrip the symbol table from the linked program or shared object, the shipping shape; without it a build of any tier keeps every function’s name, so a profiler, a backtrace and a debugger read the program’s own procedures — requires --link, not for archives
-sa | --sanitizeaddress · undefined · threadlink the program under a C sanitizer, so the C beneath it runs checked and the first error ends the program with a report naming the C file and line — program outputs only, requires --link; the sanitized builds below say what it links and what it needs. Combines with --run

Sanitized builds

--sanitize address links a program under the GNU C compiler’s address sanitizer, which catches out-of-bounds and freed-memory accesses, --sanitize undefined under its undefined-behavior sanitizer, which catches overflows, misaligned and null accesses and invalid shifts, and --sanitize thread under its thread sanitizer, which catches data races between the threads a multicore program runs its tasks on. The program’s own code is built exactly as without the flag. What changes is what it links: the sanitizer’s runtime, and the Dragon runtime built under the same sanitizer, so every line of C beneath the program runs checked — the runtime’s own, and any C library of yours compiled with the matching option, -fsanitize=address, -fsanitize=undefined or -fsanitize=thread. The first report names the C file and line and ends the program; a thread report names both accesses of the race, and the program ends with exit code 66.

mica --compile --link --sanitize undefined --source Hello.mica --build build
./build/Hello

The runtime built under the sanitizers is an optional package beside the Dragon runtime, under the same licence. It depends on gcc, whose packages bring the sanitizer runtimes:

sudo apt install ./mica-dragon-rt-sanitizers_<version>_<arch>.deb

A program linked under a sanitizer says so in its manifest: mica --inspect prints "sanitizer":"address", "sanitizer":"undefined" or "sanitizer":"thread", and "sanitizer":null for every other program. The address sanitizer serves the hosted heap, the undefined-behavior sanitizer every memory class and tasking flavor, and the thread sanitizer the multicore tasking flavor in either memory class. A checked build of a program with a heapless routine admits the address and the undefined-behavior sanitizer, and refuses the thread sanitizer, which takes the C allocator’s entries the heapless watch reads and shows it only some of its blocks. A sanitized program finds the sanitizer’s runtime as a shared library when it starts, so it runs on a machine with the GNU C compiler’s runtime libraries installed: it is a build for finding errors, not the one you ship.

A sanitized build the compiler cannot link is refused with one line:

SituationThe line
beside --staticThe address sanitizer's runtime is a shared library the program finds at start, and a wholly static program finds none - drop the '--static' selection or the '--sanitize' selection
for a library outputThe address sanitizer's runtime joins a program, and a library is linked without it - link the library without '--sanitize', and the program that links it with '--sanitize'
address beside --memory-class fixed-arenaThe address sanitizer watches the blocks the C allocator hands out, and a fixed-arena program takes its cells from its own arena, where the sanitizer never sees them - name the hosted-heap memory class, or the undefined-behavior sanitizer
thread beside the single-tasking flavorThe thread sanitizer watches the threads a multicore program's carriers run on, and a single-tasking program runs every task on one thread - name the multicore tasking flavor, or the address or undefined-behavior sanitizer
thread beside a checked program with a heapless routineThe thread sanitizer takes the C allocator's entries for itself, and a checked program with a heapless routine points the same entries at the watchers that keep the routine's promise - drop 'checked' from '--optimize', or name the undefined-behavior sanitizer
the sanitized runtime not installedThe undefined-behavior sanitizer needs the runtime floor built under it, which is not installed here: the archive 'mica-dragon-rt-sites-ubsan-amd64.a' is missing from '/usr/bin' and '/usr/lib'. Install the 'mica-dragon-rt-sanitizers' package from https://mica-dev.com/
a value other than the threeinvalid value for sanitizer 'memory': '--sanitize' takes 'address', 'undefined' or 'thread', one sanitizer per build
without --linka sanitizer's runtime joins the program at its link, so the sanitize option requires the link option

A target whose C compiler installed no runtime for the sanitizer, such as the other architecture before its cross compiler is installed, is refused by the files the link looked for.

Target selection

FlagValueEffect
-pf | --platformos,arch,encodingthe target platform, e.g. linux,arm64,utf-8 — requires --compile. Combines with --run
-asm | --assemblyintel · attthe emitted assembly syntax; the default is intel — requires --compile

The accepted values: operating system linux; architecture amd64 or arm64; string encoding utf-32 or utf-8. All four Linux combinations are valid. When no platform is named, the build targets the machine it runs on: Linux with the host’s own architecture, utf-32 encoded. The string encoding is fixed per binary — utf-32 is the general-purpose default, utf-8 the interop-oriented choice; format specifiers follow it (%ls under utf-32, %s under utf-8), and the compiler checks them at compile time.

Optimization

FlagValueEffect
-o | --optimizecomma-separated setselect the optimization profile and passes — requires --compile; when the flag is omitted entirely, the build is a plain debug build

The three spellings almost everyone uses:

LevelExpands toMeaning
O0debugevery variable observable, every line breakable, every GPU kernel finished before the program goes on — the profile a debugger wants
O1release,standard_optimizationsthe release profile with the standard pass set
O2release,full_optimizationsthe release profile with the full optimizing set

O3 is refused by name, with an explanation: the transformations that would distinguish it from O2 — vectorization, loop unrolling — do not exist yet, and an alias that silently meant O2 would be a promise the compiler does not keep.

The set may also name its members directly: the profiles debug and release (mutually exclusive; naming neither in a non-empty set defaults to release), checked for the checked runtime diagnostics, a flag beside either profile — O2,checked ships every guard on the optimizing lowering, debug,checked keeps every variable observable at the trap, and checked alone means release,checked as any set naming no profile means release — profiling for the line table, the subprogram entries and the inlining records at any tier — O2,profiling is the build a profiler attributes to source lines and a debugger shows an inlined procedure in as its own frame, with no variable locations and the code of the plain build to the byte — the group names standard_optimizations and full_optimizations, and the individual pass names constant_folding, assembly_peephole, stub_allocator, graph_allocator, function_inlining, loop_optimization, fp_contract, heap_contract — plus the two code-generation modes il_static_single_assignment and il_direct_lowering, which are mutually exclusive and exist for differential testing of the middle end. Individually named passes are an instrument for working on the compiler; programs are shipped with O0, O1, or O2.

What each level does

LevelCode pathRegister allocatorDebug informationRuntime floor
debug (O0)direct loweringnone: every value lives on the stackfullrecords the allocation site of every cell
releasestatic single assignmentlinear scannoneplain
release,standard_optimizations (O1)static single assignment, assembly peepholelinear scannoneplain
release,full_optimizations (O2)static single assignment, assembly peephole, inlining, loop optimizationsgraph colouringnoneplain

release alone takes the static-single-assignment road with no pass beside it: it is the setting that exercises the middle end in isolation, and a program ships with O1 or O2. A set that names no level is a release build, so full_optimizations alone is the same build as O2. profiling adds the line table, the subprogram entries and the inlining records to any release level. The standard library is the same prebuilt archive at every level.

At O1 and O2, the levels that run the assembly peephole, a branch that only chooses which value a local variable takes is compiled without a jump where the variable lives in a register: as a conditional move on x86-64 and a conditional select on AArch64. release alone keeps the branch. Leaving SSA shows the conversion in a program’s export.

Every level computes the program’s constant expressions when it compiles: a debug build holds the value of Limit * 2 as an O2 build does, so a constant has one value whatever the level, and no flag that changes the run time’s arithmetic gives it a second one. The pass name constant_folding names that computation: O1 and O2 list it among their passes, in the manifest --inspect prints as well, and a set may still name it, which changes nothing the build makes.

A program that computes on an NVIDIA GPU may add fp_tensor_float32: O2,fp_tensor_float32 lets every float32 matrix product the program runs, the reverse products of its tape included, read its inputs in TF32 on the card’s tensor cores — ten bits of mantissa beside float32’s exponent range, sums kept in float32 — the setting nanoGPT trains with. An attention keeps float32’s precision either way, as PyTorch’s float32 attention does under that setting. A product’s digits then differ from float32’s from about the fourth significant one on, which is why the flag belongs to no level and is named only for a program; a library’s build refuses it, because the program that links the library decides for all its products.

Every release build, O1 and O2 among them, lets the GPU work through its kernels and products while the program goes on, and a copy back to the processor waits for their results; O0 waits for each one, so a kernel that fails is named where it failed.

Deployment classes

FlagValuesEffect
-mc | --memory-classhosted-heap · fixed-arena · fixed-arena=<bytes>the memory deployment class; selects the matching standard-library archive. hosted (default) uses the operating system’s heap; fixed-arena places the whole program heap in one arena of the given size, for deployments that must not allocate after start
-tk | --taskingsingle · multicore · multicore,<carriers> · multicore,<carriers>,fixedthe tasking flavor. multicore runs tasks on a carrier pool and links the multicore standard-library archive; the count, from 1 to 1024, is the pool’s size unless the program is started with a carriers runtime flag, and with no count the pool sizes itself at start to the processors the program may use (the least of the processors online, its affinity mask and its cgroup’s CPU quota, see how many carriers a pool starts). ,fixed pins the count: the program refuses the carriers flag
-ps | --processesa counthow many worker processes run the tasks the program places on processes at once, from 1 to 1024; a task placed beyond the count waits until a worker ends. The program’s processes runtime flag replaces the count at start, and without one the count is the processors the program may use (see how many worker processes run at once). A program’s decision: refused for a library. Combines with --run
-rf | --runtime-flagsopen · sealed · sealed,rtp · nonewhat the built program accepts in the runtime-flag group at the head of its arguments: open every flag the build did not pin (the debug default), sealed only info, check, gpu=<n>, stdout=line and heap (the release default), sealed,rtp those and the runtime protocol’s rtp= flags, none no group at all

Diagnostics and analysis

FlagValueEffect
-ss | --stack-sizebytesgive the program this many bytes of stack: every frame the stack holds compiles quietly and a frame it cannot hold is refused — in both directions, so a small embedded request tightens the limit — while the default stack warns at frames above 1 MiB; a linked program raises its own stack limit before main runs (default: the platform’s 8 MiB). Combines with --run
-vb | --verbosereport the per-source optimization statistics beside the build: what each pass folded, inlined, forwarded, elided and declined — requires --compile
-rm | --remarksreport the compiler’s remarks: hints from its own knowledge about your code — be careful here, or do it another way. A remark never gates a build and is spoken only when asked for; combines with every road, --run included — requires --compile
-exp | --exportwrite every intermediate representation to the build directory — requires --compile; the compiler, exported walks all sixteen stages
-pr | --profileprint a per-phase and per-pass compile-time table and write profile.json to the build directory — requires --compile
-q | --qualitysemantic_analysis · intermediate_code · machine_code · no_quality_gates, several joined by commasextra verification runs inside the compiler, for root-cause analysis of internal compiler errors: semantic_analysis checks the analyzed syntax tree, intermediate_code the intermediate code after its generation and after placement, machine_code the machine code the peephole pass of O1 and O2 leaves — requires --compile
-cp | --cpu-profilefilewrite a CPU profile of the compiler itself to the file
-mp | --mem-profilefilewrite a memory profile of the compiler itself to the file

The combination rules

The compiler refuses inconsistent combinations rather than guessing: --link requires --compile; --no-pie, --emit-contract, --output-modifier, --external and --sanitize require --link; --optimize, --platform, --assembly, --export, --profile and --quality require --compile; --purge requires --build. Each refusal names the rule.