Skip to content

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

Merged
matklad merged 1 commit intomatklad:masterfrom
taiki-e:portable-atomic
Sep 29, 2024
Merged

Add portable-atomic feature and disable portable-atomic/critical-section by default#265
matklad merged 1 commit intomatklad:masterfrom
taiki-e:portable-atomic

Conversation

@taiki-e
Copy link
Copy Markdown
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
Copy Markdown
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
@taiki-e taiki-e deleted the portable-atomic branch September 29, 2024 13:43
Comment thread Cargo.toml

# Enables `once_cell::race` module.
race = []
race = ["portable-atomic?/require-cas"]
Copy link
Copy Markdown
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
Copy Markdown
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 :)

@brody2consult
Copy link
Copy Markdown
Contributor

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