Last active
May 14, 2026 11:41
-
-
Save janhohenheim/5731c11e91736bab5e9ef58c2a982c36 to your computer and use it in GitHub Desktop.
My global config.toml setup for ultra fast Rust compile times
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [unstable] | |
| codegen-backend = true | |
| [profile.dev] | |
| # Compile using cranelift for massively faster compilation | |
| codegen-backend = "cranelift" | |
| # If you want to attach a debugger, set `debug = true` instead | |
| debug = "line-tables-only" | |
| # Assuming we don't do `catch_unwind`, we can safely abort on panics for some extra perf | |
| panic = "abort" | |
| # Consider compiling deps with cranelift if you want cold-compilation to be faster | |
| # Or, if you want your hot compilation to have max performance, copy the contents of `[profile.dev.build-override]` here | |
| # The setting below is a happy medium between performance and cold compile time. | |
| [profile.dev.package."*"] | |
| codegen-backend = "llvm" | |
| # cranelift is always `panic = abort`, so you need to compile with llvm to get `#[should_panic]` working | |
| # See <https://github.com/rust-lang/rust/issues/32512> | |
| [profile.test.package."*"] | |
| codegen-backend = "llvm" | |
| # Enable optimizations for build scripts and proc-macros | |
| # This trades slower cold compilation for faster incremental compilation | |
| [profile.dev.build-override] | |
| codegen-backend = "llvm" | |
| codegen-units = 1 | |
| opt-level = 3 | |
| # Disable cranelift for release profile, | |
| # and trade some compile time for increased performance | |
| [profile.release] | |
| codegen-backend = "llvm" | |
| codegen-units = 1 | |
| # lto = "fat" has very diminishing returns on performance, but extremely high compile times | |
| # "thin" is good enough. | |
| lto = "thin" | |
| # Assuming we don't do `catch_unwind`, we can safely abort on panics for some extra perf | |
| panic = "abort" | |
| # 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] | |
| linker = "clang" | |
| rustflags = [ | |
| "-Clink-arg=--ld-path=wild", | |
| # Compile faster | |
| "-Zshare-generics=y", | |
| # 8 is the limit where parallelism overhead begins to dominate | |
| "-Zthreads=8", | |
| # optimize for the current CPU | |
| # remove this if you want to share the binary with others | |
| "-Ctarget-cpu=native", | |
| ] | |
| rustdocflags = [ | |
| # Compile faster | |
| "-Zshare-generics=y", | |
| # 8 is the limit where parallelism overhead begins to dominate | |
| "-Zthreads=8", | |
| ] | |
| [target.wasm32-unknown-unknown] | |
| rustflags = [ | |
| # Compile faster | |
| "-Zshare-generics=y", | |
| # 8 is the limit where parallelism overhead begins to dominate | |
| "-Zthreads=8", | |
| # optimize for the current CPU | |
| # remove this if you want to share the binary with others | |
| "-Ctarget-cpu=native", | |
| ] | |
| rustdocflags = [ | |
| # Compile faster | |
| "-Zshare-generics=y", | |
| # 8 is the limit where parallelism overhead begins to dominate | |
| "-Zthreads=8", | |
| ] |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Put the above in
~/.cargo/config.toml.Requires:
rustup default nightlyrustup component add rustc-codegen-cranelift-preview --toolchain nightlycargo install --locked wild-linkercargo install --git https://github.com/TheBevyFlock/bevy_cli --locked bevy_cliand assumes you run your apps with
bevy runandbevy run web -U multi-threading.Also make sure to enable the
dynamic_linkingfor Bevy!