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

Add portable-atomic feature and disable portable-atomic/critical-section by default #265

Merged
merged 1 commit into from
Sep 29, 2024

Conversation

taiki-e
Copy link
Contributor

@taiki-e taiki-e commented Sep 22, 2024

Closes #264

This implements the first of the ways I mentioned in #264 (comment).

  • New Cargo feature to use portable-atomic's atomic types instead of core's

(The second way mentioned there was probably more user-friendly, but I did not choose it because it would have caused portable-atomic to appear in Cargo.lock as a platform-specific dependency. Like cfg-specific dependencies in crossbeam-rs/crossbeam#487 (comment).)

No new test case was added, because the following case is sufficient to test the situation where the race module is enabled (due to default features) and portable-atomic is used instead of core::sync::atomic (due to critical-section feature enables portable-atomic feature).

cmd!(sh, "cargo test --features critical-section").run()?;

This also closes #248 since this is a sound way to do that.

cc @kaspar030 @brodycj

@matklad
Copy link
Owner

matklad commented Sep 29, 2024

This all looks alright to me, thanks a lot for putting this together!

@matklad matklad merged commit f61508a into matklad:master Sep 29, 2024
1 check passed
@taiki-e taiki-e deleted the portable-atomic branch September 29, 2024 13:43
@@ -38,17 +38,23 @@ std = ["alloc"]
alloc = ["race"]

# Enables `once_cell::race` module.
race = []
race = ["portable-atomic?/require-cas"]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, due to Cargo bug (rust-lang/cargo#10801), this makes portable-atomic to appear in Cargo.lock (even if the portable-atomic feature is not enabled. even if portable-atomic will never be compiled).

With the diagnostic improvements in portable-atomic 1.8 (taiki-e/portable-atomic#181), the need for require-cas feature has decreased, so I think it is probably fine to remove "portable-atomic?/require-cas"...

Copy link
Owner

Choose a reason for hiding this comment

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

I am also fine with keeping it! Cargo bug is a bug, the code here seems correct, and could perhaps be helpful for older versions of portable-atomic?

I guess you are the best person to make a judgement call here though :)

@brodycj
Copy link
Contributor

brodycj commented Oct 2, 2024

Thanks @taiki-e & @matklad & thanks for the quick release!

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.

regression with portable-atomics in 1.20.0
3 participants