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

Use target_has_atomic on Rust 1.60+ to enable atomic (de)serialization #2337

Merged

Conversation

badboy
Copy link
Contributor

@badboy badboy commented Dec 11, 2022

I recently ran into the issue that serde didn't implement Deserialize for atomics when compiled for Android on Arm (armv7-linux-androideabi).
This was once reported in #1579 and might have been addressed back then.
Current version doesn't enable it for arm ever, so it's still an issue regardless.

target_has_atomic has become stable in Rust 1.60 (see rust-lang/rust#32976 (comment)), so now it is possible to use it, at least when compiled for 1.60 and above.

I implemented it the quick way, just duplicating the code when a different cfg is enabled.
I might be able to merge those two into a single macro if that's desired.

I tested it locally by building the test suite for Android (requires proper set up of the Android NDK, etc.):

cargo test --target armv7-linux-androideabi -p serde_test_suite --no-run

@badboy badboy force-pushed the use-target_has_atomic-when-available branch from 98ef887 to 126730e Compare December 11, 2022 12:34
Copy link
Member

@dtolnay dtolnay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@dtolnay dtolnay merged commit 5361c79 into serde-rs:master Dec 11, 2022
@badboy badboy deleted the use-target_has_atomic-when-available branch December 12, 2022 09:31
crapStone added a commit to Calciumdibromid/CaBr2 that referenced this pull request Dec 22, 2022
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [serde](https://serde.rs) ([source](https://github.com/serde-rs/serde)) | dependencies | patch | `1.0.149` -> `1.0.151` |

---

### Release Notes

<details>
<summary>serde-rs/serde</summary>

### [`v1.0.151`](https://github.com/serde-rs/serde/releases/tag/v1.0.151)

[Compare Source](serde-rs/serde@v1.0.150...v1.0.151)

-   Update `serde::`{`ser`,`de`}`::StdError` to re-export `core::error::Error` when serde is built with `feature="std"` **off** and `feature="unstable"` **on** ([#&#8203;2344](serde-rs/serde#2344))

### [`v1.0.150`](https://github.com/serde-rs/serde/releases/tag/v1.0.150)

[Compare Source](serde-rs/serde@v1.0.149...v1.0.150)

-   Relax some trait bounds from the `Serialize` impl of `HashMap` and `BTreeMap` ([#&#8203;2334](serde-rs/serde#2334))
-   Enable `Serialize` and `Deserialize` impls of `std::sync::atomic` types on more platforms ([#&#8203;2337](serde-rs/serde#2337), thanks [@&#8203;badboy](https://github.com/badboy))

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNC41NC4yIiwidXBkYXRlZEluVmVyIjoiMzQuNjcuMCJ9-->

Co-authored-by: cabr2-bot <cabr2.help@gmail.com>
Co-authored-by: crapStone <crapstone01@gmail.com>
Reviewed-on: https://codeberg.org/Calciumdibromid/CaBr2/pulls/1672
Reviewed-by: crapStone <crapstone@noreply.codeberg.org>
Co-authored-by: Calciumdibromid Bot <cabr2_bot@noreply.codeberg.org>
Co-committed-by: Calciumdibromid Bot <cabr2_bot@noreply.codeberg.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants