All Projects → onehr → Crust

onehr / Crust

Licence: apache-2.0
C compiler toolchain in Rust. [WIP, early development stage]

Programming Languages

c
50402 projects - #5 most used programming language
rust
11053 projects
assembly
5116 projects

Projects that are alternatives of or similar to Crust

Ppci
A compiler for ARM, X86, MSP430, xtensa and more implemented in pure Python
Stars: ✭ 210 (+40%)
Mutual labels:  compiler, x86-64
Dora
Dora VM
Stars: ✭ 371 (+147.33%)
Mutual labels:  compiler, x86-64
Minijit
A basic x86-64 JIT compiler written from scratch in stock Python
Stars: ✭ 185 (+23.33%)
Mutual labels:  compiler, x86-64
Wag
WebAssembly compiler implemented in Go
Stars: ✭ 177 (+18%)
Mutual labels:  compiler, x86-64
Mir
A light-weight JIT compiler based on MIR (Medium Internal Representation)
Stars: ✭ 1,075 (+616.67%)
Mutual labels:  compiler, x86-64
Babygo
Go compiler made from scratch, which can compile itself. It's going to be the smallest and simplest go compiler in the world.
Stars: ✭ 143 (-4.67%)
Mutual labels:  compiler, x86-64
Asmjit
Machine code generation for C++
Stars: ✭ 2,874 (+1816%)
Mutual labels:  compiler, x86-64
Mazucc
A minimalist C compiler with x86_64 code generation
Stars: ✭ 437 (+191.33%)
Mutual labels:  compiler, x86-64
Mlml
self-hosted compiler for a subset of OCaml
Stars: ✭ 41 (-72.67%)
Mutual labels:  compiler, x86-64
Dynarmic
An ARM dynamic recompiler.
Stars: ✭ 475 (+216.67%)
Mutual labels:  compiler, x86-64
Pyast64
Compile a subset of the Python AST to x64-64 assembler
Stars: ✭ 93 (-38%)
Mutual labels:  compiler, x86-64
Jit Compiler
JIT compiler in Go
Stars: ✭ 70 (-53.33%)
Mutual labels:  compiler, x86-64
Peachpy
x86-64 assembler embedded in Python
Stars: ✭ 1,592 (+961.33%)
Mutual labels:  compiler, x86-64
Finkel
Haskell in S-expression
Stars: ✭ 146 (-2.67%)
Mutual labels:  compiler
Shaderc Rs
Rust bindings for the shaderc library.
Stars: ✭ 143 (-4.67%)
Mutual labels:  compiler
Sim C
A dynamically typed high-level front end for C
Stars: ✭ 145 (-3.33%)
Mutual labels:  compiler
Slang
SystemVerilog compiler and language services
Stars: ✭ 145 (-3.33%)
Mutual labels:  compiler
Assemblyscript
A TypeScript-like language for WebAssembly.
Stars: ✭ 13,152 (+8668%)
Mutual labels:  compiler
Lawvere
A categorical programming language with effects
Stars: ✭ 142 (-5.33%)
Mutual labels:  compiler
Emacs Cl
Common Lisp implemented in Emacs Lisp.
Stars: ✭ 140 (-6.67%)
Mutual labels:  compiler

CRUST

Build Status Gitter FOSSA Status GitHub commit activity GitHub

A simple C compiler written in the Rust-lang. (early development stage, started at Mar 30, 2019)

(PS. this is the development branch, if you want to see how to write a simple c compiler in rust, you should check branch toy, which contains a simple c compiler written in rust without extra libs, it can read simple c source code and produce x86-64 assembly code).

Project Goal

Should follow the C11 Standard and generate binary code from C source code.

This compiler is in the very early development stage, the plan is to continue developing it until it can compile real-world applications.

If you are interested in crust and want to contribute, feel free to join the Gitter chat room, we have already got some contributors now who are interested in building this project.

Milestone 0.1 Goal

  1. Finish the preprocessor.
  2. Support all C11 grammar rules.
  3. replace gcc with it's own assembler to generate binary code
  4. Stabilize the interfaces among different layers.
  5. With some possible optimizations.

Track of current progress

  • Preprocessor (working on)
    • [X] support #include "local-header", nested-include is supported (need to add more features)
    • [X] Trigraph translation
    • [X] comment support /**/ and //
    • [X] line concatenation with \
    • [X] object-like macro expansion
    • [X] function-like macro expansion
    • [ ] should support all directives (ifdef, elif, endif, ...)
  • Lexer (working on)
    • [X] lex all c11 keywords
    • [ ] the floating point number and number with postfix should be supported later.
  • Parser (almost done, need to be carefully tested)
    • [X] support c11 standard and generate ast tree
    • [ ] better ast printer
    • [ ] should be able handle typedef
    • [ ] add more tests for parser
  • Semantics Analyzer (working on)
    • [X] Type system
    • [ ] Type checker
  • Benchmark (working on)
    • [X] Use Criterion.rs to do benchmarks.
    • [ ] Generate more informations from benchmarking.
  • IR generator (TODO)
  • Optimizer (TODO)
  • Assembly code generator (TODO)
  • Code clean up
    • [ ] Remove #[allow(dead_code)]

Requirements

You need a valid rust environment, Cargo.

Build

(PS. Now the crust can only preprocess, lex, and parse the source code, the generator was disabled now).

$ cargo build # use this command to build the project

run

$ cargo run [FLAGS] <files> ...

Running Tests

Run:

$ ./test_dev.sh

Benchmark

(PS. This is pretty time consuming, cause benchmark will do lots of iterations to test different layers' performance.

Might take 20 to 30 minutes until it is finished. ) Run:

$ cargo bench

After it is finished, you can open target/criterion/report/index.html in your web browser to see the details of performance.

License

FOSSA Status

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].