From 4568f5dae3be6b08d4556c3d6db3a6c57c4bce80 Mon Sep 17 00:00:00 2001 From: Carter Anderson Date: Sun, 7 Jun 2020 23:35:40 -0700 Subject: [PATCH] remove specialization. bevy now builds on stable rust! --- .cargo/config_fast_builds | 9 +++++++++ .github/workflows/rust.yml | 3 --- README.md | 10 +++++++--- crates/bevy_app/src/lib.rs | 1 - crates/bevy_app/src/resources.rs | 2 +- crates/bevy_render/src/lib.rs | 1 - examples/3d/3d_scene.rs | 1 + src/lib.rs | 1 - 8 files changed, 18 insertions(+), 10 deletions(-) diff --git a/.cargo/config_fast_builds b/.cargo/config_fast_builds index 6f1151e5bc..8c8e03acb9 100644 --- a/.cargo/config_fast_builds +++ b/.cargo/config_fast_builds @@ -1,7 +1,16 @@ +# Rename this file to `config` to enable "fast build" configuration. Please read the notes below. + +# NOTE: For maximum performance, build using a nightly compiler +If you are using rust stable, remove the "-Zshare-generics=y" below. + [target.x86_64-unknown-linux-gnu] linker = "/usr/bin/clang" rustflags = ["-Clink-arg=-fuse-ld=lld", "-Zshare-generics=y"] +[target.x86_64-apple-darwin] +linker = "/usr/bin/clang" +rustflags = ["-Zshare-generics=y"] + # NOTE: you must manually install lld on windows. you can easily do this with the "scoop" package manager: # `scoop install llvm` [target.x86_64-pc-windows-msvc] diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 06933d87d8..c1890a9a7e 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -15,9 +15,6 @@ jobs: steps: - uses: actions/checkout@v2 - uses: actions-rs/toolchain@v1 - with: - toolchain: nightly - override: true - name: Build run: cargo build --verbose - name: Run tests diff --git a/README.md b/README.md index 13fec32a24..7e9290a6f1 100644 --- a/README.md +++ b/README.md @@ -40,10 +40,14 @@ We recommend checking out [The Bevy Book](https://bevyengine.org/learn/book/intr cargo run --example scene ``` -### Nightly Compiler - -Bevy requires nightly rust right now. It currently uses [specialization](https://github.com/rust-lang/rfcs/blob/master/text/1210-impl-specialization.md) features, which are unstable. If specialization goes stable soon then we can go back to a stable compiler. [There is actually good forward progress happening here](https://github.com/rust-lang/rust/pull/68970). In the meantime, we will try our best to remove specialization usage so we can go back to stable. +### Fast Compiles +Bevy can be built just fine using default configuration on stable Rust. However for really fast iterative compiles, you should use nightly Rust and rename [.cargo/config_fast_builds](.cargo/config_fast_builds) to `.cargo/config`. This enables the following: +* Shared Generics: This feature shares generic monomorphization between crates, which significantly reduces the amount of redundant code generated (which gives a nice speed boost). +* LLD linker: Rust spends a lot of time linking, and LLD is _much_ faster. This config swaps in LLD as the linker on Windows and Linux (sorry MacOS users ... LLD currently does not support MacOS). You must have lld installed, which is part of llvm distributions: + * Ubuntu: `sudo apt-get install lld` + * Arch: `sudo pacman -S lld` + * Windows (using scoop package manager): `scoop install llvm` ## Libraries Used diff --git a/crates/bevy_app/src/lib.rs b/crates/bevy_app/src/lib.rs index 7807b8ee22..23cbd97cc6 100644 --- a/crates/bevy_app/src/lib.rs +++ b/crates/bevy_app/src/lib.rs @@ -1,4 +1,3 @@ -#![feature(min_specialization)] mod app; mod app_builder; mod entity_archetype; diff --git a/crates/bevy_app/src/resources.rs b/crates/bevy_app/src/resources.rs index af7ec92c2e..28851e30a9 100644 --- a/crates/bevy_app/src/resources.rs +++ b/crates/bevy_app/src/resources.rs @@ -8,7 +8,7 @@ impl FromResources for T where T: Default, { - default fn from_resources(_resources: &Resources) -> Self { + fn from_resources(_resources: &Resources) -> Self { Self::default() } } \ No newline at end of file diff --git a/crates/bevy_render/src/lib.rs b/crates/bevy_render/src/lib.rs index 05b393b5bd..5c17b1333c 100644 --- a/crates/bevy_render/src/lib.rs +++ b/crates/bevy_render/src/lib.rs @@ -1,4 +1,3 @@ -#![feature(min_specialization)] pub mod batch; mod camera; pub mod entity; diff --git a/examples/3d/3d_scene.rs b/examples/3d/3d_scene.rs index cf8faedc43..9842eca060 100644 --- a/examples/3d/3d_scene.rs +++ b/examples/3d/3d_scene.rs @@ -7,6 +7,7 @@ fn main() { .run(); } + /// set up a simple scene fn setup( command_buffer: &mut CommandBuffer, diff --git a/src/lib.rs b/src/lib.rs index 7539828446..b5694b4287 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -33,7 +33,6 @@ //! //! If you prefer it, you can also consume the individual bevy crates directly. -#![feature(min_specialization)] #![doc( html_logo_url = "https://bevyengine.org/assets/icon.png", html_favicon_url = "https://bevyengine.org/assets/icon.png"