Table of Contents
ivcc (Project)
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:
#include <stdio.h> 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:
$ 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.
