IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /docs/manual/basics.md). For the complete Mojo documentation index, see llms.txt.
Skip to main content
Version: 1.0.0b1
For the complete Mojo documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /docs/manual/basics.md).

compile

Provides utilities for compiling and inspecting Mojo code.

This module contains functionality for compiling Mojo functions and examining their assembly, LLVM IR, or object code output. It is particularly useful for kernel engineers who want to inspect the low-level implementation details of specific functions without dealing with entire files or manual invocation of compilation tools.

Key features:

  • Compile individual functions to assembly, LLVM IR, or object code
  • Get linkage names and module information
  • Inspect number of captures and other function metadata
  • Write compilation output to files
  • Control compilation options and targets

Example:

from std.compile import compile_info

def my_func(x: Int) -> Int:
return x

# Get assembly for the function
info = compile_info[my_func]()
print(info)

Structs

Functions

  • compile_info: Compiles a function and returns detailed compilation information.