Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/junaire/jcc

Jun's C compiler from scratch.
https://github.com/junaire/jcc

c compiler cpp

Last synced: about 19 hours ago
JSON representation

Jun's C compiler from scratch.

Awesome Lists containing this project

README

        

# JCC: Jun's C compiler from scractch
```
___ ________ ________
|\ \|\ ____\|\ ____\
\ \ \ \ \___|\ \ \___|
__ \ \ \ \ \ \ \ \
|\ \\_\ \ \ \____\ \ \____
\ \________\ \_______\ \_______\
\|________|\|_______|\|_______|
```
**Please note this is just my little toy and could be abandoned any time**

## Build instruction

**Instructions below assume you use Ubtuntu22**

### Prerequisites
```bash
sudo apt install cmake clang ninja-build -y
pip3 install --user conan
```
### Build
```bash
mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \
-DCMAKE_EXPORT_COMPILE_COMMANDS=YES \
-DJCC_USE_ASAN=ON \
-GNinja ../ && ninja
```
`-DJCC_USE_ASAN=ON` means enable the address sanitizer, which might be helpful to catch some memory bugs.
### Run tests
```bash
ninja test
```

### Usage
> Note JCC is still in the very early stage, so don't expected it can handle everything correctly :)

- Dump the AST tree of the program.
```bash
./jcc test.c --ast-dump # Note you can only pass the flag in the end!
```
- Generate the assembly.
```bash
./jcc test.c # It will produce a.out
```