Compiler reference
The Motoko compiler (moc) is the primary tool for compiling Motoko programs into executable WebAssembly (Wasm) modules.
The compiler runs in the background when you build projects using the DFINITY Canister SDK.
If you invoke the compiler directly on the command-line, you can press CTRL-C to exit.
This section provides compiler command-line reference information.
moc
Use the Motoko compiler (moc) to compile Motoko programs into executable WebAssembly (Wasm) modules.
Options
You can use the following options with the moc command.
| Option | Description |
|---|---|
|
Specifies a path to actor IDL (Candid) files. |
|
Specifies an actor import alias. |
|
Read additional newline separated command line arguments from <file> |
|
Read additional NUL separated command line arguments from <file> |
|
Compile to WebAssembly. |
|
Performs type checking only. |
|
Link with compacting GC instead of copying GC. |
|
Respects debug expressions in the source (the default). |
|
Set level of error message detail for syntax errors, n in [0..3] (default 2). |
|
Displays usage information. |
|
Hides compiler warnings. |
|
Treat warnings as errors. |
|
Generates the interface description language specification. |
|
Runs the compiler in an interactive read–eval–print loop (REPL) shell so you can evaluate program execution (implies -r). |
|
Outputs a Javascript source map. |
|
Disables system API imports. |
|
Specifies the output file. |
|
Sets the print depth. |
|
Specifies a package-name package-path pair, separated by a space. |
|
Prints the dependencies for a given source file. |
|
Interprets programs. |
|
Ignores debug expressions in the source. |
|
Activates tracing in interpreter. |
|
Generates verbose output. |
|
Displays version information. |
|
Uses the WASI system API (wasmtime). |