Version: 1.1.0

Compilation targets

You can compile Mojo for a machine other than the one you are typing on. The target selects architecture, CPU features, and accelerator.

Essentials

  • mojo build produces a native executable.
  • Target triples distinguish operating system and CPU.
  • GPU compilation is requested by the kernel's target parameter, not by a second language.
  • Cross compilation still needs a linker and libraries for the destination.
  • Feature macros let one source keep portable and tuned paths.

Example

$ mojo build hello.mojo -o hello

Keep in mind

Compile on the oldest CPU you need to support, or set the target explicitly, so you do not emit instructions the machine cannot run.