← Dispatch

I Cloned the Mojo Compiler 30 Minutes After It Went Open Source — Here's What's Inside

2026-08-18 · Dark Knight · 5 min read

Modular just dropped the full source of Mojo and the MAX framework under Apache 2.0 with LLVM Exceptions. This is the language they've been hyping for two years — the one that promises Python's ergonomics with C's speed, CUDA-level GPU control, and a compiler written in something that isn't Rust. I cloned the repo the minute it landed and went through the code. Here's what I found.

What Actually Landed

This isn't just Mojo. It's the full Modular monorepo: 341 MB, 10,536 files, one commit (pushed today). The commit message tells you everything:

$ git log --oneline
f66d4d5 [docs] Update README, contributing docs. (#6905)

One commit. Fresh push. No tags. This is day zero.

The repo contains four major components:

graph TD
    A[Modular Monorepo
341 MB / 10,536 files] --> B[KGEN Compiler] A --> C[Mojo Standard Library] A --> D[MAX Framework] A --> E[AsyncRT Runtime] B --> B1[25 MB C++ code] B --> B2[626 .cpp/.h/.td files] B --> B3[LLVM/MLIR-based] C --> C1[249 .mojo files] C --> C2[4.6 MB source] C --> C3[SIMD, collections,
complex, pathlib, etc.] D --> D1[163 MB total] D --> D2[GPU kernels in Mojo] D --> D3[Python inference server] D --> D4[Model pipelines] style A fill:#27272a,stroke:#a78bfa style B fill:#27272a,stroke:#52525b style C fill:#27272a,stroke:#52525b style D fill:#27272a,stroke:#52525b style E fill:#27272a,stroke:#52525b

The Compiler — KGEN

KGEN is 25 MB of C++ built on LLVM/MLIR (the TableGen files give it away). 626 source files. It's the compiler that takes Mojo down to machine code through LLVM's backend. This is not open for external contributions yet — Modular explicitly says so in the README.

The directory layout tells a story:

KGEN/
├── lib/       # 8.6 MB — compiler guts
│   ├── CODialect/     # Mojo's custom MLIR dialect
│   ├── LowerLIT/      # Lowering pipeline (IR translation)
│   └── Target/        # GPU/CPU target lowering
├── include/   # 2.0 MB — public headers
├── tools/     # CLI tooling
└── test/      # Compiler tests

CODialect is the Mojo-specific MLIR dialect — this is where the language's type system, ownership model, and async features live at the IR level. LowerLIT is the pipeline that translates from Mojo's high-level IR down to LLVM IR. This is the path from def add(a: Int, b: Int) -> Int to assembly.

The Standard Library — 249 Files

The stdlib is surprisingly mature for a language that's been effectively closed-source until today. 249 .mojo files, 4.6 MB of source. Here's what stands out:

Let me show you what Mojo actually looks like:

struct ComplexSIMD[dtype: DType, length: SIMDLength](
    Equatable, TrivialRegisterPassable, Writable, _Expable
):
    """Represents a complex SIMD value."""

    var re: Self.element_type
    var im: Self.element_type

    def __init__(out self, re: Self.element_type, im: Self.element_type = 0):
        self.re = self.im = re
        self.im = im

It reads like Python but with Swift-style generics ([...] for type parameters), value semantics (struct is an owned type), and trait conformance (Equatable, Writable). The out self parameter is a Rust-like borrow — the init consumes the uninitialized memory and produces a value.

The MAX Framework

This is the sleeper hit. 163 MB of production inference infrastructure:

The kernels directory alone tells you this isn't a toy. There are benchmarks for matmul, tests for GPU memory management, and an autotune framework for finding optimal kernel parameters.

What's Missing

Three things keep this from being a full open-source triumph:

  1. Compiler contributions — KGEN is not open for external PRs yet. You can read it, you can't change it.
  2. MAX license — the MAX framework ships under a separate Community License, not Apache 2.0. Usage and distribution are more restricted.
  3. Build friction — the repo uses Bazel with a wrapper script. Bootstrapping Mojo from source is not a one-command affair.

The Bottom Line

This is a serious release. The license (Apache 2.0 with LLVM Exceptions) is the most permissive option for a compiler — same as LLVM itself. You can take Mojo, embed it in a commercial product, compile it with proprietary extensions, and ship the binary with no strings attached.

For the first time, anyone can read how Mojo's MLIR dialect works, see how the stdlib is implemented, contribute fixes to the library, and understand what "Python speed with C performance" actually costs in compiler complexity. That's worth a lot more than a press release.

Sources: