# ivcc (Project) **[ivcc](https://github.com/yanevskiv/ivcc)** is a project I built to compile C programs and follow them through assembly, linking, and execution. It's a C99 compiler toolchain for x86-64, written in C. The project includes the `ivcc` compiler driver, `ivas` assembler, `ivar` archiver, `ivld` linker, and `ivemu` emulator. The compiler preprocesses source files, parses declarations and expressions into an **abstract syntax tree**, performs semantic analysis, and generates x86-64 code. It can stop after preprocessing, write AT&T assembly text, produce a relocatable ELF object, or link a static executable. The assembler, archiver, and linker are also available as separate tools, so the intermediate stages can be inspected and used independently. The project provides startup code, a C standard library, and a mathematics library. Linux is the default runtime target. Programs can run natively on x86-64 Linux or under the emulator, which loads executable files and implements instruction execution and selected Linux system calls. A separate `ivemu` runtime target uses the emulator's memory-mapped devices. For example, this program uses the project's standard library to print a greeting: ```c #include int main(void) { puts("Hello from ivcc!"); return 0; } ``` After building the toolchain with `make`, compile `hello.c` and run it on x86-64 Linux: ```bash $ build/bin/ivcc hello.c -o hello $ ./hello Hello from ivcc! ``` The same executable can be run with `build/bin/ivemu hello`. Tests exercise several paths through the tools, including assembly output, archives, linking, and emulated execution. They also check diagnostics, language features, libraries, and compatibility with GNU tools. ## Concepts - [[ivcc-compiler-driver|Compiler driver]] - [[ivcc-compilation-pipeline|Compilation pipeline]] - [[ivcc-compilation-modes|Compilation modes]] - [[ivcc-runtime-targets|Runtime targets]] - [[ivcc-dependency-generation|Dependency generation]] - [[ivcc-preprocessing|Preprocessing]] - [[ivcc-macro-expansion|Macro expansion]] - [[ivcc-header-inclusion|Header inclusion]] - [[ivcc-conditional-compilation|Conditional compilation]] - [[ivcc-compiler-frontend|Compiler frontend]] - [[ivcc-lexical-analysis|Lexical analysis]] - [[ivcc-parsing|Parsing]] - [[ivcc-abstract-syntax-tree|Abstract syntax tree]] - [[ivcc-semantic-analysis|Semantic analysis]] - [[ivcc-name-resolution|Name resolution]] - [[ivcc-type-checking|Type checking]] - [[ivcc-constant-expressions|Constant expressions]] - [[ivcc-data-layout|Data layout]] - [[ivcc-code-generation|Code generation]] - [[ivcc-stack-frames|Stack frames]] - [[ivcc-calling-convention|Calling convention]] - [[ivcc-argument-passing|Argument passing]] - [[ivcc-return-values|Return values]] - [[ivcc-variadic-arguments|Variadic arguments]] - [[ivcc-control-flow|Control flow]] - [[ivcc-floating-point-operations|Floating-point operations]] - [[ivcc-assembler|Assembler]] - [[ivcc-assembly-syntax|Assembly syntax]] - [[ivcc-instruction-encoding|Instruction encoding]] - [[ivcc-labels|Labels]] - [[ivcc-elf-files|ELF files]] - [[ivcc-sections|Sections]] - [[ivcc-symbols|Symbols]] - [[ivcc-relocations|Relocations]] - [[ivcc-linker|Linker]] - [[ivcc-symbol-resolution|Symbol resolution]] - [[ivcc-section-placement|Section placement]] - [[ivcc-static-linking|Static linking]] - [[ivcc-relocatable-linking|Relocatable linking]] - [[ivcc-archiver|Archiver]] - [[ivcc-static-libraries|Static libraries]] - [[ivcc-archive-member-selection|Archive member selection]] - [[ivcc-runtime|Runtime]] - [[ivcc-program-startup|Program startup]] - [[ivcc-system-calls|System calls]] - [[ivcc-c-standard-library|C standard library]] - [[ivcc-mathematics-library|Mathematics library]] - [[ivcc-emulator|Emulator]] - [[ivcc-instruction-execution|Instruction execution]] - [[ivcc-program-loading|Program loading]] - [[ivcc-memory-mapped-devices|Memory-mapped devices]] - [[ivcc-linux-syscall-emulation|Linux syscall emulation]] - [[ivcc-signal-delivery|Signal delivery]] - [[ivcc-instruction-tracing|Instruction tracing]] - [[ivcc-testing|Testing]] - [[ivcc-toolchain-pipelines|Toolchain pipelines]] - [[ivcc-diagnostic-tests|Diagnostic tests]] - [[ivcc-regression-tests|Regression tests]] - [[ivcc-compatibility-checks|Compatibility checks]]