-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Tracking Issue: MVP no_std
Bevy
#15460
Comments
Looks like there is some effort to make |
Yeah that's where I got the (temporary) fix from: thiserror = {
git = "https://github.com/quartiq/thiserror",
rev = "515bd36da54dbc346250026ddc349c88851e4bb1",
default-features = false,
} I'm hoping the PR is merged sooner rather than later, but there's a similar issue with In both cases we have options for how to proceed. Either waiting for those crates to get updated, replacing them with something equivalent, or developing a replacement based on these prior efforts. |
# Objective - Contributes to #15460 ## Solution - Wrap `derive_label` `quote!` in an anonymous constant which contains an `extern crate alloc` statement, allowing use of the `alloc` namespace even when a user has not brought in the crate themselves. ## Testing - CI passed locally. ## Notes We can't generate code that uses `::std::boxed::Box` in `no_std` environments, but we also can't rely on `::alloc::boxed::Box` either, since the user might not have declared `extern crate alloc`. To resolve this, the generated code is wrapped in an anonymous constant which contains the `extern crate alloc` invocation. This does mean the macro is no longer hygienic against cases where the user provides an alternate `alloc` crate, however I believe this is an acceptable compromise. Additionally, this crate itself doesn't need to be `no_std`, it just needs to _generate_ `no_std` compatible code. --------- Co-authored-by: Alice Cecile <[email protected]>
) # Objective - Contributes to bevyengine#15460 ## Solution - Wrap `derive_label` `quote!` in an anonymous constant which contains an `extern crate alloc` statement, allowing use of the `alloc` namespace even when a user has not brought in the crate themselves. ## Testing - CI passed locally. ## Notes We can't generate code that uses `::std::boxed::Box` in `no_std` environments, but we also can't rely on `::alloc::boxed::Box` either, since the user might not have declared `extern crate alloc`. To resolve this, the generated code is wrapped in an anonymous constant which contains the `extern crate alloc` invocation. This does mean the macro is no longer hygienic against cases where the user provides an alternate `alloc` crate, however I believe this is an acceptable compromise. Additionally, this crate itself doesn't need to be `no_std`, it just needs to _generate_ `no_std` compatible code. --------- Co-authored-by: Alice Cecile <[email protected]>
# Objective - Contributes to #15460 - Allows `bevy_mikktspace` to be used in `no_std` contexts. ## Solution - Added `std` (default) and `libm` features which control the inclusion of the standard library. To use `bevy_mikktspace` in `no_std` environments, enable the `libm` feature. ## Testing - CI - `cargo clippy -p bevy_mikktspace --target "x86_64-unknown-none" --no-default-features --features libm`
) # Objective - Contributes to bevyengine#15460 ## Solution - Wrap `derive_label` `quote!` in an anonymous constant which contains an `extern crate alloc` statement, allowing use of the `alloc` namespace even when a user has not brought in the crate themselves. ## Testing - CI passed locally. ## Notes We can't generate code that uses `::std::boxed::Box` in `no_std` environments, but we also can't rely on `::alloc::boxed::Box` either, since the user might not have declared `extern crate alloc`. To resolve this, the generated code is wrapped in an anonymous constant which contains the `extern crate alloc` invocation. This does mean the macro is no longer hygienic against cases where the user provides an alternate `alloc` crate, however I believe this is an acceptable compromise. Additionally, this crate itself doesn't need to be `no_std`, it just needs to _generate_ `no_std` compatible code. --------- Co-authored-by: Alice Cecile <[email protected]>
# Objective - Contributes to bevyengine#15460 - Allows `bevy_mikktspace` to be used in `no_std` contexts. ## Solution - Added `std` (default) and `libm` features which control the inclusion of the standard library. To use `bevy_mikktspace` in `no_std` environments, enable the `libm` feature. ## Testing - CI - `cargo clippy -p bevy_mikktspace --target "x86_64-unknown-none" --no-default-features --features libm`
# Objective - Contributes to #15460 ## Solution - Made `web-time` a `wasm32`-only dependency. - Moved time-related exports to its own module for clarity. - Feature-gated allocator requirements for `hashbrown` behind `alloc`. - Enabled compile-time RNG for `ahash` (runtime RNG will preferentially used in `std` environments) - Made `thread_local` optional by feature-gating the `Parallel` type. ## Testing - Ran CI locally. - `cargo build -p bevy_utils --target "x86_64-unknown-none" --no-default-features`
After some discussion on the Discord, I'm going to open PRs to replace |
# Objective - Contributes to #15460 ## Solution - Added the following features: - `std` (default) - `async_executor` (default) - `edge_executor` - `critical-section` - `portable-atomic` - Gated `tracing` in `bevy_utils` to allow compilation on certain platforms - Switched from `tracing` to `log` for simple message logging within `bevy_ecs`. Note that `tracing` supports capturing from `log` so this should be an uncontroversial change. - Fixed imports and added feature gates as required - Made `bevy_tasks` optional within `bevy_ecs`. Turns out it's only needed for parallel operations which are already gated behind `multi_threaded` anyway. ## Testing - Added to `compile-check-no-std` CI command - `cargo check -p bevy_ecs --no-default-features --features edge_executor,critical-section,portable-atomic --target thumbv6m-none-eabi` - `cargo check -p bevy_ecs --no-default-features --features edge_executor,critical-section` - `cargo check -p bevy_ecs --no-default-features` ## Draft Release Notes Bevy's core ECS now supports `no_std` platforms. In prior versions of Bevy, it was not possible to work with embedded or niche platforms due to our reliance on the standard library, `std`. This has blocked a number of novel use-cases for Bevy, such as an embedded database for IoT devices, or for creating games on retro consoles. With this release, `bevy_ecs` no longer requires `std`. To use Bevy on a `no_std` platform, you must disable default features and enable the new `edge_executor` and `critical-section` features. You may also need to enable `portable-atomic` and `critical-section` if your platform does not natively support all atomic types and operations used by Bevy. ```toml [dependencies] bevy_ecs = { version = "0.16", default-features = false, features = [ # Required for platforms with incomplete atomics (e.g., Raspberry Pi Pico) "portable-atomic", "critical-section", # Optional "bevy_reflect", "serialize", "bevy_debug_stepping", "edge_executor" ] } ``` Currently, this has been tested on bare-metal x86 and the Raspberry Pi Pico. If you have trouble using `bevy_ecs` on a particular platform, please reach out either through a GitHub issue or in the `no_std` working group on the Bevy Discord server. Keep an eye out for future `no_std` updates as we continue to improve the parity between `std` and `no_std`. We look forward to seeing what kinds of applications are now possible with Bevy! ## Notes - Creating PR in draft to ensure CI is passing before requesting reviews. - This implementation has no support for multithreading in `no_std`, especially due to `NonSend` being unsound if allowed in multithreading. The reason is we cannot check the `ThreadId` in `no_std`, so we have no mechanism to at-runtime determine if access is sound. --------- Co-authored-by: Alice Cecile <[email protected]> Co-authored-by: Vic <[email protected]>
# Objective - Contributes to #15460 ## Solution - Added the following features: - `std` (default) - `bevy_tasks` (default) - `downcast ` (default) - `portable-atomic` - `critical-section` - `downcast` and `bevy_tasks` are now optional dependencies for `bevy_app`. ## Testing - CI - Personal UEFI and Raspberry Pi Pico demo applications compile and run against this branch ## Draft Release Notes Bevy's application framework now supports `no_std` platforms. Following up on `bevy_ecs` gaining `no_std` support, `bevy_app` extends the functionality available on these targets to include the powerful `App` and `Plugin` abstractions. With this, library authors now have the option of making their plugins `no_std` compatible, or even offering plugins specifically to improve Bevy on certain embedded platforms! To start making a `no_std` compatible plugin, simply disable default features when including `bevy_app`: ```toml [dependencies] bevy_app = { version = "0.16", default-features = false } ``` We encourage library authors to do this anyway, as it can also help with compile times and binary size on all platforms. Keep an eye out for future `no_std` updates as we continue to improve the parity between `std` and `no_std`. We look forward to seeing what kinds of applications are now possible with Bevy! ## Notes - `downcast-rs` is optional as it isn't compatible with `portable-atomic`. I will investigate making a PR upstream to add support for this functionality, as it should be very straightforward. - In line with the `bevy_ecs` no-std-ification, I've added documentation to all features, and grouped them as well. - ~~Creating this PR in draft while CI runs and so I can polish before review.~~ --------- Co-authored-by: Alice Cecile <[email protected]>
# Objective - Contributes to #15460 ## Solution - Added the following features: - `std` (default) ## Testing - CI ## Notes - There was a minor issue with `bevy_reflect`'s `smallvec` feature noticed in this PR which I have also resolved here. I can split this out if desired, but I've left it here for now as it's a very small change and I don't consider this PR itself to be very controversial.
# Objective - Contributes to #15460 ## Solution - Added the following features: - `std` (default) - `smol_str` (default) - `portable-atomic` - `critical-section` - `libm` - Fixed an existing issue where `bevy_reflect` wasn't properly feature gated. ## Testing - CI ## Notes - There were some minor issues with `bevy_math` and `bevy_ecs` noticed in this PR which I have also resolved here. I can split these out if desired, but I've left them here for now as they're very small changes and I don't consider this PR itself to be very controversial. - `libm`, `portable-atomic`, and `critical-section` are shortcuts to enable the relevant features in dependencies, making the usage of this crate on atomically challenged platforms possible and simpler. - `smol_str` is gated as it doesn't support atomically challenged platforms (e.g., Raspberry Pi Pico). I have an issue and a [PR](rust-analyzer/smol_str#91) to discuss this upstream.
# Objective - Contributes to #15460 ## Solution - Added the following features: - `std` (default) - `portable-atomic` - `critical-section` ## Testing - CI ## Notes - `portable-atomic`, and `critical-section` are shortcuts to enable the relevant features in dependencies, making the usage of this crate on atomically challenged platforms possible and simpler. - This PR is blocked until #17027 is merged (as it depends on fixes for the `once!` macro). Once merged, the change-count for this PR should reduce.
I think the |
# Objective - Contributes to #15460 ## Solution - Added the following features: - `std` (default) - `alloc` (default) - `bevy_reflect` (default) - `libm` ## Testing - CI ## Notes - `alloc` feature added to allow using this crate in `no_alloc` environments. - `bevy_reflect` was previously always enabled when `bevy-support` was enabled, which isn't how most other crates handle reflection. I've brought this in line with how most crates gate `bevy_reflect`.
Agreed! I've added a little preface note indicating that the below information was written prior to version 2 of |
# Objective - Contributes to #15460 ## Solution - Added the following features: - `std` (default) - `bevy_reflect` (default) - `libm` ## Testing - CI ## Notes - `bevy_reflect` was previously always enabled, which isn't how most other crates handle reflection. I've brought this in line with how most crates gate `bevy_reflect`. This is where the majority of the changes come from in this PR. --------- Co-authored-by: Alice Cecile <[email protected]>
# Objective - Contributes to bevyengine#15460 ## Solution - Added two new features, `std` (default) and `alloc`, gating `std` and `alloc` behind them respectively. - Added missing `f32` functions to `std_ops` as required. These `f32` methods have been added to the `clippy.toml` deny list to aid in `no_std` development. ## Testing - CI - `cargo clippy -p bevy_math --no-default-features --features libm --target "x86_64-unknown-none"` - `cargo test -p bevy_math --no-default-features --features libm` - `cargo test -p bevy_math --no-default-features --features "libm, alloc"` - `cargo test -p bevy_math --no-default-features --features "libm, alloc, std"` - `cargo test -p bevy_math --no-default-features --features "std"` ## Notes The following items require the `alloc` feature to be enabled: - `CubicBSpline` - `CubicBezier` - `CubicCardinalSpline` - `CubicCurve` - `CubicGenerator` - `CubicHermite` - `CubicNurbs` - `CyclicCubicGenerator` - `RationalCurve` - `RationalGenerator` - `BoxedPolygon` - `BoxedPolyline2d` - `BoxedPolyline3d` - `SampleCurve` - `SampleAutoCurve` - `UnevenSampleCurve` - `UnevenSampleAutoCurve` - `EvenCore` - `UnevenCore` - `ChunkedUnevenCore` This requirement could be relaxed in certain cases, but I had erred on the side of gating rather than modifying. Since `no_std` is a new set of platforms we are adding support to, and the `alloc` feature is enabled by default, this is not a breaking change. --------- Co-authored-by: Benjamin Brienen <[email protected]> Co-authored-by: Matty <[email protected]> Co-authored-by: Joona Aalto <[email protected]>
# Objective - Contributes to bevyengine#15460 ## Solution - Removed `petgraph` as a dependency from the `bevy_ecs` crate. - Replaced `TarjanScc` and `GraphMap` with specialised in-tree alternatives. ## Testing - Ran CI locally. - Added new unit tests to check ordering invariants. - Confirmed `petgraph` is no longer present in `cargo tree -p bevy_ecs` ## Migration Guide The `Dag::graph` method no longer returns a `petgraph` `DiGraph` and instead returns the new `DiGraph` type within `bevy_ecs`. Edge and node iteration methods are provided so conversion to the `petgraph` type should be trivial if required. ## Notes - `indexmap` was already in the dependency graph for `bevy_ecs`, so its inclusion here makes no difference to compilation time for Bevy. - The implementation for `Graph` is heavily inspired from the `petgraph` original, with specialisations added to simplify and improve the type. - `petgraph` does have public plans for `no_std` support, however there is no timeframe on if or when that functionality will be available. Moving to an in-house solution in the interim allows Bevy to continue developing its `no_std` offerings and further explore alternate graphing options. --------- Co-authored-by: Lixou <[email protected]> Co-authored-by: vero <[email protected]>
# Objective - Contributes to bevyengine#15460 ## Solution - Added `std` feature (enabled by default) ## Testing - CI - `cargo check -p bevy_reflect --no-default-features --target "x86_64-unknown-none"` - UEFI demo application runs with this branch of `bevy_reflect`, allowing `derive(Reflect)` ## Notes - The [`spin`](https://crates.io/crates/spin) crate has been included to provide `RwLock` and `Once` (as an alternative to `OnceLock`) when the `std` feature is not enabled. Another alternative may be more desirable, please provide feedback if you have a strong opinion here! - Certain items (`Box`, `String`, `ToString`) provided by `alloc` have been added to `__macro_exports` as a way to avoid `alloc` vs `std` namespacing. I'm personally quite annoyed that we can't rely on `alloc` as a crate name in `std` environments within macros. I'd love an alternative to my approach here, but I suspect it's the least-bad option. - I would've liked to have an `alloc` feature (for allocation-free `bevy_reflect`), unfortunately, `erased_serde` unconditionally requires access to `Box`. Maybe one day we could design around this, but for now it just means `bevy_reflect` requires `alloc`. --------- Co-authored-by: Gino Valente <[email protected]> Co-authored-by: Alice Cecile <[email protected]>
# Objective - Contributes to bevyengine#15460 ## Solution - Added the following new features: - `std` (default) - `alloc` - `encase` (default) - `libm` ## Testing - Added to `compile-check-no-std` CI command ## Notes - `ColorCurve` requires `alloc` due to how the underlying `EvenCore` type works. - `Srgba::to_hex` requires `alloc` to return a `String`. - This was otherwise a _very_ simple change
# Objective - Contributes to bevyengine#15460 ## Solution - Added the following features: - `std` (default) - `async_executor` (default) - `edge_executor` - `critical-section` - `portable-atomic` - Added [`edge-executor`](https://crates.io/crates/edge-executor) as a `no_std` alternative to `async-executor`. - Updated the `single_threaded_task_pool` to work in `no_std` environments by gating its reliance on `thread_local`. ## Testing - Added to `compile-check-no-std` CI command ## Notes - In previous iterations of this PR, a custom `async-executor` alternative was vendored in. This raised concerns around maintenance and testing. In this iteration, an existing version of that same vendoring is now used, but _only_ in `no_std` contexts. For existing `std` contexts, the original `async-executor` is used. - Due to the way statics work, certain `TaskPool` operations have added restrictions around `Send`/`Sync` in `no_std`. This is because there isn't a straightforward way to create a thread-local in `no_std`. If these added constraints pose an issue we can revisit this at a later date. - If a user enables both the `async_executor` and `edge_executor` features, we will default to using `async-executor`. Since enabling `async_executor` requires `std`, we can safely assume we are in an `std` context and use the original library. --------- Co-authored-by: Mike <[email protected]> Co-authored-by: Alice Cecile <[email protected]>
# Objective - Contributes to bevyengine#15460 ## Solution - Added the following features: - `std` (default) - `async_executor` (default) - `edge_executor` - `critical-section` - `portable-atomic` - Gated `tracing` in `bevy_utils` to allow compilation on certain platforms - Switched from `tracing` to `log` for simple message logging within `bevy_ecs`. Note that `tracing` supports capturing from `log` so this should be an uncontroversial change. - Fixed imports and added feature gates as required - Made `bevy_tasks` optional within `bevy_ecs`. Turns out it's only needed for parallel operations which are already gated behind `multi_threaded` anyway. ## Testing - Added to `compile-check-no-std` CI command - `cargo check -p bevy_ecs --no-default-features --features edge_executor,critical-section,portable-atomic --target thumbv6m-none-eabi` - `cargo check -p bevy_ecs --no-default-features --features edge_executor,critical-section` - `cargo check -p bevy_ecs --no-default-features` ## Draft Release Notes Bevy's core ECS now supports `no_std` platforms. In prior versions of Bevy, it was not possible to work with embedded or niche platforms due to our reliance on the standard library, `std`. This has blocked a number of novel use-cases for Bevy, such as an embedded database for IoT devices, or for creating games on retro consoles. With this release, `bevy_ecs` no longer requires `std`. To use Bevy on a `no_std` platform, you must disable default features and enable the new `edge_executor` and `critical-section` features. You may also need to enable `portable-atomic` and `critical-section` if your platform does not natively support all atomic types and operations used by Bevy. ```toml [dependencies] bevy_ecs = { version = "0.16", default-features = false, features = [ # Required for platforms with incomplete atomics (e.g., Raspberry Pi Pico) "portable-atomic", "critical-section", # Optional "bevy_reflect", "serialize", "bevy_debug_stepping", "edge_executor" ] } ``` Currently, this has been tested on bare-metal x86 and the Raspberry Pi Pico. If you have trouble using `bevy_ecs` on a particular platform, please reach out either through a GitHub issue or in the `no_std` working group on the Bevy Discord server. Keep an eye out for future `no_std` updates as we continue to improve the parity between `std` and `no_std`. We look forward to seeing what kinds of applications are now possible with Bevy! ## Notes - Creating PR in draft to ensure CI is passing before requesting reviews. - This implementation has no support for multithreading in `no_std`, especially due to `NonSend` being unsound if allowed in multithreading. The reason is we cannot check the `ThreadId` in `no_std`, so we have no mechanism to at-runtime determine if access is sound. --------- Co-authored-by: Alice Cecile <[email protected]> Co-authored-by: Vic <[email protected]>
# Objective - Contributes to bevyengine#15460 ## Solution - Added the following features: - `std` (default) - `bevy_tasks` (default) - `downcast ` (default) - `portable-atomic` - `critical-section` - `downcast` and `bevy_tasks` are now optional dependencies for `bevy_app`. ## Testing - CI - Personal UEFI and Raspberry Pi Pico demo applications compile and run against this branch ## Draft Release Notes Bevy's application framework now supports `no_std` platforms. Following up on `bevy_ecs` gaining `no_std` support, `bevy_app` extends the functionality available on these targets to include the powerful `App` and `Plugin` abstractions. With this, library authors now have the option of making their plugins `no_std` compatible, or even offering plugins specifically to improve Bevy on certain embedded platforms! To start making a `no_std` compatible plugin, simply disable default features when including `bevy_app`: ```toml [dependencies] bevy_app = { version = "0.16", default-features = false } ``` We encourage library authors to do this anyway, as it can also help with compile times and binary size on all platforms. Keep an eye out for future `no_std` updates as we continue to improve the parity between `std` and `no_std`. We look forward to seeing what kinds of applications are now possible with Bevy! ## Notes - `downcast-rs` is optional as it isn't compatible with `portable-atomic`. I will investigate making a PR upstream to add support for this functionality, as it should be very straightforward. - In line with the `bevy_ecs` no-std-ification, I've added documentation to all features, and grouped them as well. - ~~Creating this PR in draft while CI runs and so I can polish before review.~~ --------- Co-authored-by: Alice Cecile <[email protected]>
# Objective - Contributes to bevyengine#15460 ## Solution - Added the following features: - `std` (default) ## Testing - CI ## Notes - There was a minor issue with `bevy_reflect`'s `smallvec` feature noticed in this PR which I have also resolved here. I can split this out if desired, but I've left it here for now as it's a very small change and I don't consider this PR itself to be very controversial.
# Objective - Contributes to bevyengine#15460 ## Solution - Added the following features: - `std` (default) - `smol_str` (default) - `portable-atomic` - `critical-section` - `libm` - Fixed an existing issue where `bevy_reflect` wasn't properly feature gated. ## Testing - CI ## Notes - There were some minor issues with `bevy_math` and `bevy_ecs` noticed in this PR which I have also resolved here. I can split these out if desired, but I've left them here for now as they're very small changes and I don't consider this PR itself to be very controversial. - `libm`, `portable-atomic`, and `critical-section` are shortcuts to enable the relevant features in dependencies, making the usage of this crate on atomically challenged platforms possible and simpler. - `smol_str` is gated as it doesn't support atomically challenged platforms (e.g., Raspberry Pi Pico). I have an issue and a [PR](rust-analyzer/smol_str#91) to discuss this upstream.
# Objective - Contributes to bevyengine#15460 ## Solution - Added the following features: - `std` (default) - `portable-atomic` - `critical-section` ## Testing - CI ## Notes - `portable-atomic`, and `critical-section` are shortcuts to enable the relevant features in dependencies, making the usage of this crate on atomically challenged platforms possible and simpler. - This PR is blocked until bevyengine#17027 is merged (as it depends on fixes for the `once!` macro). Once merged, the change-count for this PR should reduce.
# Objective - Contributes to bevyengine#15460 ## Solution - Added the following features: - `std` (default) - `alloc` (default) - `bevy_reflect` (default) - `libm` ## Testing - CI ## Notes - `alloc` feature added to allow using this crate in `no_alloc` environments. - `bevy_reflect` was previously always enabled when `bevy-support` was enabled, which isn't how most other crates handle reflection. I've brought this in line with how most crates gate `bevy_reflect`.
This is a tracking issue for progress on a
no_std
compatible subset ofBevy
. The tasks are ordered roughly in sequence (bevy_app
can't beno_std
untilbevy_ecs
is for example).Overview
Below is a visualisation of the crates planned to be ported to
no_std
. Edges indicate the primary blocker for a crate being ported. The 🚧 symbol indicates that this crate is in-progress, while ✅ indicates it is now available inno_std
.Core Tasks
These tasks must be completed for a
no_std
Bevy to become usable at all.Prerequisites ✅
core
andalloc
overstd
Lints #15281bevy_ptr
✅Done prior to initiative.
bevy_utils
✅bevy_utils
inno_std
#15463Provide an appropriate
Instant
type which can be controlled by the user inno_std
contexts, or avoid its use. Moveweb-time
intowasm32
-only dependencies (doesn't need to exist outside web anyway!). Makethread_local
optional.Done!
bevy_tasks
✅no_std
support tobevy_tasks
#15464Done!
bevy_macro_utils
✅derive_label
to supportno_std
environments #15465Update
derive_label
to useBox
fromalloc
(requires wrapping the quotedimpl
in aconst _: () = { ... }
so thatextern crate alloc
wont conflict with the outer namespace).Done!
bevy_ecs
✅petgraph
frombevy_ecs
#15519thiserror
frombevy_ecs
#15774no_std
support tobevy_ecs
#16758Done!
bevy_app
✅thiserror
frombevy_app
#15779no_std
support tobevy_app
#16874Merged!
bevy_core
1 ✅bevy_core
#16897Merged!
bevy_internal
/bevy
std
/alloc
features from sub-crates through to the finalbevy
crate.Blocked on
bevy_core
.CI 🚧
compile-check-no-std
Command to CI Tool #15843no_std
example should be created and tested in CI as well.Bonus Features
These tasks aren't strictly required, but should be completed to close the gap between
no_std
andstd
Bevy. The more functionality we can provide inno_std
, the more the community can develop for it.bevy_a11y
This crate
iswas blocked on AccessKit's lack ofno_std
support. @DataTriny pointed out AccessKit 0.17 now supportsno_std
! This should now be quite straightforward to addno_std
support to once the other internal blockers are resolved (bevy_app
, etc.)bevy_asset
thiserror
frombevy_asset
#15778Reliance on filesystem operations will make this interesting, but a lot of the asset functionality exists outside of files and folders (processing, etc.). It's reasonable to consider that a
no_std
platform could have a customAssetSource
(and accompanyingAssetReader
/Writer
/etc.).bevy_color
✅no_std
support tobevy_color
#16633thiserror
frombevy_color
#15777Done!
bevy_derive
Should work as-is, but need to test.
bevy_diagnostic
Blocked on
bevy_core
.bevy_hierarchy
✅no_std
support tobevy_hierarchy
#16998Merged!
bevy_image
thiserror
frombevy_image
#15771Blocked on
bevy_asset
. Would also require some substantial feature-gating to isolate out theno_std
compatible subset.bevy_input
✅thiserror
frombevy_input
#15770no_std
support tobevy_input
#16995Awaiting merge.
bevy_input_focus
Blocked on
bevy_hierarchy
andbevy_window
.bevy_log
Blocked on
bevy_ecs
.bevy_math
✅no_std
Support tobevy_math
#15810thiserror
frombevy_math
#15769Done!
bevy_mesh
thiserror
frombevy_mesh
#15768Blocked on
bevy_image
,bevy_transform
, andhexasphere
.hexasphere
would need upstream changes, but on a first-glance looks like to could beno_std
.bevy_mikktspace
✅no_std
support tobevy_mikktspace
#15528Done!
bevy_reflect
✅no_std
support tobevy_reflect
#16256thiserror
frombevy_reflect
#15766Done!
bevy_remote
Blocked on
bevy_hierarchy
and a design. Currently built around networking, but could support serial commands instead, and would make debugging on embedded much easier too.bevy_scene
thiserror
frombevy_scene
#15764Blocked on
bevy_hierarchy
andbevy_asset
.bevy_state
✅no_std
support tobevy_state
#17028Done!
bevy_time
thiserror
frombevy_time
#15759Blocked on
bevy_ecs
, but also needs some design work, sinceInstant
is a part ofstd
and notcore
. Providing anunsafe
method for manually updatingTime
's based on aDuration
would be sufficient.bevy_transform
✅thiserror
frombevy_transform
#15761no_std
support tobevy_transform
#17030Merged!
bevy_window
✅no_std
support tobevy_window
#17031Merged!
Not Planned
These crates can't be ported to
no_std
because they are highly platform specific. If you see something on this list that could be ported, please let me know!bevy_animation
⚠Blocked by
bevy_render
.thiserror
frombevy_animation
#15780petgraph
with ano_std
compatible alternative.Currently only using the
DiGraph
type with no edge data and only a single node typeAnimationGraphNode
(and a serializable alternateSerializedAnimationGraphNode
).bevy_audio
⚠Currently undergoing a major re-write so this is subject to change. I suspect even with the re-write
no_std
support would be blocked on a fundamental dependency such ascpal
. Like rendering, audio is very platform dependent so there likely isn't a viable API Bevy could provide that would be simultaneously feature-rich enough for use on common platforms (PC, etc.) while being low-level enough forno_std
ones too.bevy_core_pipeline
⚠thiserror
frombevy_core_pipeline
#15775Blocked by
bevy_render
.bevy_dev_tools
⚠Blocked by
bevy_render
.bevy_dylib
⚠Unfamiliar with the dynamic linking this crate provides. I don't see any reason why it couldn't be supported in
no_std
, but I would definitely require an SME to assist with getting it working.bevy_encase_derive
⚠Exclusively used with
encase
, which is a part of the rendering side of Bevy.bevy_gilrs
⚠thiserror
frombevy_gilrs
#15773Built around
gilrs
which does not currently have anyno_std
support. There might be a way to upstreamno_std
support by relying on something likeSDL
, but I'm not familiar enough with the project to make a fair assessment on the viability here.bevy_gizmos
⚠Blocked by
bevy_render
.bevy_gltf
⚠thiserror
frombevy_gltf
#15772Blocked by
bevy_render
. It may make sense to find a way to break this dependency, sincegLTF
can be used independently ofwgpu
(e.g., with a user-created OpenGL renderer backend), but this would need an SME for sure.bevy_pbr
⚠thiserror
frombevy_pbr
#15767Blocked by
bevy_render
andwgpu
. Without support for WGSL shaders there's no real point in having this crate supported inno_std
.bevy_render
⚠thiserror
frombevy_render
#15765Massive crate very deeply integrated with
wgpu
, which is not juststd
reliant, but also platform dependent too. I don't think it will ever make sense to have ano_std
bevy_render
. Maybe could have value in splitting out some abstractions, but I don't know.bevy_sprite
⚠thiserror
frombevy_sprite
#15763Blocked on
bevy_render
.bevy_text
⚠thiserror
frombevy_text
#15762Blocked on
bevy_render
.bevy_ui
⚠thiserror
frombevy_ui
#15760Blocked on
bevy_render
.bevy_winit
⚠Blocked on
winit
. Likely couldn't be madeno_std
upstream either since it's entirely platform dependent.General Notes
thiserror
Note: this is now outdated, as
thiserror
version 2 includesno_std
support and is now publicly available.thiserror
is currently not available in ano_std
form due to its use of the::std::error::Error
path forError
(which it continues to use for MSRV backwards compatibility). There is a PR to addno_std
support tothiserror
which preserves that MSRV requirement, but it's unclear if/when that will be merged and released.One alternative is to link against the PR instead of the published version of
thiserror
:Another alternative is to switch to using
derive_more
. This would require adding explicit calls toderive(From, Display)
as well, which adds to the noise. Additionally, it isn't already in the dependency tree, so its inclusion may be contentious.Due to delays in
thiserror
'sno_std
support, we have decided to usederive_more
.portable-atomic
Certain platforms, such as the Raspberry Pi Pico, could run Bevy once
no_std
support is added, but can't due to Bevy's use of certain atomic features. To work around this issue, Bevy should employportable-atomic
and its siblingportable-atomic-util
. These crates provide suitable replacements for the variousAtomicX
types andArc
.This adds
cfg(...)
burden to the project, but would be limited in scope tobevy_ecs
andbevy_tasks
(the largest users of atomic types), at least initially. Additionally, there is issue with coercion sinceportable_atomic_util::Arc
is a 3rd party smart-pointer, so you cannot, for example, create anArc<dyn T>
directly from anArc<impl T>
. There is a simple workaround, but at a small performance cost for unsized types. However, this will be resolved once #18598 stabilises.Platform Support
Being
no_std
is necessary for certain platforms, but it is not always sufficient. Below is a table of platforms that I have tested:x86_64-unknown-uefi
uefi
crate.thumbv4t-none-eabi
tracing
tolog
, and usingportable_atomics
is sufficient to make this platform compile.aarch64-nintendo-switch-freestanding
cargo nx
on real hardware or an emulator to confirm it actually works.mipsel-sony-psx
tracing
tolog
, and usingportable_atomics
is sufficient to make this platform compile.msp430-none-elf
zerocopy
.thumbv7em-none-eabihf
fixedbitset
to disabled SIMD. Could potentially be fixed from within Bevy without the patch though.thumbv6m-none-eabi
portable_atomics
within Bevy, since the Pico doesn't support the atomic CAS instructions required.I have a prototype of
no_std
compatible Bevy available on this branch. It's not being actively maintained, as it is a proof of concept for upstreamno_std
support (use at your own risk, etc.). However, if anyone has a particular platform they'd like to use Bevy on, please feel free to test using this branch and let me know what kind of compatibility you have. In general:alloc
andcore
available.bevy_app
,bevy_ecs
,bevy_utils
, andbevy_tasks
are compatible in this branch, and must be imported directly (e.g., you can'tuse bevy;
, insteaduse bevy_app;
). Additionally, you must disable default features forno_std
compatibility.bevy_ecs
. For further information, see [Merged by Bors] - Fail to compile on 16-bit platforms #4736.Having an
std
FeatureI've posted a more detailed write-up here. But as a succinct warning:
no_std
crates should unconditionally be#[no_std]
to ensure consistent implicit prelude.These findings are acted upon in #17086.
Footnotes
bevy_core
has been removed, effectively resolving itsno_std
compatibility. ↩The text was updated successfully, but these errors were encountered: