-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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 <alice.i.cecile@gmail.com>
) # 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 <alice.i.cecile@gmail.com>
# 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 <alice.i.cecile@gmail.com>
# 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 |
Can |
Unfortunately no. Currently In the interim, if a user adds |
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).Core Tasks
These tasks must be completed for a
no_std
Bevy to become usable at all.core
andalloc
instead ofstd
Add
core
andalloc
overstd
Lints #15281bevy_ptr
bevy_utils
Minor fixes for
bevy_utils
inno_std
#15463Instant
type which can be controlled by the user inno_std
contexts, or avoid its useweb-time
intowasm32
-only dependencies (doesn't need to exist outside web anyway!)thread_local
optionalbevy_tasks
Add
no_std
support tobevy_tasks
#15464async-executor
with ano_std
compatible executorCan just be a direct copy of the existing
Local/Executor
usingno_std
compatible types from a crate likespin
std
/alloc
featuresbevy_macro_utils
Modify
derive_label
to supportno_std
environments #15465derive_label
to useBox
fromalloc
(requires wrapping the quoted
impl
in aconst _: () = { ... }
so thatextern crate alloc
wont conflict with the outer namespace)bevy_ecs
petgraph
'sGraphMap
Remove
petgraph
frombevy_ecs
#15519A direct copy does work since the biggest issue is the complex trait network
petgraph
uses and their reliance on thestd
feature ofindexmap
, which we don't need.petgraph
'sTarjanScc
Remove
petgraph
frombevy_ecs
#15519A direct copy is also possible here.
thiserror
with ano_std
compatible alternative.Remove
thiserror
frombevy_ecs
#15774std
/alloc
featuresbevy_app
thiserror
with ano_std
compatible alternative.Remove
thiserror
frombevy_app
#15779std
/alloc
featuresbevy_internal
/bevy
std
/alloc
features from sub-crates through to the finalbevy
crate.Will require making most extra Bevy crates optional behind a
std
feature. However, as more crates are madeno_std
these can be moved out from that feature gate.no_std
compatibility is preservedAdd
compile-check-no-std
Command to CI Tool #15843Bonus 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_animation
thiserror
with ano_std
compatible alternative.Remove
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_asset
Reliance on filesystem operations will make this interesting, but a lot of the asset functionality exists outside of files and folders (processing, etc.).
thiserror
with ano_std
compatible alternative.Remove
thiserror
frombevy_asset
#15778bevy_color
thiserror
with ano_std
compatible alternative.Remove
thiserror
frombevy_color
#15777bevy_core
bevy_derive
bevy_diagnostic
bevy_hierarchy
bevy_image
Remove
thiserror
frombevy_image
#15771bevy_input
thiserror
with ano_std
compatible alternative.Remove
thiserror
frombevy_input
#15770bevy_log
bevy_math
Add
no_std
Support tobevy_math
#15810thiserror
with ano_std
compatible alternative.Remove
thiserror
frombevy_math
#15769bevy_mesh
Remove
thiserror
frombevy_mesh
#15768bevy_mikktspace
Add
no_std
support tobevy_mikktspace
#15528bevy_reflect
thiserror
with ano_std
compatible alternative.Remove
thiserror
frombevy_reflect
#15766bevy_remote
Might be able to work over serial?
bevy_state
bevy_time
thiserror
with ano_std
compatible alternative.Remove
thiserror
frombevy_time
#15759bevy_transform
thiserror
with ano_std
compatible alternative.Remove
thiserror
frombevy_transform
#15761Not 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_a11y
bevy_audio
bevy_core_pipeline
Remove
thiserror
frombevy_core_pipeline
#15775bevy_dev_tools
bevy_dylib
bevy_encase_derive
bevy_gilrs
Remove
thiserror
frombevy_gilrs
#15773bevy_gizmos
bevy_gltf
Remove
thiserror
frombevy_gltf
#15772bevy_pbr
Remove
thiserror
frombevy_pbr
#15767bevy_render
Remove
thiserror
frombevy_render
#15765bevy_scene
Remove
thiserror
frombevy_scene
#15764bevy_sprite
Remove
thiserror
frombevy_sprite
#15763bevy_text
Remove
thiserror
frombevy_text
#15762bevy_ui
Remove
thiserror
frombevy_ui
#15760bevy_window
bevy_winit
General Notes
thiserror
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
.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
.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.The text was updated successfully, but these errors were encountered: