Skip to content

portable-atomic support for alloc::sync in tracing-core #3173

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

Closed
edisno opened this issue Dec 8, 2024 · 0 comments · Fixed by #3199
Closed

portable-atomic support for alloc::sync in tracing-core #3173

edisno opened this issue Dec 8, 2024 · 0 comments · Fixed by #3199

Comments

@edisno
Copy link

edisno commented Dec 8, 2024

Feature Request

I want to use bevy_reflect on no_std rp2040. This platform has alloc, but not atomics, so alloc::sync is missing. bevy_relflect has a hard depency on tracing, and I'd like to use tracing on this platform also.

Crates

tracing-core
portable-atomic
bevy_reflect

Motivation

Want to use tracing-core on no_std rp2040 without hardware atomics

Proposal

Since alloc::sync is missing on some no_std platforms, and the "portable-atomic" crate is a drop-in replacement for alloc::sync, integrate portable-atomic.

Alternatives

None that I know of.

@hds hds closed this as completed in #3199 Mar 31, 2025
hds pushed a commit that referenced this issue Mar 31, 2025
## Motivation

I want to use `bevy_reflect` on `no_std` devices. This platform has alloc,
but not atomics, so `alloc::sync` is missing. `bevy_relflect` has a hard
depency on `tracing`, and I'd like to use tracing on this platform also.

Want to use tracing-core on `no_std` devices like rp2040
without hardware atomics

## Solution

- Added `portable-atomic-util` as an optional dependency
  gated behind a new feature, `portable-atomic` to
  `tracing-core`
- When `portable-atomic` is enabled, switched uses of
  `Arc` and `Weak` away from `alloc::sync` to
  `portable_atomic_util`.
- Added workaround for a lack of support for
  [unsized coercion](rust-lang/rust#18598)
  in custom types. I've included a comment linking to this issue
  explaining the missing functionality.

Fixes #3173
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant