Skip to content

Improving compile times for the editor #210

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

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
180 changes: 180 additions & 0 deletions .cargo/config_fast_builds.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
# Copy this file to `config.toml` to speed up your builds.
#
# # Faster linker
#
# One of the slowest aspects of compiling large Rust programs is the linking time. This file configures an
# alternate linker that may improve build times. When choosing a new linker, you have two options:
#
# ## LLD
#
# LLD is a linker from the LLVM project that supports Linux, Windows, macOS, and Wasm. It has the greatest
# platform support and the easiest installation process. It is enabled by default in this file for Linux
# and Windows. On macOS, the default linker yields higher performance than LLD and is used instead.
#
# To install, please scroll to the corresponding table for your target (eg. `[target.x86_64-pc-windows-msvc]`
# for Windows) and follow the steps under `LLD linker`.
#
# For more information, please see LLD's website at <https://lld.llvm.org>.
#
# ## Mold
#
# Mold is a newer linker written by one of the authors of LLD. It boasts even greater performance, specifically
# through its high parallelism, though it only supports Linux.
#
# Mold is disabled by default in this file. If you wish to enable it, follow the installation instructions for
# your corresponding target, disable LLD by commenting out its `-Clink-arg=...` line, and enable Mold by
# *uncommenting* its `-Clink-arg=...` line.
#
# There is a fork of Mold named Sold that supports macOS, but it is unmaintained and is about the same speed as
# the default ld64 linker. For this reason, it is not included in this file.
#
# For more information, please see Mold's repository at <https://github.com/rui314/mold>.
#
# # Nightly configuration
#
# Be warned that the following features require nightly Rust, which is experimental and may contain bugs. If you
# are having issues, skip this section and use stable Rust instead.
#
# There are a few unstable features that can improve performance. To use them, first install nightly Rust
# through Rustup:
#
# ```
# rustup toolchain install nightly
# ```
#
# Finally, uncomment the lines under the `Nightly` heading for your corresponding target table (eg.
# `[target.x86_64-unknown-linux-gnu]` for Linux) to enable the following features:
#
# ## `share-generics`
#
# Usually rustc builds each crate separately, then combines them all together at the end. `share-generics` forces
# crates to share monomorphized generic code, so they do not duplicate work.
#
# In other words, instead of crate 1 generating `Foo<String>` and crate 2 generating `Foo<String>` separately,
# only one crate generates `Foo<String>` and the other adds on to the pre-existing work.
#
# Note that you may have some issues with this flag on Windows. If compiling fails due to the 65k symbol limit,
# you may have to disable this setting. For more information and possible solutions to this error, see
# <https://github.com/bevyengine/bevy/issues/1110>.
#
# ## `threads`
#
# This option enables rustc's parallel frontend, which improves performance when parsing, type checking, borrow
# checking, and more. We currently set `threads=0`, which defaults to the amount of cores in your CPU.
#
# For more information, see the blog post at <https://blog.rust-lang.org/2023/11/09/parallel-rustc.html>.

[target.x86_64-unknown-linux-gnu]
linker = "clang"
rustflags = [
# LLD linker
#
# You may need to install it:
#
# - Ubuntu: `sudo apt-get install lld clang`
# - Fedora: `sudo dnf install lld clang`
# - Arch: `sudo pacman -S lld clang`
# "-Clink-arg=-fuse-ld=lld",

# Mold linker
#
# You may need to install it:
#
# - Ubuntu: `sudo apt-get install mold clang`
# - Fedora: `sudo dnf install mold clang`
# - Arch: `sudo pacman -S mold clang`
"-Clink-arg=-fuse-ld=mold",

# Nightly
"-Zshare-generics=y",
"-Zthreads=0",
]
# Some systems may experience linker performance issues when running doc tests.
# See https://github.com/bevyengine/bevy/issues/12207 for details.
rustdocflags = [
# LLD linker
# "-Clink-arg=-fuse-ld=lld",

# Mold linker
"-Clink-arg=-fuse-ld=mold",
]

[target.x86_64-apple-darwin]
rustflags = [
# LLD linker
#
# The default ld64 linker is faster, you should continue using it instead.
#
# You may need to install it:
#
# Brew: `brew install llvm`
# Manually: <https://lld.llvm.org/MachO/index.html>
# "-Clink-arg=-fuse-ld=/usr/local/opt/llvm/bin/ld64.lld",

# Nightly
"-Zshare-generics=y",
"-Zthreads=0",
]

[target.aarch64-apple-darwin]
rustflags = [
# LLD linker
#
# The default ld64 linker is faster, you should continue using it instead.
#
# You may need to install it:
#
# Brew: `brew install llvm`
# Manually: <https://lld.llvm.org/MachO/index.html>
# "-Clink-arg=-fuse-ld=/opt/homebrew/opt/llvm/bin/ld64.lld",

# Nightly
"-Zshare-generics=y",
"-Zthreads=0",
]

[target.x86_64-pc-windows-msvc]
# LLD linker
#
# You may need to install it:
#
# ```
# cargo install -f cargo-binutils
# rustup component add llvm-tools
# ```
linker = "rust-lld.exe"
rustdocflags = ["-Clinker=rust-lld.exe"]
rustflags = [
# Nightly
"-Zshare-generics=n", # This needs to be off if you use dynamic linking on Windows.
"-Zthreads=0",
]

# Optional: Uncommenting the following improves compile times, but reduces the amount of debug info to 'line number tables only'.
# In most cases the gains are negligible, but if you are on macOS and have slow compile times you should see significant gains.
# [profile.dev]
# debug = 1

# Cranelift
[unstable]
codegen-backend = true

[profile]
incremental = true

[profile.dev]
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 = "cranelift"

# 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"
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
uses: dtolnay/rust-toolchain@stable

- name: Install dependencies
run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev libwayland-dev libxkbcommon-dev
run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev libwayland-dev libxkbcommon-dev lld clang

- name: Populate target directory from cache
uses: Leafwing-Studios/cargo-cache@v2
Expand Down
7 changes: 0 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,31 +53,24 @@ bevy_properties_pane = { path = "bevy_editor_panes/bevy_properties_pane" }
bevy_scene_tree = { path = "bevy_editor_panes/bevy_scene_tree" }

# bevy_widgets
bevy_color_picker = { path = "bevy_widgets/bevy_color_picker" }
bevy_command_palette = { path = "bevy_widgets/bevy_command_palette" }
bevy_context_menu = { path = "bevy_widgets/bevy_context_menu" }
bevy_i-cant-believe-its-not-bsn = { path = "bevy_widgets/bevy_i-cant-believe-its-not-bsn" }
bevy_menu_bar = { path = "bevy_widgets/bevy_menu_bar" }
bevy_scroll_box = { path = "bevy_widgets/bevy_scroll_box" }
bevy_footer_bar = { path = "bevy_widgets/bevy_footer_bar" }
bevy_toolbar = { path = "bevy_widgets/bevy_toolbar" }
bevy_tooltips = { path = "bevy_widgets/bevy_tooltips" }
bevy_text_editing = { path = "bevy_widgets/bevy_text_editing" }
bevy_field_forms = { path = "bevy_widgets/bevy_field_forms" }
bevy_focus = { path = "bevy_widgets/bevy_focus" }

# general crates
bevy_editor_core = { path = "crates/bevy_editor_core" }
bevy_asset_preview = { path = "crates/bevy_asset_preview" }
bevy_proto_bsn = { path = "crates/bevy_proto_bsn" }
bevy_editor = { path = "crates/bevy_editor" }
bevy_editor_camera = { path = "crates/bevy_editor_camera" }
bevy_editor_launcher = { path = "crates/bevy_editor_launcher" }
bevy_editor_settings = { path = "crates/bevy_editor_settings" }
bevy_editor_styles = { path = "crates/bevy_editor_styles" }
bevy_localization = { path = "crates/bevy_localization" }
bevy_pane_layout = { path = "crates/bevy_pane_layout" }
bevy_transform_gizmos = { path = "crates/bevy_transform_gizmos" }
bevy_undo = { path = "crates/bevy_undo" }
bevy_infinite_grid = { path = "crates/bevy_infinite_grid" }
bevy_editor_cam = { path = "crates/bevy_editor_cam" }
Expand Down
10 changes: 0 additions & 10 deletions bevy_widgets/bevy_color_picker/Cargo.toml

This file was deleted.

17 changes: 0 additions & 17 deletions bevy_widgets/bevy_color_picker/src/lib.rs

This file was deleted.

10 changes: 0 additions & 10 deletions bevy_widgets/bevy_command_palette/Cargo.toml

This file was deleted.

22 changes: 0 additions & 22 deletions bevy_widgets/bevy_command_palette/src/lib.rs

This file was deleted.

10 changes: 0 additions & 10 deletions bevy_widgets/bevy_toolbar/Cargo.toml

This file was deleted.

20 changes: 0 additions & 20 deletions bevy_widgets/bevy_toolbar/src/lib.rs

This file was deleted.

10 changes: 0 additions & 10 deletions bevy_widgets/bevy_tooltips/Cargo.toml

This file was deleted.

17 changes: 0 additions & 17 deletions bevy_widgets/bevy_tooltips/src/lib.rs

This file was deleted.

7 changes: 0 additions & 7 deletions crates/bevy_asset_preview/Cargo.toml

This file was deleted.

13 changes: 0 additions & 13 deletions crates/bevy_asset_preview/src/lib.rs

This file was deleted.

9 changes: 0 additions & 9 deletions crates/bevy_localization/Cargo.toml

This file was deleted.

17 changes: 0 additions & 17 deletions crates/bevy_localization/src/lib.rs

This file was deleted.

Loading