Hacker News new | ask | show | jobs
by kalnins 1522 days ago
As Rust is llvm based, you don't need to compile it to C. Just write a backend that translates LLVM IR to C instead of x86_64. The IR is very C looking, it's probably overly complex.

Compiling down to asm, lot of information is lost regarding memory layout etc, so it's not the best source for generating code.

2 comments

https://github.com/JuliaComputingOSS/llvm-cbe

edit: you also have mrustc as a Rust to C compiler outright.

Hey, LLVM to C is what Rellic does! https://github.com/lifting-bits/rellic