mojo build
Builds an executable from a Mojo file.
Synopsis
mojo build [options] <path>
mojo build [options] <path>
Description
Compiles the Mojo file at the given path into an executable.
By default, the executable is saved to the current directory and named the same as the input file, but without a file extension.
Beware that any Python libraries used in your Mojo project are not included in the executable binary, so they must be provided by the environment where you run the executable.
Options
Output options
-o <PATH>
Sets the path and filename for the executable output. By default, it outputs the executable to the same location as the Mojo file, with the same name and no extension.
Compilation options
--optimization-level <LEVEL>
, -O
, --no-optimization (LEVEL=0)
Sets the level of optimization to use at compilation. The value must be a number between 0 and 3. The default is 3.
-I <PATH>
Appends the given path to the list of directories to search for imported Mojo files.
-D <KEY=VALUE>
Defines a named value that can be used from within the Mojo source file being executed. For example, -D foo=42
defines a name foo
that, when queried with the sys.param_env
module from within the Mojo program, would yield the compile-time value 42
.
--debug-level <LEVEL>
, -g (LEVEL=full)
Sets the level of debug info to use at compilation. The value must be one of: none
(the default value), line-tables
, or full
. Please note that there are issues when generating debug info for some Mojo programs that have yet to be addressed.
Target options
--target-triple <TRIPLE>
Sets the compilation target triple. Defaults to the host target.
--target-cpu <CPU>
Sets the compilation target CPU. Defaults to the host CPU.
--target-features <FEATURES>
Sets the compilation target CPU features. Defaults to the host features.
--march <ARCHITECTURE>
Sets the architecture for which to generate code.
--mcpu <CPU>
Sets the CPU for which to generate code.
--mtune <TUNE>
Sets the CPU for which to tune code.