Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add section for cranelift #1523

Merged
merged 10 commits into from
Jul 7, 2024
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]
janhohenheim marked this conversation as resolved.
Show resolved Hide resolved
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