Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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.
- Host: GitHub
- URL: https://github.com/junaire/jcc
- Owner: junaire
- Created: 2022-03-27T02:06:42.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2023-06-14T08:22:09.000Z (over 1 year ago)
- Last Synced: 2024-10-11T23:38:17.144Z (27 days ago)
- Topics: c, compiler, cpp
- Language: C++
- Homepage:
- Size: 396 KB
- Stars: 3
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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
```