# Modern toolchain features (/docs/experiments/toolchain)

What a modern compiler toolchain is expected to have, how the best ones do it, and where marmot stands. "Have" means it works today, "partial" means a part works, "missing" means nothing exists. The evidence is from the code at main (cf0e9b27). The ranking at the end is by value to users against cost.

| Feature | Best practice | marmot | Evidence |
| --- | --- | --- | --- |
| Query-based incremental compilation | rustc (red-green query graph, salsa), Zig (incremental at declaration level) | partial | Package level: a dev build type checks and builds SSA only for packages whose module is not in the MLIR cache, the rest come from cached export data (internal/driver/incremental.go). No reuse below the package. |
| Fine-grained and remote cache | Bazel and Buck2 remote execution, sccache, Go's GOCACHEPROG | partial | A local content-addressed object and MLIR cache, every MARMOT_ switch in the key (internal/driver/stamp.go, cache.go). No remote or shared cache. |
| Parallel compilation at function level | rustc codegen units, LLVM ThinLTO backends, Go per package | have | Large packages split into parts of 40000 SSA instructions that generate and compile in parallel (internal/driver/parts.go, MARMOT_PART_INSTRS). |
| Reproducible and hermetic builds | Go (reproducible by default), Bazel (hermetic) | partial | -trimpath works, and two cold builds are byte-identical with MARMOT_PART_ORDER=1 (TestReproducibleBuild). Part order is off by default until its perfcmp passes, so default builds are not yet reproducible. |
| Cross compilation with sysroots | Go (GOOS and GOARCH, no sysroot for pure Go), Zig (bundled libc for every target) | have | -target, marmot sysroot fetches headers and libraries, -static with musl (cmd/marmot/sysroot.go, internal/driver/crosslink.go). |
| PGO, instrumented | Clang -fprofile-instr-generate, rustc -Cprofile-generate | have | --pgo-gen and --pgo with an indexed LLVM profile (internal/driver/driver.go). |
| PGO, sampling | Go default.pgo from pprof (2 to 14% in Go's reports), AutoFDO and BOLT | missing | No pprof or perf profile input. |
| LTO | ThinLTO (LLVM), whole-program in Go's linker for dead code | have | -release is whole-program optimization (WholeProgram.cpp, thinlink tests). |
| Sanitizers (address, thread, undefined) | Clang and Go -race (ThreadSanitizer), -asan, -msan | missing | No -race and no -fsanitize for Go code (sanitizer flags exist only in cgo flag checks). The runtime has debug modes (poison, gcstress) that find memory errors in the runtime. |
| Fuzzing | Go native fuzzing (go test -fuzz, coverage guided), libFuzzer, AFL++ | partial | marmot test passes flags to the test binary, but there is no coverage instrumentation for -fuzz. tests/fuzz is a compiler fuzzer (differential against gc), not user fuzzing. |
| Debug info and debugger | DWARF 5 for gdb, lldb and Delve, DAP for editors | missing | A dev build has no .debug sections. A pc table gives tracebacks with file:line (Pcln.cpp). No DWARF variables, no Delve or DAP support. |
| Language server | gopls, rust-analyzer (incremental, salsa) | partial | marmot check runs gopls's checks among others. marmot mcp serves the compiler's tools over the Model Context Protocol (cmd/marmot/mcp.go). No LSP server with marmot's own diagnostics, go to definition or rename. |
| Diagnostics, error recovery and fix-its | Rust and Elm diagnostics, Clang fix-its | have | Diagnostics with spans, codes (marmot explain), suggested fixes and marmot fix, JSON Lines output (internal/diag, internal/check/fix.go). |
| Formatter and linter | gofmt, go vet, staticcheck, clippy | have | marmot fmt (gofmt plus goimports) and marmot check (fmt, vet, lint, modernize, vuln, tidy, cross, deadcode). |
| Stable IR and plugin passes | MLIR dialects, LLVM pass plugins | partial | The go MLIR dialect is the IR of -release (--emit mlir), and the loop passes build as an LLVM pass plugin (backend/lib/Loops/Plugin.cpp). The dialect is not versioned or documented as stable. No plugin interface for user passes. |
| Wasm target | Go wasip1, Rust, Zig, TinyGo | have | -target wasip1/wasm with goroutines on Asyncify or JSPI, run in the browser playground. |
| GPU target | MLIR gpu dialect, CUDA, Triton, Mojo | partial | An NVPTX path in the backend and a GPU runtime (backend/lib/Driver/Gpu.cpp, runtime/core/gpu). Not a user-facing feature yet (SPEC M8 is the plan). |
| REPL and playground | Swift REPL, Jupyter kernels, Go playground | have | marmot repl, marmot play, and the docs playground that compiles and runs edited programs in the browser with no server. |
| Self-hosting | Go, Rust, Zig compile themselves | in progress | SPEC M7. The stage probe of tonight records the state (selfhost.md). |

## Ranking: top 10 of the missing and partial features [#ranking-top-10-of-the-missing-and-partial-features]

Value is for marmot users (Go developers who want faster and smaller binaries). Cost is rough engineering time.

1. **Debug info and a debugger (missing).** Value: high. A compiler people use for real work must let them step through code. DWARF line tables first (cheap: LLVM emits them from locations marmot already has), then variables and Delve or lldb support. Cost: medium for line tables, high for variables and goroutines.
2. **Race detector (missing).** Value: high. Go users run go test -race routinely, and marmot's concurrent GC and scheduler make races likely to matter. ThreadSanitizer instrumentation through LLVM plus runtime hooks. Cost: high.
3. **Reproducible builds by default (partial).** Value: high for releases, caches and trust. MARMOT_PART_ORDER=1 already gives byte-identical cold builds. It needs its perfcmp to pass, then a flip. Cost: low.
4. **Language server (partial).** Value: high for daily use: editors show marmot's own diagnostics (escape, allocation and verify findings) next to gopls. A thin LSP server that reuses marmot check and the diagnostics JSON. Cost: medium.
5. **Native fuzzing in marmot test (partial).** Value: medium to high. go test -fuzz needs coverage counters (LLVM SanitizerCoverage) and the testing package's fuzz engine. Cost: medium.
6. **Sampling PGO (missing).** Value: medium. Go's PGO guide reports about 2 to 14% from default.pgo. marmot has instrumented PGO, so a pprof to LLVM sample profile converter plus -fprofile-sample-use is the step. Cost: medium.
7. **Shared and remote cache (missing).** Value: medium for teams and CI: marmot's cold builds are slower than go's, so a shared cache helps more. A GOCACHEPROG-like protocol over the existing content-addressed cache. Cost: medium.
8. **Finer incremental compilation (partial).** Value: medium. Reuse below the package (per function or per part) for one-line edits in large packages. The parts already give a unit. Cost: high.
9. **Address and undefined behavior sanitizers for cgo code (missing).** Value: medium for users with C code. Clang's sanitizers on the C side plus runtime support. Cost: medium.
10. **A stable, documented go dialect and a pass plugin interface (partial).** Value: medium for research users and tooling. Version the dialect, document it, and load passes as plugins. Cost: medium.

These are not in the list, because marmot has them: function-level parallel compilation, cross compilation, instrumented PGO and LTO. Also diagnostics with fix-its, a formatter and linter, the wasm target, the REPL and the playground. GPU and self-hosting have their own milestones (SPEC M8 and M7).