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

bevy_reflect: no no_std support when the functions feature is enabled #18051

Closed
shekohex opened this issue Feb 26, 2025 · 3 comments · Fixed by #18060
Closed

bevy_reflect: no no_std support when the functions feature is enabled #18051

shekohex opened this issue Feb 26, 2025 · 3 comments · Fixed by #18060
Labels
A-Reflection Runtime information about types C-Bug An unexpected or incorrect behavior D-Modest A "normal" level of difficulty; suitable for simple features or challenging fixes O-Embedded Weird hardware and no_std platforms

Comments

@shekohex
Copy link

Bevy version

The release number or commit hash of the version you're using.

Bevy main 11db717

What you did

I'm trying to use bevy_reflect in a project and this project requires no_std support. the latest bevy_reflect release v0.15.3 has no_std support, but not really, since the #[derive(Reflect)] uses ::std::boxed::Box<..> in the trait implementation.

After some search and looking for the code on github, I found that it actually now supports no_std, However, enabling the functions feature makes it not compiling without std feature enabled as it still uses std here:

use std::sync::{PoisonError, RwLock, RwLockReadGuard, RwLockWriteGuard};

What went wrong

  1. bevy_reflect has no_std support.
  2. However, the func module does not fully work when std feature is disabled.
@shekohex shekohex added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Feb 26, 2025
@bushrat011899 bushrat011899 added A-Reflection Runtime information about types D-Modest A "normal" level of difficulty; suitable for simple features or challenging fixes O-Embedded Weird hardware and no_std platforms and removed S-Needs-Triage This issue needs to be labelled labels Feb 26, 2025
@bushrat011899
Copy link
Contributor

Thanks for testing this out! bevy_reflect was one of the first crates I added no_std support to, so it may be possible to increase the number of features that work now. I'll give it another look this weekend!

@bushrat011899
Copy link
Contributor

#18060 should solve this, but feel free to try out this branch in the mean-time!

@shekohex
Copy link
Author

Awesome! Thank you for the quick fix. It works 🫡

github-merge-queue bot pushed a commit that referenced this issue Feb 27, 2025
# Objective

- Fixes #18051

## Solution

- Switched function registry to use `bevy_platform_support::sync`
instead of `std::sync`
- Also documented that `debug_stack` (and transitively `debug`) require
`std`
- Also removed `std` from `wgpu-types` since that crate is now `no_std`
compatible

## Testing

- `cargo check -p bevy_reflect --no-default-features --features
critical-section,documentation,glam,glam/libm,smallvec,wgpu-types,functions
--target thumbv6m-none-eabi`

---

## Notes

With these changes, `bevy_reflect`'s feature support looks like this:

| Feature | `no_std` (Before) | `no_std` (After) | Notes |
| - | - | - | - |
| `default` | ❌ | ❌ | |
| `std` | ❌ | ❌ | |
| `documentation` | ✔️ | ✔️ | |
| `functions` | ❌ | ✔️ | |
| `critical-section` | ✔️ | ✔️ | |
| `bevy` | ✔️* | ✔️* | Partial due to `smol_str` |
| `debug` | ❌ | ❌ | |
| `debug_stack` | ❌ | ❌ | |
| `petgraph` | ❌ | ❌ | |
| `glam` | ✔️* | ✔️* | Requires enabling `glam/libm` |
| `smallvec` | ✔️ | ✔️ | |
| `uuid` | ✔️* | ✔️* | Requires setting up `getrandom` backend |
| `wgpu-types ` | ❌ | ✔️ | |
| `smol_str` | ✔️* | ✔️* | Partial due to `smol_str` not supporting
`portable-atomic` |
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Reflection Runtime information about types C-Bug An unexpected or incorrect behavior D-Modest A "normal" level of difficulty; suitable for simple features or challenging fixes O-Embedded Weird hardware and no_std platforms
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants