Skip to content

Instantly share code, notes, and snippets.

@janhohenheim
Last active October 5, 2025 03:20
Show Gist options
  • Save janhohenheim/5731c11e91736bab5e9ef58c2a982c36 to your computer and use it in GitHub Desktop.
Save janhohenheim/5731c11e91736bab5e9ef58c2a982c36 to your computer and use it in GitHub Desktop.
My global config.toml setup for ultra fast Rust compile times
[unstable]
codegen-backend = true
[profile.dev]
# Compile using cranelift for massively faster compilation
codegen-backend = "cranelift"
# If you want to attach a debugger, set this to true
debug = "line-tables-only"
# Consider compiling deps with cranelift if you want cold-compilation to be faster
[profile.dev.package."*"]
codegen-backend = "llvm"
# cranelift is `panic = abort`, so you need to compile with llvm to get `#[should_panic]` working
[profile.test.package."*"]
codegen-backend = "llvm"
# Disable cranelift for release profile
[profile.release]
codegen-backend = "llvm"
# cranelift cannot build wasm32-unknown-unknown out of the box
[profile.web]
codegen-backend = "llvm"
[build]
# Using a global target dir allows all projects to share incremental compilation results,
# vastly speeding up cold-compilation of new projects.
target-dir = "/home/hhh/.cargo/global-target"
[target.x86_64-unknown-linux-gnu]
rustflags = [
# Compile faster
"-Zshare-generics=y",
"-Zthreads=8",
]
rustdocflags = [
# Compile faster
"-Zshare-generics=y",
"-Zthreads=8",
]
[target.wasm32-unknown-unknown]
rustflags = [
# Improve performance
"--cfg",
"web_sys_unstable_apis",
"-Ctarget-feature=+sign-ext,+nontrapping-fptoint",
# Compile faster
"-Zshare-generics=y",
"-Zthreads=8",
]
rustdocflags = [
# Compile faster
"-Zshare-generics=y",
"-Zthreads=8",
]
@janhohenheim
Copy link
Author

janhohenheim commented May 20, 2025

Put the above in ~/.cargo/config.toml.
Requires:

  • Linux
  • nightly: rustup default nightly
  • cranelift: rustup component add rustc-codegen-cranelift-preview --toolchain nightly
  • Bevy CLI: cargo install --git https://github.com/TheBevyFlock/bevy_cli --locked bevy_cli

and assumes you run your apps with bevy run and bevy run web -U multi-threading

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment