moxzi
Docs / CLI / Coming from moc

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#

mocmoxzi build
Candid interface (.did)Only with --idlAlways written; --no-idl turns it off
debug { … } blocksKept (--debug is the default)Dropped. Pass --debug to keep them. There is no --release flag
candid:service, candid:args metadataPrivatePublic, as dfx sets them. --public-metadata replaces this default
Packages--package flagsRead from mops.toml through mops sources; --package adds to them
PersistenceEnhanced orthogonal persistenceEnhanced orthogonal persistence
persistent actorEvery actor is persistent; the keyword warns M0217Same

Flags that work the same#

mocmoxzi 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 NAMEsame
--implicit-derivation-depth Nsame
--stable-regionssame
--max-stable-pages Nsame
--stabilization-instruction-limit Nsame
-measure-rts-stack--measure-rts-stack (two dashes)

Flags that became subcommands#

mocmoxzi
--stable-compatible PRE POSTmoxzi stable-compatible PRE POST
--print-deps FILEmoxzi deps FILE. Lists every file in the build, not only direct imports

moc features moxzi doesn't have#

mocAlternative
-r, -i, -iR, -t (interpreter, REPL, tracing)Run the actor with moxzid
--checkBuild and discard the output
--explain, --error-format, --error-detail, --error-recovery, --ai-errors, --print-source-on-errorNone. Errors are plain text in moc's default format
-Werror, --hide-warnings, --warn-helpUse -E with specific codes
--actor-idl, --actor-alias, --actor-id-alias, --actor-env-aliasImport the interface with idl: and create the reference with actor "…". See Importing a Candid interface
-g, --mapNone
-wasi-system-apiNone
--args FILEUse shell expansion

moxzi additions#

OptionPurpose
--no-linkWrite an unlinked module (moc 2.0 removed -no-link)
--gzipAlso write a gzipped module
--compact-rtsSmaller heap, for moxzid and moxzi-web
--stack-budget N, --progress N, --status-secs S, --timingsControl and observe long builds
--remote URL --canister IDBuild on-chain
--root DIRSet the project directory
--compiler, --linkerUse 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.

On this pageThe commandDefaults that differFlags that work the sameFlags that became subcommandsmoc features moxzi doesn't havemoxzi additionsdfx and mops