Skip to content

Exclude ctrlc from bevy_app for the Nintendo 3DS #19453

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

Merged
merged 1 commit into from
Jun 2, 2025

Conversation

selvmaya
Copy link
Contributor

@selvmaya selvmaya commented May 31, 2025

Background/motivation

The Nintendo 3DS is supported by the tier 3 rust target armv6k-nintendo-3ds. Bevy does not officially support the device, but as more of bevy becomes no_std compatible, more targets are being partially supported (e.g. GBA - #10680, https://github.com/bushrat011899/bevy_mod_gba) officially or not.

The Nintendo 3DS runs Horizon as its OS which is unix-based, and the above target (at least partially) supports rust std. It makes sense that you would want to use it, since the 3DS supports things like filesystem reads and the system clock.

Problem

Unlike standard unix targets, armv6k-nintendo-3ds is not one that can use/build the the ctrlc dependency in bevy_app which is enabled by the bevy std cargo feature.

Without the std feature flag, scheduled systems panic without providing another way for bevy to tick using the Instant type (like you might for a GBA).

Example
    Finished `dev` profile [optimized + debuginfo] target(s) in 1m 39s
Building smdh: /home/maya/repos/hyperspace-dj/target/armv6k-nintendo-3ds/debug/hyperspace-dj.smdh
Building 3dsx: /home/maya/repos/hyperspace-dj/target/armv6k-nintendo-3ds/debug/hyperspace-dj.3dsx
Adding RomFS from /home/maya/repos/hyperspace-dj/romfs
Running 3dslink
Sending hyperspace-dj.3dsx, 7172344 bytes
2777346 sent (38.72%), 233 blocks
starting server
server active ...
hii we'are about the to start the bevy app

thread 'main' panicked at /home/maya/repos/bevy/crates/bevy_platform/src/time/fallback.rs:177:13:
An elapsed time getter has not been provided to `Instant`. Please use `Instant::set_elapsed(...)` before calling `Instant::now()`
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Solution

This PR simply excludes the ctrlc dependency and its uses in bevy_app for the 3DS target (horizon) with an addition to its existing feature flags.

After this fix, we can use the std feature, and regular scheduled systems no longer panic because of missing Instant (system clock) support.

Testing

I compiled and ran a binary with the modified version of bevy, using no_default_features and feature flags default_no_std and std on a physical 3DS (classic) using homebrew and cargo-3ds.

Toolchain: armv6k-nintendo-3ds (nightly-2025-03-31)
Project reference: https://codeberg.org/pollyglot/hyperspace-dj/commit/440fc1018468885eed4c10c163f6bf3eefc64cb1

Considerations

It could be that we don't want to add specific exceptions inside bevy to support specific hardware with weird quirks inside general bevy code, but it's not obvious to me what we should use instead of an exception to (pre-existing) target cfg: every change here is merely an addition to a cfg that already checks for both the target family and the std flag.

It is not clear to me if this PR is exhaustive enough to be considered an adequate solution for the larger goal of partially supporting the 3DS, but it seems to be a step in the right direction because it at least lets trivial App::run setups with scheduled systems work.

The 3ds toolchain cannot build ctrlc, and this is not accounted for
while the 3ds is a unix target.
Copy link
Contributor

Welcome, new contributor!

Please make sure you've read our contributing guide and we look forward to reviewing your pull request shortly ✨

@FuzzyLitchi
Copy link

https://queer.party/@polly/114604313807885727

@selvmaya selvmaya changed the title Exclude ctrlc from bevy_app for the nindendo 3ds Exclude ctrlc from bevy_app for the Nintendo 3DS target May 31, 2025
@selvmaya selvmaya changed the title Exclude ctrlc from bevy_app for the Nintendo 3DS target Exclude ctrlc from bevy_app for the Nintendo 3DS May 31, 2025
@janhohenheim janhohenheim added S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it D-Straightforward Simple bug fixes and API improvements, docs, test and examples C-Machine-Specific This bug is isolated to specific hardware or driver configurations A-ECS Entities, components, systems, and events labels Jun 1, 2025
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Jun 2, 2025
Merged via the queue into bevyengine:main with commit f93e5c5 Jun 2, 2025
45 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ECS Entities, components, systems, and events C-Machine-Specific This bug is isolated to specific hardware or driver configurations D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants