# espressif/crosstool-ng architecture

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

- Interactive diagram: https://gitdiagram.com/espressif/crosstool-ng
- Repository: https://github.com/espressif/crosstool-ng

## Overview

Crosstool-NG is a configurable cross-toolchain builder: users select a target and toolchain components, then invoke its make-based interface to produce a toolchain. The tree shows Kconfig front ends and configuration definitions, plus package metadata for supported compilers, binutils, kernels, C libraries, and utilities. The README confirms the toolchain-building purpose but does not document the runtime build sequence in detail; those links are therefore marked unverified. The sampled Kconfig sources support the configuration-editor and symbol/expression layers.

Main entry points: [`ct-ng.in`](https://github.com/espressif/crosstool-ng/blob/esp-1.28.x/ct-ng.in) (ct-ng interface), [`kconfig/menu.c`](https://github.com/espressif/crosstool-ng/blob/esp-1.28.x/kconfig/menu.c) (Menu model), [`config/config.in`](https://github.com/espressif/crosstool-ng/blob/esp-1.28.x/config/config.in) (Configuration choices), [`kconfig/conf.c`](https://github.com/espressif/crosstool-ng/blob/esp-1.28.x/kconfig/conf.c) (Config editor)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_userflow["Toolchain workflow"]
  node_ctng["ct-ng interface<br/>[ct-ng.in]"]
  node_output["Built toolchain"]
end

subgraph group_config["Configuration"]
  node_configdefs["Configuration choices<br/>[config.in]"]
  node_targetopts["Target options<br/>[target.in]"]
  node_archopts["Architecture options"]
  node_componentopts["Component options"]
end

subgraph group_build["Toolchain components"]
  node_pkgmeta["Package metadata"]
  node_binutils["Binutils"]
  node_compiler["Compiler"]
  node_kernel["Target kernel"]
  node_libc["Target C library"]
  node_debugtools["Debug tools"]
  node_hosttools["Build tools"]
end

subgraph group_kconfig["Kconfig engine"]
  node_conf["Config editor<br/>[conf.c]"]
  node_mconf["Menu editor<br/>[mconf.c]"]
  node_nconf["Text editor<br/>[nconf.c]"]
  node_configio["Config persistence<br/>[confdata.c]"]
  node_menu["Menu model<br/>[menu.c]"]
  node_symbols["Symbol evaluation<br/>[symbol.c]"]
  node_expressions["Expression engine<br/>[expr.c]"]
  node_preprocess["Config preprocessing<br/>[preprocess.c]"]
  node_dialog["Terminal dialogs"]
end

node_user(("Toolchain user"))

node_user -->|"invokes"| node_ctng
node_ctng -.->|"configures"| node_configdefs
node_configdefs -.->|"offers"| node_targetopts
node_targetopts -.->|"selects"| node_archopts
node_configdefs -.->|"offers"| node_componentopts
node_configdefs -.->|"defines"| node_conf
node_conf -.->|"reads config"| node_configio
node_conf -.->|"parses menus"| node_menu
node_mconf -->|"edits menus"| node_menu
node_nconf -->|"edits menus"| node_menu
node_mconf -->|"renders dialogs"| node_dialog
node_menu -.->|"uses symbols"| node_symbols
node_symbols -->|"evaluates dependencies"| node_expressions
node_preprocess -.->|"prepares config"| node_menu
node_configio -.->|"stores values"| node_symbols
node_ctng -.->|"uses package choices"| node_pkgmeta
node_ctng -.->|"builds"| node_binutils
node_ctng -.->|"builds"| node_compiler
node_ctng -.->|"builds"| node_kernel
node_ctng -.->|"builds"| node_libc
node_ctng -.->|"builds"| node_debugtools
node_ctng -.->|"uses"| node_hosttools
node_ctng -.->|"produces"| node_output

click node_ctng "https://github.com/espressif/crosstool-ng/blob/esp-1.28.x/ct-ng.in"
click node_configdefs "https://github.com/espressif/crosstool-ng/blob/esp-1.28.x/config/config.in"
click node_targetopts "https://github.com/espressif/crosstool-ng/blob/esp-1.28.x/config/target.in"
click node_archopts "https://github.com/espressif/crosstool-ng/tree/esp-1.28.x/config/arch"
click node_componentopts "https://github.com/espressif/crosstool-ng/tree/esp-1.28.x/config"
click node_conf "https://github.com/espressif/crosstool-ng/blob/esp-1.28.x/kconfig/conf.c"
click node_mconf "https://github.com/espressif/crosstool-ng/blob/esp-1.28.x/kconfig/mconf.c"
click node_nconf "https://github.com/espressif/crosstool-ng/blob/esp-1.28.x/kconfig/nconf.c"
click node_configio "https://github.com/espressif/crosstool-ng/blob/esp-1.28.x/kconfig/confdata.c"
click node_menu "https://github.com/espressif/crosstool-ng/blob/esp-1.28.x/kconfig/menu.c"
click node_symbols "https://github.com/espressif/crosstool-ng/blob/esp-1.28.x/kconfig/symbol.c"
click node_expressions "https://github.com/espressif/crosstool-ng/blob/esp-1.28.x/kconfig/expr.c"
click node_preprocess "https://github.com/espressif/crosstool-ng/blob/esp-1.28.x/kconfig/preprocess.c"
click node_dialog "https://github.com/espressif/crosstool-ng/tree/esp-1.28.x/kconfig/lxdialog"
click node_pkgmeta "https://github.com/espressif/crosstool-ng/tree/esp-1.28.x/packages"
click node_binutils "https://github.com/espressif/crosstool-ng/tree/esp-1.28.x/config/binutils"
click node_compiler "https://github.com/espressif/crosstool-ng/tree/esp-1.28.x/config/cc"
click node_kernel "https://github.com/espressif/crosstool-ng/tree/esp-1.28.x/config/kernel"
click node_libc "https://github.com/espressif/crosstool-ng/tree/esp-1.28.x/config/libc"
click node_debugtools "https://github.com/espressif/crosstool-ng/tree/esp-1.28.x/config/debug"
click node_hosttools "https://github.com/espressif/crosstool-ng/tree/esp-1.28.x/config/comp_tools"

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_ctng,node_output,node_user toneBlue
class node_configdefs,node_targetopts,node_archopts,node_componentopts toneAmber
class node_pkgmeta,node_binutils,node_compiler,node_kernel,node_libc,node_debugtools,node_hosttools toneMint
class node_conf,node_mconf,node_nconf,node_configio,node_menu,node_symbols,node_expressions,node_preprocess,node_dialog toneRose
```

## Components

### Toolchain workflow

- [ct-ng interface](https://github.com/espressif/crosstool-ng/blob/esp-1.28.x/ct-ng.in): `ct-ng.in`
- **Built toolchain**

### Configuration

- [Configuration choices](https://github.com/espressif/crosstool-ng/blob/esp-1.28.x/config/config.in): `config/config.in`
- [Target options](https://github.com/espressif/crosstool-ng/blob/esp-1.28.x/config/target.in): `config/target.in`
- [Architecture options](https://github.com/espressif/crosstool-ng/tree/esp-1.28.x/config/arch): `config/arch`
- [Component options](https://github.com/espressif/crosstool-ng/tree/esp-1.28.x/config): `config`

### Toolchain components

- [Package metadata](https://github.com/espressif/crosstool-ng/tree/esp-1.28.x/packages): `packages`
- [Binutils](https://github.com/espressif/crosstool-ng/tree/esp-1.28.x/config/binutils): `config/binutils`
- [Compiler](https://github.com/espressif/crosstool-ng/tree/esp-1.28.x/config/cc): `config/cc`
- [Target kernel](https://github.com/espressif/crosstool-ng/tree/esp-1.28.x/config/kernel): `config/kernel`
- [Target C library](https://github.com/espressif/crosstool-ng/tree/esp-1.28.x/config/libc): `config/libc`
- [Debug tools](https://github.com/espressif/crosstool-ng/tree/esp-1.28.x/config/debug): `config/debug`
- [Build tools](https://github.com/espressif/crosstool-ng/tree/esp-1.28.x/config/comp_tools): `config/comp_tools`

### Kconfig engine

- [Config editor](https://github.com/espressif/crosstool-ng/blob/esp-1.28.x/kconfig/conf.c): `kconfig/conf.c`
- [Menu editor](https://github.com/espressif/crosstool-ng/blob/esp-1.28.x/kconfig/mconf.c): `kconfig/mconf.c`
- [Text editor](https://github.com/espressif/crosstool-ng/blob/esp-1.28.x/kconfig/nconf.c): `kconfig/nconf.c`
- [Config persistence](https://github.com/espressif/crosstool-ng/blob/esp-1.28.x/kconfig/confdata.c): `kconfig/confdata.c`
- [Menu model](https://github.com/espressif/crosstool-ng/blob/esp-1.28.x/kconfig/menu.c): `kconfig/menu.c`
- [Symbol evaluation](https://github.com/espressif/crosstool-ng/blob/esp-1.28.x/kconfig/symbol.c): `kconfig/symbol.c`
- [Expression engine](https://github.com/espressif/crosstool-ng/blob/esp-1.28.x/kconfig/expr.c): `kconfig/expr.c`
- [Config preprocessing](https://github.com/espressif/crosstool-ng/blob/esp-1.28.x/kconfig/preprocess.c): `kconfig/preprocess.c`
- [Terminal dialogs](https://github.com/espressif/crosstool-ng/tree/esp-1.28.x/kconfig/lxdialog): `kconfig/lxdialog`

### Other components

- **Toolchain user**

## Connections

- Toolchain user → ct-ng interface: invokes (evidence: `README.md`)
- ct-ng interface → Configuration choices: configures
- Configuration choices → Target options: offers
- Target options → Architecture options: selects
- Configuration choices → Component options: offers
- Configuration choices → Config editor: defines
- Config editor → Config persistence: reads config
- Config editor → Menu model: parses menus
- Menu editor → Menu model: edits menus (evidence: `kconfig/mconf.c`)
- Text editor → Menu model: edits menus (evidence: `kconfig/nconf.c`)
- Menu editor → Terminal dialogs: renders dialogs (evidence: `kconfig/mconf.c`)
- Menu model → Symbol evaluation: uses symbols
- Symbol evaluation → Expression engine: evaluates dependencies (evidence: `kconfig/symbol.c`)
- Config preprocessing → Menu model: prepares config
- Config persistence → Symbol evaluation: stores values
- ct-ng interface → Package metadata: uses package choices
- ct-ng interface → Binutils: builds
- ct-ng interface → Compiler: builds
- ct-ng interface → Target kernel: builds
- ct-ng interface → Target C library: builds
- ct-ng interface → Debug tools: builds
- ct-ng interface → Build tools: uses
- ct-ng interface → Built toolchain: produces
