Repository navigation
Conversation
|
Welcome, new contributor! Please make sure you've read our contributing guide, as well as our policy regarding AI usage, and we look forward to reviewing your pull request shortly ✨ |
In attempting to update `bevy_mod_gba` to support newer releases I encountered a few compilation issues due to the lack of atomic support on the "thumb4t" target used by the GBA. The Rust toolchain basically eliminated atomics support for a few arm/thumb targets due to some limitations: rust-lang/rust#149241 In `bevy_reflect` I added `cfg` guards to the various atomics based on the appropriate sizes. For the new `AtomicTick` type I updated the `AtomicU32` import to use the compatiblity imports from `bevy_platform` which provide a fallback on platforms lacking native atomic support. These fixes were sufficient to build and run a simple GBA app, along with using a version of `foldhash` that includes this patch for atomics support: orlp/foldhash#46
Just using `cfg(target_has_atomic)` was too aggresive and led to other errors. Checking for 8-bit atomics as the smallest size seems to work.
| @@ -1,3 +1,4 @@ | |||
| #[cfg(target_has_atomic = "8")] | |||
There was a problem hiding this comment.
There's probably a better pattern to use for these checks on the imports, but this was the best I found to avoid either leaving "unused imports" when the implementation isn't used while not hitting errors for the imports being compiled away in other circumstances.
There was a problem hiding this comment.
Could we make this apply to the whole module rather than on every import and the macro individually?
There was a problem hiding this comment.
Oh yes, thanks I've moved the check.
MrGVSV
left a comment
There was a problem hiding this comment.
Assuming target_has_atomic = 8 is a prerequisite for all other atomic sizes, I think we should conditionally compile the entire module with that. Is there any reason not to?
Skip compiling the whole module if atomics are unavailable.
Oh yes, that makes sense. I hadn't run into a need to do it at the |
| ::core::sync::atomic::AtomicU16, | ||
| ::core::sync::atomic::Ordering::SeqCst | ||
| ); | ||
| #[cfg(target_has_atomic = "8")] |
There was a problem hiding this comment.
These are now redundant with the mod-level check, but I figured this might be clearer for consistency instead of a comment or something about why they're not needed at this level.
| @@ -1,3 +1,4 @@ | |||
| #[cfg(target_has_atomic = "8")] | |||
There was a problem hiding this comment.
Oh yes, thanks I've moved the check.
|
I just realized I had overlooked issue #25205 which reported the With 0.20-dev enabling Just enabling the other features besides |
|
Yep, happy to review more PRs like this as you need them :) We don't have a ton of users working on embedded, so efforts to fight entropy like this are lovely. |
Objective
In attempting to update
bevy_mod_gbato support newer releases (see bushrat011899/bevy_mod_gba#9) I encountered a few compilation issues due to the lack of atomic support on the "thumb4t" target used by the GBA.The Rust toolchain basically eliminated atomics support for a few arm/thumb targets due to some limitations: rust-lang/rust#149241
So, with a Rust toolchain newer than 2025-12-02 Bevy has a few new compile issues due to missing atomics.
Solution
In
bevy_reflectI addedcfgguards to the various atomics based on the appropriate sizes.For the new
AtomicTicktype I updated theAtomicU32import to use the compatiblity imports frombevy_platformwhich provide a fallback on platforms lacking native atomic support.Testing
These fixes were sufficient to build and run a simple GBA app, along with using a version of
foldhashthat includes this patch for atomics support: orlp/foldhash#46I published a simple demo here which builds a GBA app using this patched version of Bevy: https://github.com/mgood/agb_bevy_demo
(I attempted to just patch
bevy_mod_gbabut due to some separate issues bringing it up-to-date I started with a much simpler demo app that just has basic graphics and input support)My build environment is not currently set up to build the whole Bevy suite, so I have some separate compilation issues with the examples failing with errors like this, even on a clean checkout of
main:I have run the tests for
bevy_reflect, and I'm attempting to figure out which other broader test targets I can run as well.