midad build
midad build <file.md> [-o OUT] [--json]
midad build <file.md> --native FN [-o OUT]
midad build <file.md> --native-all [-o OUT] [--backend auto|c|cranelift]
Three shapes
Bundle. No flags: the interpreter and your source in one executable. It runs
anywhere, without the .md file next to it, and it is not a compile:
$ midad build hello.md -o hello
built hello (interpreter + source bundle; not a native compile)
One function. --native FN compiles the named function to machine code and
gives you an executable that calls it with the command line arguments. The rest
of the program still runs on the interpreter.
The whole program. --native-all compiles the program with the C backend by
default (when cc exists) and with Cranelift when asked:
$ midad build hello.md --native-all -o hello
built hello (native executable via C, whole program)
$ ./hello
hello, world!
What a native build refuses
A native build refuses, by name and with a reason, anything it cannot compile correctly rather than guessing:
- a wildcard or directory permission grant (
fs_read: ["*"]), because a binary cannot enforce a set with no members; - a program with
persist:, because the native runtime does not persist; - routes with an inline body, and anything else outside the subset each backend covers;
- the
nullliteral in a Cranelift build, which refuses it by name and points at--backend c, where it compiles.
The refusals are listed per backend in the limits page, and the message names the thing it refused.
The runtime archive
The Cranelift backend links libmidad_rt.a. A checkout builds it; a
cargo install does not put it next to the binary, and a build without it fails
with a message saying where it looked and that MIDAD_RT_A can point at it. The
C backend does not need it.
Flags
| flag | meaning |
|---|---|
-o OUT |
the output path; the default is derived from the input |
--native FN |
compile one function |
--native-all |
compile the whole program |
--backend auto|c|cranelift |
which backend --native-all uses |
--json |
print the result as an object |