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
27 changes: 27 additions & 0 deletions content/learn/quick-start/getting-started/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,33 @@ 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.

To install cranelift on Linux or macOS, 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

# Replace `my_program` with the name of your binary.
[profile.dev.package.my_program]
codegen-backend = "cranelift"
janhohenheim marked this conversation as resolved.
Show resolved Hide resolved
```

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?tab=readme-ov-file#download-using-rustup) for
janhohenheim marked this conversation as resolved.
Show resolved Hide resolved
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.
Note that cranelift [currently does not build Bevy on macOS](https://github.com/rust-lang/rustc_codegen_cranelift/issues/1504).
janhohenheim marked this conversation as resolved.
Show resolved Hide resolved


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.
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