Ask HN: Why rust cannot use the same compiler back end as mojo?
1–5 of 5 posts
Re: Ask HN: Why rust cannot use the same compiler back end as mojo?
#2Re: Ask HN: Why rust cannot use the same compiler back end as mojo?
#3Compiler backends require corresponding compiler frontends to do lexical analysis and parsing of the programming language into the intermediate representation (IR) that the backend accepts. The Rust compiler frontend currently lexes and compiles Rust source code into LLVM IR.
It is possible to create a Rust frontend that lexes and compiles into other intermediate representations and there are several related projects:
1) gccrs (https://github.com/Rust-GCC/gccrs) is creating a GCC frontend for Rust that can be used with the GCC backend.
2) Cranelift (https://cranelift.dev/) is creating an alternate LLVM IR-based backend for Rust written in Rust since the current LLVM backend is written in C++.
3) rustc_codegen_gcc (https://github.com/rust-lang/rustc_codegen_gcc) is creating a bridge between the Rust compiler LLVM IR frontend and the GCC backend.
So, while it is possible to create a Rust frontend to lex and parse Rust source code into MLIR I am not aware that anyone is working on it.
Re: Ask HN: Why rust cannot use the same compiler back end as mojo?
#4Not what you asked, though I just noticed Cranelift, an alt rust compiler. Not sure which advantage you're after, though variants are happening!