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

Remove uses of unstable feature(cfg_target_has_atomic) #698

Merged
merged 3 commits into from May 29, 2021
Merged

Conversation

taiki-e
Copy link
Member

@taiki-e taiki-e commented May 15, 2021

Some no-std targets (e.g., ARMv6-M) do not support atomic CAS operations and cannot use Arc, etc.

Currently, we are using an unstable feature to detect them, but it has caused breakage in the past (#435).
Also, users of stable Rust are not able to compile crossbeam on those targets.

Instead of depending on unstable features of the compiler, this patch detects those targets using the TARGET environment variables provided by cargo for the build script, and a list of targets that do not support atomic CAS operations.

This way is the same as the way we recently adopted in futures and valuable, and was originally inspired by the way heapless and defmt do, but this doesn't maintain the target list manually. (It's not really fully automated, but it's very easy to update.)

Also, this completely removes the dependency on unstable features from crates other than crossbeam-epoch.

refs: rust-lang/rust#51953, rust-lang/futures-rs#2400, tokio-rs/valuable#12

@Cightline
Copy link

Cightline commented May 16, 2021

I appreciate the work, I recently encountered this issue.

@taiki-e taiki-e force-pushed the no-atomic-cas branch 5 times, most recently from 76f9e2e to 138c956 Compare May 23, 2021 04:56
done
echo "];" >>"$file"

# There is no `"max-atomic-width" == 16` or `"max-atomic-width" == 8` targets.
Copy link
Member Author

@taiki-e taiki-e May 27, 2021

Choose a reason for hiding this comment

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

@taiki-e taiki-e force-pushed the no-atomic-cas branch 4 times, most recently from debc101 to 361edc9 Compare May 27, 2021 13:09
Detect platforms that do not support AtomicU64 by using the same way.
AFAIK, this is more robust than the current way that uses autocfg.
See also rust-lang/futures-rs#2294.
@taiki-e
Copy link
Member Author

taiki-e commented May 29, 2021

bors r+

@bors
Copy link
Contributor

bors bot commented May 29, 2021

Build succeeded:

@bors bors bot merged commit 9a9dd75 into master May 29, 2021
@bors bors bot deleted the no-atomic-cas branch May 29, 2021 10:41
bors bot added a commit that referenced this pull request May 30, 2021
707: Prepare for the next release r=taiki-e a=taiki-e

- crossbeam-epoch 0.9.4 -> 0.9.5
  - Fix UB in `Pointable` impl of `[MaybeUninit<T>]` (#694)
  - Support targets that do not have atomic CAS on stable Rust (#698)
  - Fix breakage with nightly feature due to rust-lang/rust#84510 (#692)
- crossbeam-queue 0.3.1 -> 0.3.2
  - Support targets that do not have atomic CAS on stable Rust (#698)
- crossbeam-utils 0.8.4 -> 0.8.5
  - Add `AtomicCell::fetch_update` (#704)
  - Support targets that do not have atomic CAS on stable Rust (#698)
- crossbeam 0.8.0 -> 0.8.1
  - Support targets that do not have atomic CAS on stable Rust (#698)

Closes #702 

Co-authored-by: Taiki Endo <te316e89@gmail.com>
bors bot added a commit that referenced this pull request Jan 23, 2022
776: Automatically creates PR when no_atomic.rs needs to be updated r=taiki-e a=taiki-e

follow-up #698

Co-authored-by: Taiki Endo <te316e89@gmail.com>
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