# google/rune architecture

> Architecture diagram of the GitHub repository google/rune, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/google/rune
- Repository: https://github.com/google/rune

## Overview

Rune is an unfinished systems programming language whose compiler turns source modules into LLVM IR and can invoke Clang to produce an executable. The principal workflow parses modules, binds and checks language constructs, applies relationship-based memory management and iterator transformations, then generates LLVM. Its runtime provides arrays, I/O, and integer support for generated programs. A separate RPC generator parses and binds RPC definitions and emits C++ client/server support. The RPC flow and runtime feature links reflect the tree and sampled code; unsampled implementation details are not expanded.

Main entry points: [`src/main.c`](https://github.com/google/rune/blob/main/src/main.c) (Compiler driver), [`rpc/rpcgen_cc.c`](https://github.com/google/rune/blob/main/rpc/rpcgen_cc.c) (RPC generator), [`llvm/genllvm.c`](https://github.com/google/rune/blob/main/llvm/genllvm.c) (LLVM generation), [`runtime/runtime.c`](https://github.com/google/rune/blob/main/runtime/runtime.c) (Core runtime)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_compiler["Compiler front end"]
  node_driver["Compiler driver<br/>[main.c]"]
  node_parser["Module parser<br/>[parse.c]"]
  node_database[("Compiler model")]
  node_binder["Name and type binding"]
end

subgraph group_transform["Language transforms"]
  node_transforms["Code transforms<br/>[transformer.c]"]
  node_memory["Memory management<br/>[memmanage.c]"]
  node_iterators["Iterator inlining<br/>[iterator.c]"]
end

subgraph group_backend["Code generation"]
  node_llvmgen["LLVM generation<br/>[genllvm.c]"]
  node_llvmdecl["Runtime declarations<br/>[llvmdecls.c]"]
end

subgraph group_runtime["Runtime"]
  node_runtime["Core runtime<br/>[runtime.c]"]
  node_bigint["Big integer operations<br/>[bigint.c]"]
  node_io["I/O services<br/>[io.c]"]
end

subgraph group_rpc["RPC generation"]
  node_rpcgen["RPC generator<br/>[rpcgen_cc.c]"]
  node_rpcwire["RPC wire codecs<br/>[rpc_encoding.c]"]
end

node_programmer(("Rune programmer"))
node_source["Rune source"]
node_ir["LLVM IR"]
node_clang["Clang"]
node_executable["Rune executable"]
node_rpcdefs["RPC definitions"]
node_rpcoutput["Generated C++ RPC"]

node_programmer -->|"writes"| node_source
node_source -->|"compiles"| node_driver
node_driver -->|"parses modules"| node_parser
node_parser -->|"builds model"| node_database
node_driver -->|"binds"| node_binder
node_binder -->|"resolves symbols"| node_database
node_driver -->|"adds management"| node_memory
node_driver -->|"inlines iterators"| node_iterators
node_driver -->|"evaluates transforms"| node_transforms
node_driver -->|"generates code"| node_llvmgen
node_llvmgen -->|"declares runtime calls"| node_llvmdecl
node_llvmgen -->|"writes IR"| node_ir
node_driver -.->|"invokes optionally"| node_clang
node_ir -.->|"compiles"| node_clang
node_clang -.->|"produces"| node_executable
node_executable -->|"uses"| node_runtime
node_runtime -->|"delegates integers"| node_bigint
node_runtime -->|"provides I/O"| node_io
node_rpcdefs -->|"generates from"| node_rpcgen
node_rpcgen -->|"parses definitions"| node_parser
node_rpcgen -->|"binds definitions"| node_binder
node_rpcgen -->|"uses codecs"| node_rpcwire
node_rpcgen -->|"emits C++"| node_rpcoutput

click node_driver "https://github.com/google/rune/blob/main/src/main.c"
click node_parser "https://github.com/google/rune/blob/main/parse/parse.c"
click node_database "https://github.com/google/rune/tree/main/database"
click node_binder "https://github.com/google/rune/tree/main/bind"
click node_transforms "https://github.com/google/rune/blob/main/transformer/transformer.c"
click node_memory "https://github.com/google/rune/blob/main/transformer/memmanage.c"
click node_iterators "https://github.com/google/rune/blob/main/transformer/iterator.c"
click node_llvmgen "https://github.com/google/rune/blob/main/llvm/genllvm.c"
click node_llvmdecl "https://github.com/google/rune/blob/main/llvm/llvmdecls.c"
click node_runtime "https://github.com/google/rune/blob/main/runtime/runtime.c"
click node_bigint "https://github.com/google/rune/blob/main/runtime/bigint.c"
click node_io "https://github.com/google/rune/blob/main/runtime/io.c"
click node_rpcgen "https://github.com/google/rune/blob/main/rpc/rpcgen_cc.c"
click node_rpcwire "https://github.com/google/rune/blob/main/rpc/rpc_encoding.c"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_driver,node_parser,node_database,node_binder toneBlue
class node_transforms,node_memory,node_iterators toneAmber
class node_llvmgen,node_llvmdecl toneMint
class node_runtime,node_bigint,node_io toneRose
class node_rpcgen,node_rpcwire,node_programmer,node_source,node_ir,node_clang,node_executable,node_rpcdefs,node_rpcoutput toneIndigo
```

## Components

### Compiler front end

- [Compiler driver](https://github.com/google/rune/blob/main/src/main.c): `src/main.c`
- [Module parser](https://github.com/google/rune/blob/main/parse/parse.c): `parse/parse.c`
- [Compiler model](https://github.com/google/rune/tree/main/database): `database`
- [Name and type binding](https://github.com/google/rune/tree/main/bind): `bind`

### Language transforms

- [Code transforms](https://github.com/google/rune/blob/main/transformer/transformer.c): `transformer/transformer.c`
- [Memory management](https://github.com/google/rune/blob/main/transformer/memmanage.c): `transformer/memmanage.c`
- [Iterator inlining](https://github.com/google/rune/blob/main/transformer/iterator.c): `transformer/iterator.c`

### Code generation

- [LLVM generation](https://github.com/google/rune/blob/main/llvm/genllvm.c): `llvm/genllvm.c`
- [Runtime declarations](https://github.com/google/rune/blob/main/llvm/llvmdecls.c): `llvm/llvmdecls.c`

### Runtime

- [Core runtime](https://github.com/google/rune/blob/main/runtime/runtime.c): `runtime/runtime.c`
- [Big integer operations](https://github.com/google/rune/blob/main/runtime/bigint.c): `runtime/bigint.c`
- [I/O services](https://github.com/google/rune/blob/main/runtime/io.c): `runtime/io.c`

### RPC generation

- [RPC generator](https://github.com/google/rune/blob/main/rpc/rpcgen_cc.c): `rpc/rpcgen_cc.c`
- [RPC wire codecs](https://github.com/google/rune/blob/main/rpc/rpc_encoding.c): `rpc/rpc_encoding.c`

### Other components

- **Rune programmer**
- **Rune source**
- **LLVM IR**
- **Clang**
- **Rune executable**
- **RPC definitions**
- **Generated C++ RPC**

## Connections

- Rune programmer → Rune source: writes
- Rune source → Compiler driver: compiles
- Compiler driver → Module parser: parses modules
- Module parser → Compiler model: builds model
- Compiler driver → Name and type binding: binds
- Name and type binding → Compiler model: resolves symbols
- Compiler driver → Memory management: adds management
- Compiler driver → Iterator inlining: inlines iterators
- Compiler driver → Code transforms: evaluates transforms
- Compiler driver → LLVM generation: generates code
- LLVM generation → Runtime declarations: declares runtime calls
- LLVM generation → LLVM IR: writes IR
- Compiler driver → Clang: invokes optionally
- LLVM IR → Clang: compiles
- Clang → Rune executable: produces
- Rune executable → Core runtime: uses
- Core runtime → Big integer operations: delegates integers
- Core runtime → I/O services: provides I/O
- RPC definitions → RPC generator: generates from
- RPC generator → Module parser: parses definitions
- RPC generator → Name and type binding: binds definitions
- RPC generator → RPC wire codecs: uses codecs
- RPC generator → Generated C++ RPC: emits C++
