Skip to main content
Log in

Mojo module

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 compile import compile_info

fn my_func():
print("Hello")

# Get assembly for the function
info = compile_info[my_func]()
print(info.asm)
    from compile import compile_info

fn my_func():
print("Hello")

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

Structs

  • Info: Contains compilation information and results for a function.

Functions

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