Skip to content

Commit

Permalink
Add section for cranelift (#1523)
Browse files Browse the repository at this point in the history
Co-authored-by: BD103 <[email protected]>
Co-authored-by: bjorn3 <[email protected]>
  • Loading branch information
3 people authored Jul 7, 2024
1 parent 7bd5101 commit 9e63225
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions content/learn/quick-start/getting-started/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,37 @@ channel = "nightly"

For more information, see [The rustup book: Overrides](https://rust-lang.github.io/rustup/overrides.html#the-toolchain-file).

#### Cranelift

This uses a new nightly-only codegen that is about 30% faster at compiling than LLM.
It currently works best on Linux.

To install cranelift, run the following.
```
rustup component add rustc-codegen-cranelift-preview --toolchain nightly
```

To activate it for your project, add the following to your `.config/cargo.toml`.
```toml
[unstable]
codegen-backend = true

[profile.dev]
codegen-backend = "cranelift"

[profile.dev.package."*"]
codegen-backend = "llvm"
```

This enables faster compiles for your binary, but builds Bevy and other dependencies with the more-optimized LLVM backend. See the [cranelift setup guide](https://github.com/rust-lang/rustc_codegen_cranelift#download-using-rustup) for
details on other ways in which cranelift can be enabled. The installation process for Windows is a bit more involved. Consult the linked documentation for help.
MacOS builds can currently crash on Bevy applications, so you should still wait a bit before using cranelift on that system.

While cranelift is very fast to compile, the generated binaries are not optimized for speed. Additionally, it is generally still immature, so you may run into issues with it.
Notably, Wasm builds do not work yet.

When shipping your game, you should still compile it with LLVM.

#### Generic Sharing

Allows crates to share monomorphized generic code instead of duplicating it.
Expand Down

0 comments on commit 9e63225

Please sign in to comment.