A C compiler written in Rust.
- Implements both the frontend and the backend, with the LLVM IR as its intermediate representation
- A test bench is included and is run in Github actions
Note: this is a work in progress and currently only supports compilation of int-only programs with unary operators, binary operators, and direct return values.
- Python3 (for the test bench)
- Install Clang and lldb (used for preprocessing, linking, and for the test bench)
Tested on WSL2 only Preprocessing, executable generation from assembly code and linking are omitted for now. To compile a c file, do the following:
clang -E -P file.c -o file.i
./britten file.i
clang file.s -o file
On the linux distribution of your choice:
cargo build --release --target x86_64-unknown-linux-gnu
python3 test/test.py
- Writing a C compiler* from Nora Sandler
- Individual test cases come from the MIT-licensed companion test suite of the aforementioned book.