Compiler's high-level structure graphThe Diagram below can be viewed with a Markdown editor with a Mermaid renderer, e.g. GitHub; IntelliJ + “Markdown” plugin + “Mermaid Visualizer” plugin; VS Code; etc.; or just https://mermaid.ai/live
Please improve it using Mermaid syntax:
1st compilation stage
C/ObjC Import
2nd compilation stage
Executables
KotlinSources
JavaSources
KLibDependencies
JARDependencies
MetadataDeserialization
Pre-serialization IR lowerings
FIRPlugins
IRPlugins
FIR2IR + Actualizer
IR lowerings: common and JVM-specific
FIRFrontend
CompilationSwitch
CSRC
DEF
CInterop
KLIB
KlibSerialization
KLibDeserialization
JAR
JVMBackend
IR lowerings: common and backend-specific
Native_Backend
JS Backend
WASM Backend
IR_Linking
CPU
STATIC
JS
WASM_JS
WASM_WASI
Diagram Explanation:1st Compilation Stage (sources+dependencies -> Jar or KLib) :
Begins with input source code and JAR/Klib dependencies Applies various stages of the compilation pipeline within Kotlin, leading to a .jar or .klib as output for the module. 2nd Compilation Stage (KLibs -> executable artifact or library cache) for Native , JS, WASM backends :
Deserializes/links KLibs Performs numerous IR lowerings. Converts IR to backend-specific representation. Generates an executable artifact.