bevy-website icon indicating copy to clipboard operation
bevy-website copied to clipboard

added section on cranelift codegen

Open MalekiRe opened this issue 1 year ago • 2 comments

MalekiRe avatar Nov 04 '23 03:11 MalekiRe

Idk how big of a deal it is, but the configuration the blog post this PR suggests doesn't work in projects that need to support Wasm. This is because per-target profiles aren't supported by Rust You could create a new profile to handle this but then you have to specify the profile every time.

Instead it might be ideal to use rustflags for this as they can be specified per platform. Making cranelift still be used for linux but not for Wasm builds:

Cranelift

rustup component add rustc-codegen-cranelift-preview --toolchain nightly

~/.cargo/config.toml

[target.x86_64-unknown-linux-gnu]
rustflags = ["-Zcodegen-backend=cranelift", ]

Cranelift + Mold

~/.cargo/config.toml

[target.x86_64-unknown-linux-gnu]
rustflags = ["-Zcodegen-backend=cranelift", "-C", "link-arg=-fuse-ld=/usr/bin/mold"]
linker = "clang"

Thanks to this blog post for helping me discover this as an option: https://benw.is/posts/how-i-improved-my-rust-compile-times-by-seventy-five-percent

paul-hansen avatar Nov 09 '23 05:11 paul-hansen

Though you wouldn't want to start shipping builds compiled with cranelift (for performance reasons) so maybe it's not a good idea to recommend that as it isn't limited to dev builds and people might forget to take it out. Personally I do my release builds in github actions so that wasn't a concern for me.

paul-hansen avatar Nov 09 '23 06:11 paul-hansen

@MalekiRe if you rebase this I'll merge it in :)

alice-i-cecile avatar May 05 '24 22:05 alice-i-cecile

Closing in favor of #1523

janhohenheim avatar Jul 04 '24 18:07 janhohenheim