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

Check that target supports atomic pointer operations before defining max size for Arc #168

Merged
merged 2 commits into from
Aug 21, 2024

Conversation

sjudson
Copy link
Contributor

@sjudson sjudson commented Aug 21, 2024

Resolving #167 cc: @jamesmunns

When building with, e.g., --target riscv32i-unknown-none-elf and -F alloc on the current main branch, the build will fail with

error[E0432]: unresolved import `alloc::sync`
 --> source/postcard/src/max_size.rs:5:33
  |
5 | use alloc::{boxed::Box, rc::Rc, sync::Arc};
  |                                 ^^^^ could not find `sync` in `alloc`

due to the lack of support on that target for atomic pointer operations (see: https://doc.rust-lang.org/alloc/sync/index.html).

Following the recommendation from the Rust docs, this gates definition of POSTCARD_MAX_SIZE for alloc::sync::Arc behind a configuration check to confirm it is available on the target first.

Copy link

netlify bot commented Aug 21, 2024

Deploy Preview for cute-starship-2d9c9b canceled.

Name Link
🔨 Latest commit 774ed3a
🔍 Latest deploy log https://app.netlify.com/sites/cute-starship-2d9c9b/deploys/66c61f8ad7fd210007941ebf

@jamesmunns
Copy link
Owner

Gotcha! And you can confirm this resolves the issue you saw in #167? If so, I'll merge and release after CI is green.

@jamesmunns
Copy link
Owner

Also @sjudson if you'd like to add a test for this arch (rv32 + alloc) to the CI so it doesn't regress in the future: https://github.com/jamesmunns/postcard/blob/main/ci.sh feel free to add it to this PR!

@jamesmunns
Copy link
Owner

I went ahead and added it :)

@jamesmunns jamesmunns merged commit bb2be5b into jamesmunns:main Aug 21, 2024
5 checks passed
@sjudson
Copy link
Contributor Author

sjudson commented Aug 21, 2024

Thanks!

@sjudson sjudson deleted the cfg-check-alloc branch August 21, 2024 17:33
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 this pull request may close these issues.

2 participants