Coming from mocalpha
Map moc command lines and flags to moxzi, and the defaults that differ.
moxzi compiles the same language as moc 2.0.0, reports the same error codes, and accepts most of the same flags. This page maps one to the other.
The command#
# moc
moc -c --idl -o main.wasm --package core .mops/core@2.5.0/src src/Main.mo
# moxzi: compiling is the `build` subcommand, and the .did is written by default.
# With a mops.toml, packages are found automatically.
moxzi build src/Main.mo -o main.wasm
Defaults that differ#
moc | moxzi build | |
|---|---|---|
Candid interface (.did) | Only with --idl | Always written; --no-idl turns it off |
debug { … } blocks | Kept (--debug is the default) | Dropped. Pass --debug to keep them. There is no --release flag |
candid:service, candid:args metadata | Private | Public, as dfx sets them. --public-metadata replaces this default |
| Packages | --package flags | Read from mops.toml through mops sources; --package adds to them |
| Persistence | Enhanced orthogonal persistence | Enhanced orthogonal persistence |
persistent actor | Every actor is persistent; the keyword warns M0217 | Same |
Flags that work the same#
moc | moxzi build |
|---|---|
-o FILE | -o, --out FILE |
--package NAME PATH | --package NAME PATH |
-A, -W, -E CODES | -A, -W, -E CODES (comma-separated) |
--stable-types | --stable-types |
--enhanced-migration DIR | --enhanced-migration DIR |
--stable-baseline FILE | --stable-baseline FILE |
--public-metadata NAME, --omit-metadata NAME | same |
--implicit-derivation-depth N | same |
--stable-regions | same |
--max-stable-pages N | same |
--stabilization-instruction-limit N | same |
-measure-rts-stack | --measure-rts-stack (two dashes) |
Flags that became subcommands#
moc | moxzi |
|---|---|
--stable-compatible PRE POST | moxzi stable-compatible PRE POST |
--print-deps FILE | moxzi deps FILE. Lists every file in the build, not only direct imports |
moc features moxzi doesn't have#
moc | Alternative |
|---|---|
-r, -i, -iR, -t (interpreter, REPL, tracing) | Run the actor with moxzid |
--check | Build and discard the output |
--explain, --error-format, --error-detail, --error-recovery, --ai-errors, --print-source-on-error | None. Errors are plain text in moc's default format |
-Werror, --hide-warnings, --warn-help | Use -E with specific codes |
--actor-idl, --actor-alias, --actor-id-alias, --actor-env-alias | Import the interface with idl: and create the reference with actor "…". See Importing a Candid interface |
-g, --map | None |
-wasi-system-api | None |
--args FILE | Use shell expansion |
moxzi additions#
| Option | Purpose |
|---|---|
--no-link | Write an unlinked module (moc 2.0 removed -no-link) |
--gzip | Also write a gzipped module |
--compact-rts | Smaller heap, for moxzid and moxzi-web |
--stack-budget N, --progress N, --status-secs S, --timings | Control and observe long builds |
--remote URL --canister ID | Build on-chain |
--root DIR | Set the project directory |
--compiler, --linker | Use a specific compiler or linker wasm |
moxzi also supports Nat256 and Nat128, which moc doesn't. A program that doesn't use them builds with either compiler.
--force-gc exists in both but means different things. In moc it changes the generated code; in moxzi it makes the compiler collect its own garbage more often while building, and doesn't change the output.
dfx and mops#
To build with moxzi in a dfx project, build the module yourself and point dfx at it with a custom canister type:
{
"canisters": {
"backend": {
"type": "custom",
"build": "moxzi build src/backend/main.mo -o .dfx/backend.wasm",
"wasm": ".dfx/backend.wasm",
"candid": ".dfx/backend.did"
}
}
}
mops package management works unchanged. mops test still compiles with moc.