Cranelift backend for rustc
You can also read the complete discussion in our zulip-archive.
Pre-meeting details and agenda outline
Overview of the Cranelift backend
Cranelift is a code generation backend written in Rust which is under development for use in WebAssembly compilers.
As such, it could potentially improve compilation times in
rustc because it is optimized for efficiently generating code rather than generating efficient code.
Over the past ~1.5 years, @bjorn3 has been working on writing a Cranelift-based code generation backend for
cg_cranelift for short.
It is currently complete enough to compile many programs and is usually faster at compiling them than the regular LLVM backend.
The main goal of this project is to build an alternative codegen backend that can be used for faster, non-optimized (debug) builds.
rustc has support for runtime-pluggable backends via the unstable
cg_cranelift is developed in a separate repository from the Rust project, so it uses this flag to plug into
cg_cranelift also takes advantage of an internal
rustc library called
rustc_codegen_ssa which tries to be a backend-agnostic code generation support library but some parts of it are still very LLVM-like.
At this time, we want to help increase the support
cg_cranelift gets but it isn’t a top priority for us currently.
The eventual goal seems to be first-class support for
cg_cranelift alongside our existing LLVM backend but that won’t happen for a while so we can afford to take small, measured steps in the meantime.
A few things we would like to do now:
rustc_codegen_ssato be less LLVM-like and allow
cg_craneliftto re-use more of the code.
rustrepo (probably via
git-subtree) and require it to build during CI.
- This is similar to the support we give to tools like clippy or miri.
Add a way in our testing infrastructure to mark tests as reliant on a specific codegen backend and annotate existing tests that require LLVM.
Add a way to manually run tests with
cg_craneliftto Rustbuild (aka
We may also want to do these soon but we need additional discussion:
Run tests in
cg_craneliftmode and notify if they failed (but don’t gate CI on it).
Form a working group related to