# gcc-mirror/gcc architecture

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

- Interactive diagram: https://gitdiagram.com/gcc-mirror/gcc
- Repository: https://github.com/gcc-mirror/gcc

## Overview

GCC is a multi-language compiler collection: users provide source and target/options, a language frontend analyzes it, shared compiler infrastructure represents and transforms the program, and target backends produce machine-specific output. The tree also exposes distinct Rust, C++ modules, and static-analyzer capabilities, plus language runtimes. The README identifies GCC and points to usage documentation but does not describe the compilation pipeline; broad workflow links are therefore marked unverified. Source-index references support the narrower links shown for sampled modules.

Main entry points: [`gcc/coretypes.h`](https://github.com/gcc-mirror/gcc/blob/master/gcc/coretypes.h) (Shared compiler core), [`gcc/c`](https://github.com/gcc-mirror/gcc/tree/master/gcc/c) (C frontend), [`gcc/rust/rust-session-manager.cc`](https://github.com/gcc-mirror/gcc/blob/master/gcc/rust/rust-session-manager.cc) (Rust compilation), [`gcc/target.h`](https://github.com/gcc-mirror/gcc/blob/master/gcc/target.h) (Target interface)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontends["Language frontends"]
  node_c_frontend["C frontend"]
  node_cfamily["C-family support<br/>[c-common.h]"]
  node_rust_session["Rust compilation"]
  node_algol_frontend["Algol 68 frontend"]
  node_cobol_frontend["COBOL frontend"]
  node_fortran_frontend["Fortran frontend<br/>[trans-expr.cc]"]
  node_modula_frontend["Modula-2 frontend"]
end

subgraph group_middle["Compiler core"]
  node_compiler_core["Shared compiler core<br/>[coretypes.h]"]
  node_call_graph["Call graph<br/>[cgraph.h]"]
  node_gimple["GIMPLE representation<br/>[gimple-iterator.h]"]
  node_optimization["Optimization infrastructure<br/>[fold-const.h]"]
  node_attributes["Attributes and pragmas<br/>[attribs.h]"]
  node_pointer_analysis["Pointer queries<br/>[pointer-query.cc]"]
end

subgraph group_targets["Target backends"]
  node_target_interface["Target interface<br/>[target.h]"]
  node_nds32_backend["NDS32 scheduling"]
end

subgraph group_analysis["Analysis and modules"]
  node_analyzer["Static analyzer<br/>[engine.cc]"]
  node_cpp_modules["C++ module mapper<br/>[mapper-client.cc]"]
  node_module_resolver["Module resolution server<br/>[server.cc]"]
end

subgraph group_runtime["Language runtime"]
  node_ada_runtime["Ada runtime<br/>[runtime.h]"]
  node_modula_storage["Modula-2 storage<br/>[GSysStorage.cc]"]
end

node_user(("Source and options"))
node_machine_output["Target machine output"]

node_user -.->|"provides source"| node_c_frontend
node_user -.->|"provides source"| node_rust_session
node_c_frontend -.->|"uses support"| node_cfamily
node_c_frontend -.->|"produces representation"| node_compiler_core
node_rust_session -.->|"compiles crate"| node_compiler_core
node_rust_session -->|"runs resolution"| node_compiler_core
node_compiler_core -.->|"uses graph"| node_call_graph
node_compiler_core -.->|"uses IR"| node_gimple
node_optimization -.->|"supports transforms"| node_compiler_core
node_attributes -->|"supports pragmas"| node_cfamily
node_pointer_analysis -->|"queries statements"| node_gimple
node_analyzer -->|"reads functions"| node_call_graph
node_cpp_modules -->|"uses resolver"| node_module_resolver
node_compiler_core -.->|"consults target"| node_target_interface
node_target_interface -.->|"configures scheduling"| node_nds32_backend
node_nds32_backend -.->|"schedules instructions"| node_machine_output
node_algol_frontend -.->|"compiles programs"| node_compiler_core
node_cobol_frontend -.->|"compiles programs"| node_compiler_core
node_fortran_frontend -.->|"lowers expressions"| node_compiler_core
node_modula_frontend -.->|"compiles programs"| node_compiler_core
node_modula_storage -.->|"allocates runtime memory"| node_user

click node_c_frontend "https://github.com/gcc-mirror/gcc/tree/master/gcc/c"
click node_cfamily "https://github.com/gcc-mirror/gcc/blob/master/gcc/c-family/c-common.h"
click node_rust_session "https://github.com/gcc-mirror/gcc/blob/master/gcc/rust/rust-session-manager.cc"
click node_algol_frontend "https://github.com/gcc-mirror/gcc/tree/master/gcc/algol68"
click node_cobol_frontend "https://github.com/gcc-mirror/gcc/tree/master/gcc/cobol"
click node_fortran_frontend "https://github.com/gcc-mirror/gcc/blob/master/gcc/fortran/trans-expr.cc"
click node_modula_frontend "https://github.com/gcc-mirror/gcc/tree/master/gcc/m2"
click node_compiler_core "https://github.com/gcc-mirror/gcc/blob/master/gcc/coretypes.h"
click node_call_graph "https://github.com/gcc-mirror/gcc/blob/master/gcc/cgraph.h"
click node_gimple "https://github.com/gcc-mirror/gcc/blob/master/gcc/gimple-iterator.h"
click node_optimization "https://github.com/gcc-mirror/gcc/blob/master/gcc/fold-const.h"
click node_attributes "https://github.com/gcc-mirror/gcc/blob/master/gcc/attribs.h"
click node_pointer_analysis "https://github.com/gcc-mirror/gcc/blob/master/gcc/pointer-query.cc"
click node_analyzer "https://github.com/gcc-mirror/gcc/blob/master/gcc/analyzer/engine.cc"
click node_cpp_modules "https://github.com/gcc-mirror/gcc/blob/master/gcc/cp/mapper-client.cc"
click node_module_resolver "https://github.com/gcc-mirror/gcc/blob/master/c%2B%2Btools/server.cc"
click node_target_interface "https://github.com/gcc-mirror/gcc/blob/master/gcc/target.h"
click node_nds32_backend "https://github.com/gcc-mirror/gcc/blob/master/gcc/config/nds32/nds32-pipelines-auxiliary.cc"
click node_ada_runtime "https://github.com/gcc-mirror/gcc/blob/master/gcc/ada/runtime.h"
click node_modula_storage "https://github.com/gcc-mirror/gcc/blob/master/gcc/m2/mc-boot/GSysStorage.cc"

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_c_frontend,node_cfamily,node_rust_session,node_algol_frontend,node_cobol_frontend,node_fortran_frontend,node_modula_frontend toneBlue
class node_compiler_core,node_call_graph,node_gimple,node_optimization,node_attributes,node_pointer_analysis toneAmber
class node_target_interface,node_nds32_backend toneMint
class node_analyzer,node_cpp_modules,node_module_resolver toneRose
class node_ada_runtime,node_modula_storage,node_user,node_machine_output toneIndigo
```

## Components

### Language frontends

- [C frontend](https://github.com/gcc-mirror/gcc/tree/master/gcc/c): `gcc/c`
- [C-family support](https://github.com/gcc-mirror/gcc/blob/master/gcc/c-family/c-common.h): `gcc/c-family/c-common.h`
- [Rust compilation](https://github.com/gcc-mirror/gcc/blob/master/gcc/rust/rust-session-manager.cc): `gcc/rust/rust-session-manager.cc`
- [Algol 68 frontend](https://github.com/gcc-mirror/gcc/tree/master/gcc/algol68): `gcc/algol68`
- [COBOL frontend](https://github.com/gcc-mirror/gcc/tree/master/gcc/cobol): `gcc/cobol`
- [Fortran frontend](https://github.com/gcc-mirror/gcc/blob/master/gcc/fortran/trans-expr.cc): `gcc/fortran/trans-expr.cc`
- [Modula-2 frontend](https://github.com/gcc-mirror/gcc/tree/master/gcc/m2): `gcc/m2`

### Compiler core

- [Shared compiler core](https://github.com/gcc-mirror/gcc/blob/master/gcc/coretypes.h): `gcc/coretypes.h`
- [Call graph](https://github.com/gcc-mirror/gcc/blob/master/gcc/cgraph.h): `gcc/cgraph.h`
- [GIMPLE representation](https://github.com/gcc-mirror/gcc/blob/master/gcc/gimple-iterator.h): `gcc/gimple-iterator.h`
- [Optimization infrastructure](https://github.com/gcc-mirror/gcc/blob/master/gcc/fold-const.h): `gcc/fold-const.h`
- [Attributes and pragmas](https://github.com/gcc-mirror/gcc/blob/master/gcc/attribs.h): `gcc/attribs.h`
- [Pointer queries](https://github.com/gcc-mirror/gcc/blob/master/gcc/pointer-query.cc): `gcc/pointer-query.cc`

### Target backends

- [Target interface](https://github.com/gcc-mirror/gcc/blob/master/gcc/target.h): `gcc/target.h`
- [NDS32 scheduling](https://github.com/gcc-mirror/gcc/blob/master/gcc/config/nds32/nds32-pipelines-auxiliary.cc): `gcc/config/nds32/nds32-pipelines-auxiliary.cc`

### Analysis and modules

- [Static analyzer](https://github.com/gcc-mirror/gcc/blob/master/gcc/analyzer/engine.cc): `gcc/analyzer/engine.cc`
- [C++ module mapper](https://github.com/gcc-mirror/gcc/blob/master/gcc/cp/mapper-client.cc): `gcc/cp/mapper-client.cc`
- [Module resolution server](https://github.com/gcc-mirror/gcc/blob/master/c%2B%2Btools/server.cc): `c++tools/server.cc`

### Language runtime

- [Ada runtime](https://github.com/gcc-mirror/gcc/blob/master/gcc/ada/runtime.h): `gcc/ada/runtime.h`
- [Modula-2 storage](https://github.com/gcc-mirror/gcc/blob/master/gcc/m2/mc-boot/GSysStorage.cc): `gcc/m2/mc-boot/GSysStorage.cc`

### Other components

- **Source and options**
- **Target machine output**

## Connections

- Source and options → C frontend: provides source
- Source and options → Rust compilation: provides source
- C frontend → C-family support: uses support
- C frontend → Shared compiler core: produces representation
- Rust compilation → Shared compiler core: compiles crate
- Rust compilation → Shared compiler core: runs resolution (evidence: `gcc/rust/rust-session-manager.cc`)
- Shared compiler core → Call graph: uses graph
- Shared compiler core → GIMPLE representation: uses IR
- Optimization infrastructure → Shared compiler core: supports transforms
- Attributes and pragmas → C-family support: supports pragmas (evidence: `gcc/c-family/c-pragma.cc`)
- Pointer queries → GIMPLE representation: queries statements (evidence: `gcc/pointer-query.cc`)
- Static analyzer → Call graph: reads functions (evidence: `gcc/analyzer/engine.cc`)
- C++ module mapper → Module resolution server: uses resolver (evidence: `gcc/cp/mapper-client.cc`)
- Shared compiler core → Target interface: consults target
- Target interface → NDS32 scheduling: configures scheduling (evidence: `gcc/config/nds32/nds32-pipelines-auxiliary.cc`)
- NDS32 scheduling → Target machine output: schedules instructions
- Algol 68 frontend → Shared compiler core: compiles programs (evidence: `gcc/algol68/a68-parser-pragmat.cc`)
- COBOL frontend → Shared compiler core: compiles programs
- Fortran frontend → Shared compiler core: lowers expressions
- Modula-2 frontend → Shared compiler core: compiles programs
- Modula-2 storage → Source and options: allocates runtime memory
