Skip to content
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

Open
bushrat011899 opened this issue Sep 26, 2024 · 17 comments
Open

Tracking Issue: MVP no_std Bevy #15460

bushrat011899 opened this issue Sep 26, 2024 · 17 comments
Assignees
Labels
A-Cross-Cutting Impacts the entire engine C-Dependencies A change to the crates that Bevy depends on C-Feature A new feature, making something new possible C-Tracking-Issue An issue that collects information about a broad development initiative D-Modest A "normal" level of difficulty; suitable for simple features or challenging fixes X-Contentious There are nontrivial implications that should be thought through

Comments

@bushrat011899
Copy link
Contributor

bushrat011899 commented Sep 26, 2024

This is a tracking issue for progress on a no_std compatible subset of Bevy. The tasks are ordered roughly in sequence (bevy_app can't be no_std until bevy_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 in no_std.

graph TD;
    bevy_a11y
    bevy_app
    bevy_asset
    bevy_color[bevy_color ✅]
    bevy_core
    bevy_ecs[bevy_ecs 🚧]
    bevy_hierarchy
    bevy_input
    bevy_math[bevy_math ✅]
    bevy_mikktspace[bevy_mikktspace ✅]
    bevy_ptr[bevy_ptr ✅]
    bevy_reflect[bevy_reflect✅]
    bevy_tasks[bevy_tasks ✅]
    bevy_time
    bevy_transform
    bevy_utils[bevy_utils ✅]

    bevy_ptr-->bevy_ecs;

    bevy_utils-->bevy_ecs;

    bevy_tasks-->bevy_ecs;

    bevy_ecs-->bevy_app;

    bevy_app-->bevy_core;
    bevy_app-->bevy_a11y;
    bevy_app-->bevy_asset;
    bevy_app-->bevy_time;
    bevy_app-->bevy_log;

    bevy_time-->bevy_diagnostics;

    bevy_core-->bevy_input;
    bevy_core-->bevy_diagnostics;
    bevy_core-->bevy_hierarchy;
    
    bevy_asset-->bevy_image;

    bevy_color-->bevy_image;

    bevy_mikktspace-->bevy_mesh;

    bevy_hierarchy-->bevy_remote;
    bevy_hierarchy-->bevy_state;
    bevy_hierarchy-->bevy_transform;

    bevy_transform-->bevy_mesh;
    bevy_transform-->bevy_scene;
    
    bevy_math-->bevy_input;
    bevy_math-->bevy_color;

    bevy_a11y-->bevy_window;

    bevy_input-->bevy_window;

    bevy_reflect-->bevy_ecs;

    bevy_image-->bevy_mesh;
Loading

Core Tasks

These tasks must be completed for a no_std Bevy to become usable at all.

Prerequisites ✅

bevy_ptr

Done prior to initiative.

bevy_utils

Provide an appropriate Instant type which can be controlled by the user in no_std contexts, or avoid its use. Move web-time into wasm32-only dependencies (doesn't need to exist outside web anyway!). Make thread_local optional.

Done!

bevy_tasks

Done!

bevy_macro_utils

Update derive_label to use Box from alloc (requires wrapping the quoted impl in a const _: () = { ... } so that extern crate alloc wont conflict with the outer namespace).

Done!

bevy_ecs 🚧

Awaiting merge.

bevy_app

Blocked on bevy_ecs.

bevy_core

Blocked on bevy_app.

bevy_internal / bevy

  • Thread std / alloc features from sub-crates through to the final bevy crate.

Blocked on bevy_core.

CI 🚧

Bonus Features

These tasks aren't strictly required, but should be completed to close the gap between no_std and std Bevy. The more functionality we can provide in no_std, the more the community can develop for it.

bevy_a11y

This crate is was blocked on AccessKit's lack of no_std support. @DataTriny pointed out AccessKit 0.17 now supports no_std! This should now be quite straightforward to add no_std support to once the other internal blockers are resolved (bevy_app, etc.)

bevy_asset

Reliance 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 custom AssetSource (and accompanying AssetReader/Writer/etc.).

bevy_color

Done!

bevy_derive

Should work as-is, but need to test.

bevy_diagnostic

Blocked on bevy_core.

bevy_hierarchy

Blocked on bevy_core.

bevy_image

Blocked on bevy_asset. Would also require some substantial feature-gating to isolate out the no_std compatible subset.

bevy_input

Blocked on bevy_core.

bevy_log

Blocked on bevy_ecs.

bevy_math

Done!

bevy_mesh

Blocked on bevy_image, bevy_transform, and hexasphere. hexasphere would need upstream changes, but on a first-glance looks like to could be no_std.

bevy_mikktspace

Done!

bevy_reflect

Done!

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

Blocked on bevy_hierarchy and bevy_asset.

bevy_state

Blocked on bevy_hierarchy.

bevy_time

Blocked on bevy_ecs, but also needs some design work, since Instant is a part of std and not core. Providing an unsafe method for manually updating Time's based on a Duration would be sufficient.

bevy_transform

Blocked on bevy_hierarchy.

bevy_window

Currently blocked on bevy_a11y.

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.

Currently only using the DiGraph type with no edge data and only a single node type AnimationGraphNode (and a serializable alternate SerializedAnimationGraphNode).

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 as cpal. 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 for no_std ones too.

bevy_core_pipeline

Blocked 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

Built around gilrs which does not currently have any no_std support. There might be a way to upstream no_std support by relying on something like SDL, 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

Blocked by bevy_render. It may make sense to find a way to break this dependency, since gLTF can be used independently of wgpu (e.g., with a user-created OpenGL renderer backend), but this would need an SME for sure.

bevy_pbr

Blocked by bevy_render and wgpu. Without support for WGSL shaders there's no real point in having this crate supported in no_std.

bevy_render

Massive crate very deeply integrated with wgpu, which is not just std reliant, but also platform dependent too. I don't think it will ever make sense to have a no_std bevy_render. Maybe could have value in splitting out some abstractions, but I don't know.

bevy_sprite

Blocked on bevy_render.

bevy_text

Blocked on bevy_render.

bevy_ui

Blocked on bevy_render.

bevy_winit

Blocked on winit. Likely couldn't be made no_std upstream either since it's entirely platform dependent.

General Notes

thiserror

thiserror is currently not available in a no_std form due to its use of the ::std::error::Error path for Error (which it continues to use for MSRV backwards compatibility). There is a PR to add no_std support to thiserror 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:

thiserror = {
  git = "https://github.com/quartiq/thiserror",
  rev = "515bd36da54dbc346250026ddc349c88851e4bb1",
  default-features = false,
}

Another alternative is to switch to using derive_more. This would require adding explicit calls to derive(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's no_std support, we have decided to use derive_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 employ portable-atomic and its sibling portable-atomic-util. These crates provide suitable replacements for the various AtomicX types and Arc.

This adds cfg(...) burden to the project, but would be limited in scope to bevy_ecs and bevy_tasks (the largest users of atomic types), at least initially. Additionally, there is issue with coercion since portable_atomic_util::Arc is a 3rd party smart-pointer, so you cannot, for example, create an Arc<dyn T> directly from an Arc<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:

Name Target Builds Notes
UEFI x86_64-unknown-uefi Runs Boots on emulated and real hardware, supported by the uefi crate.
GameBoy Advance thumbv4t-none-eabi Partially The platform does not support all atomic operations (e.g., CAS), which Bevy directly and transiently relies on. Moving from tracing to log, and using portable_atomics is sufficient to make this platform compile.
Nintendo Switch aarch64-nintendo-switch-freestanding Compiles I cannot test the binary produced by cargo nx on real hardware or an emulator to confirm it actually works.
PlayStation One mipsel-sony-psx Partially The platform does not support all atomic operations (e.g., CAS), which Bevy directly and transiently relies on. Moving from tracing to log, and using portable_atomics is sufficient to make this platform compile.
MSP430 msp430-none-elf No This platform is 16-bit, which breaks too many assumptions made by dependencies like zerocopy.
Playdate thumbv7em-none-eabihf Runs Runs but requires a patch to fixedbitset to disabled SIMD. Could potentially be fixed from within Bevy without the patch though.
Raspberry Pi Pico thumbv6m-none-eabi Runs Runs but requires adopting 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 upstream no_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:

  • You must be able to compile a Rust project for this platform. (I hope this goes without saying!)
  • You must have alloc and core available.
  • Your platform must support Atomic CAS (hoping to relax this in the future!)
  • Only the bevy_app, bevy_ecs, bevy_utils, and bevy_tasks are compatible in this branch, and must be imported directly (e.g., you can't use bevy;, instead use bevy_app;). Additionally, you must disable default features for no_std compatibility.
  • Your platform must be 32-bit or higher due to safety concerns in bevy_ecs. For further information, see [Merged by Bors] - Fail to compile on 16-bit platforms #4736.
@bushrat011899 bushrat011899 added C-Feature A new feature, making something new possible C-Dependencies A change to the crates that Bevy depends on C-Tracking-Issue An issue that collects information about a broad development initiative A-Cross-Cutting Impacts the entire engine X-Contentious There are nontrivial implications that should be thought through D-Modest A "normal" level of difficulty; suitable for simple features or challenging fixes labels Sep 26, 2024
@BD103
Copy link
Member

BD103 commented Sep 27, 2024

Looks like there is some effort to make thiserror support #![no_std] in dtolnay/thiserror#304. Looks like it's on hold until the author responds, though.

@bushrat011899
Copy link
Contributor Author

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 petgraph where there does exist a no_std compatible version, but it's waiting in the wings.

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.

github-merge-queue bot pushed a commit that referenced this issue Sep 27, 2024
# 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]>
rudderbucky pushed a commit to rudderbucky/bevy that referenced this issue Sep 27, 2024
)

# 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]>
github-merge-queue bot pushed a commit that referenced this issue Sep 30, 2024
# 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`
@bushrat011899 bushrat011899 self-assigned this Oct 4, 2024
robtfm pushed a commit to robtfm/bevy that referenced this issue Oct 4, 2024
)

# 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]>
robtfm pushed a commit to robtfm/bevy that referenced this issue Oct 4, 2024
# 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`
github-merge-queue bot pushed a commit that referenced this issue Oct 4, 2024
# 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`
@bushrat011899
Copy link
Contributor Author

After some discussion on the Discord, I'm going to open PRs to replace thiserror with derive_more for at least bevy_ecs and bevy_app in the near-term. A quick experiment on bevy_ecs made the change look pretty minor, and the crate does offer more functionality than thiserror does on its own.

github-merge-queue bot pushed a commit that referenced this issue Oct 9, 2024
# Objective

- Contributes to #15460

## Solution

- Removed `thiserror` from `bevy_sprite`
github-merge-queue bot pushed a commit that referenced this issue Oct 9, 2024
# Objective

- Contributes to #15460

## Solution

- Removed `thiserror` from `bevy_asset`
@bushrat011899
Copy link
Contributor Author

Can cargo-deny work on "our" dependencies only? If so, please add a line for thiserror, since derive-more tackles everything we need.

Unfortunately no. Currently cargo deny treats direct and transitive dependencies identically. We could make a CI job that uses a crate like toml to check if thiserror is present in the dependency table for each Cargo.toml in the crates folder. I suspect we would want to do something like this anyway as a part of a broader no_std CI task.

In the interim, if a user adds thiserror back into Bevy inadvertently we at least have derive_more in-tree ready to go to fix it.

@Niashi24
Copy link
Contributor

Niashi24 commented Nov 1, 2024

I got @bushrat011899's no_std branch's bevy_app + bevy_ecs working on the Playdate Simulator!

The one change I had to make to get it to run was disabling fixedbitset's simd support. For whatever reason, vec![SimdBlock::NONE; 1] (being called from bevy_ecs's Schedule) was causing a segmentation fault when SimdBlock was avx2::Block. I solved this by pulling down fixedbitset, commenting out all of the simd support, and overriding the dependency in my cargo.toml.

My Playdate won't arrive until December so it's currently unknown if it will run on hardware. I assume the above jank is to do with the Playdate Simulator and wouldn't happen on hardware (since I assume the Playdate's processor doesn't support avx2), but of course that is to be seen.

Link to discussion on discord:
https://discord.com/channels/691052431525675048/691052431974465548/1302002362432487486

@alice-i-cecile
Copy link
Member

Can you open an issue upstream to feature flag the SIMD support?

@bushrat011899
Copy link
Contributor Author

I believe there's an existing issue around runtime-detection of SIMD features that is likely related to this error the Playdate exposes.

@bushrat011899
Copy link
Contributor Author

bushrat011899 commented Nov 2, 2024

@heydocode suggested using the Embassy crate as a part of offering multi threading and Async execution to Bevy. This is a good suggestion that I'm making note of here for future follow-up.

@heydocode
Copy link

Yeah, to avoid confusion, this is my GitHub account.

@CarlosMendonca
Copy link

@Niashi24 thanks for testing! Care to publish a minimal hello-world repository so we can replicate and test on hardware? Thank you!

@Niashi24
Copy link
Contributor

Niashi24 commented Nov 2, 2024

@CarlosMendonca Here you go, hope this helps! https://github.com/Niashi24/bitset-simd-min

I do want to emphasize that this is running on the Playdate Simulator on my computer, not the actual Playdate hardware. From what I understand running it on the simulator means that the game is actually running on the hardware that runs the simulator, i.e. my computer.

It's possible that it could just be a fault with the simulator. I can't test it on the actual Playdate hardware since I don't have one (mine won't arrive until Christmas).

The crash occurred running the simulator on both Windows and Linux (running through WSL2). My processor does have support for avx2.

@jatimix
Copy link
Contributor

jatimix commented Nov 7, 2024

Hello, I just notice that "thiserror" 2.0 now support no_std.

https://github.com/dtolnay/thiserror/releases/tag/2.0.0

@BenjaminBrienen
Copy link
Contributor

Hello, I just notice that "thiserror" 2.0 now support no_std.

https://github.com/dtolnay/thiserror/releases/tag/2.0.0

We have already switched off of it, and we don't see value in switching back. See the working group for no_std on the bevy discord for more info.

@DataTriny
Copy link
Contributor

The core of AccessKit (that is, the accesskit crate) is no-std compatible since 0.17.0.

@bushrat011899
Copy link
Contributor Author

The core of AccessKit (that is, the accesskit crate) is no-std compatible since 0.17.0.

That's awesome to hear, thanks for pointing it out! I've updated the roadmap to include bevy_a11y, since AccessKit was my only real concern here.

@DataTriny
Copy link
Contributor

@bushrat011899 You might also want to update the section on bevy_window, since a feature is probably not needed anymore here?

Having bevy_a11y run on as much devices as possible is important for us. We are aware that game consoles don't ship with an accessibility layer, but we still want developers to be able to rely on AccessKit to create their own assistive technologies. For this purpose, the accesskit_consumer crate, which contains the logic needed by platform adapters, also supports no-std as of its latest version.

github-merge-queue bot pushed a commit that referenced this issue Dec 3, 2024
# Objective

- Contributes to #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]>
github-merge-queue bot pushed a commit that referenced this issue Dec 3, 2024
# Objective

- Contributes to #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]>
github-merge-queue bot pushed a commit that referenced this issue Dec 3, 2024
# Objective

- Contributes to #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]>
github-merge-queue bot pushed a commit that referenced this issue Dec 5, 2024
# Objective

- Contributes to #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]>
github-merge-queue bot pushed a commit that referenced this issue Dec 5, 2024
# Objective

- Contributes to #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
github-merge-queue bot pushed a commit that referenced this issue Dec 6, 2024
# Objective

- Contributes to #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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Cross-Cutting Impacts the entire engine C-Dependencies A change to the crates that Bevy depends on C-Feature A new feature, making something new possible C-Tracking-Issue An issue that collects information about a broad development initiative D-Modest A "normal" level of difficulty; suitable for simple features or challenging fixes X-Contentious There are nontrivial implications that should be thought through
Projects
None yet
Development

No branches or pull requests

9 participants