-
Notifications
You must be signed in to change notification settings - Fork 635
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) #2400
Conversation
ba8cc00
to
2b5d082
Compare
This is great! Thanks for working on it :) Removing |
Hmm, you are right. That said, we want to reduce dependency on unstable features as much as possible... So perhaps the compromise is to make RUSTFLAGS='--cfg futures_no_atomic_cas' cargo build |
Why not simply keep Aditionally, removing it (or keeping it but making it do nothing) is semver-breaking: it makes code that compiled before stop compiling. |
No, cfg-target-has-atomic feature is unstable and stability is not guaranteed. Lines 46 to 48 in c77cd3c
|
I wasn't aware of this issue with |
Hey @taiki-e, thank you for implementing this! I have tested this change in my I can confirm this change works as expected for my project, at least :) |
0457c51
to
3f73ddd
Compare
@jamesmunns Thanks for testing this! |
// The rustc-cfg listed below are considered public API, but it is *unstable* | ||
// and outside of the normal semver guarantees: | ||
// | ||
// - `futures_no_atomic_cas` | ||
// Assume the target does not have atomic CAS (compare-and-swap). | ||
// This is usually detected automatically by the build script, but you may | ||
// need to enable it manually when building for custom targets or using | ||
// non-cargo build systems that don't run the build script. | ||
// | ||
// With the exceptions mentioned above, the rustc-cfg strings below are | ||
// *not* public API. Please let us know by opening a GitHub issue if your build | ||
// environment requires some way to enable these cfgs other than by executing | ||
// our build script. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As said in #2400 (comment), exposes cfg(futures_no_atomic_cas) as unstable public API (outside of the normal semver guarantees).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, we probably need to set #![cfg_attr(docsrs, doc(cfg_hide(futures_no_atomic_cas)))]
when rust-lang/rust#79341 merged...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That might be a while 😅
7a092cb
to
75c184b
Compare
75c184b
to
d0ca511
Compare
Some no-std targets do not have atomic CAS and cannot use Arc, etc. 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 have atomic CAS. This is a port of rust-lang/futures-rs#2400. See that PR for more.
698: Remove uses of unstable feature(cfg_target_has_atomic) r=taiki-e a=taiki-e 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](rust-lang/futures-rs#2400) and [valuable](tokio-rs/valuable#12), and was originally inspired by the way [heapless](rust-embedded/heapless@44c66a7) and [defmt](https://github.com/knurling-rs/defmt/blob/963152f0fc530fca64ba4ff1492d9c4b7bf76062/build.rs#L42-L51) do, but this doesn't maintain the target list manually. (It's not really fully automated, but [it's very easy to update](https://github.com/crossbeam-rs/crossbeam/blob/a42dbed87a5739228b576f526b1e2fd80260a29b/.github/workflows/ci.yml#L89).) 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 704: Add AtomicCell::fetch_update r=taiki-e a=taiki-e Equivalent of [`std::sync::atomic::AtomicN::fetch_update`](https://doc.rust-lang.org/nightly/core/sync/atomic/struct.AtomicUsize.html#method.fetch_update) that stabilized in Rust 1.45. Co-authored-by: Taiki Endo <te316e89@gmail.com>
Instead of depending on unstable features of the compiler, use the TARGET environment variables provided by cargo for the build script and a list of targets that do not have atomic CAS.
This completely removes the dependency on unstable features from crates other than futures, futures-util, futures-io.
This way is 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.)
Closes #2399
Replaces #2294
r? @Nemo157 @cramertj
cc @jamesmunns @Dirbaio