TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Ask HN: Why rust cannot use the same compiler back end as mojo?

3 pointsby rubiktubikabout 1 year ago
Mojo uses the new MLIR backend. This results in faster compilation times, for example. Rust uses LLVM as backend. Is it possible that rust also uses MLIR as backend and thus benefits from a modern backend?

3 comments

thesuperbigfrogabout 1 year ago
&gt;&gt; Is it possible that rust also uses MLIR as backend and thus benefits from a modern backend?<p>Compiler 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.<p>It is possible to create a Rust frontend that lexes and compiles into other intermediate representations and there are several related projects:<p>1) gccrs (<a href="https:&#x2F;&#x2F;github.com&#x2F;Rust-GCC&#x2F;gccrs">https:&#x2F;&#x2F;github.com&#x2F;Rust-GCC&#x2F;gccrs</a>) is creating a GCC frontend for Rust that can be used with the GCC backend.<p>2) Cranelift (<a href="https:&#x2F;&#x2F;cranelift.dev&#x2F;" rel="nofollow">https:&#x2F;&#x2F;cranelift.dev&#x2F;</a>) is creating an alternate LLVM IR-based backend for Rust written in Rust since the current LLVM backend is written in C++.<p>3) rustc_codegen_gcc (<a href="https:&#x2F;&#x2F;github.com&#x2F;rust-lang&#x2F;rustc_codegen_gcc">https:&#x2F;&#x2F;github.com&#x2F;rust-lang&#x2F;rustc_codegen_gcc</a>) is creating a bridge between the Rust compiler LLVM IR frontend and the GCC backend.<p>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.
remorsesabout 1 year ago
Mojo is faster because it compiles every function body in parallel, basically every function calls LLVM separately. This means you have to do everything else yourself, which is not easy.
illuminantabout 1 year ago
Not what you asked, though I just noticed Cranelift, an alt rust compiler. Not sure which advantage you&#x27;re after, though variants are happening!
评论 #39755312 未加载