-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Automatically enable portable-atomic
when required
#17570
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -92,15 +92,6 @@ critical-section = [ | |
"bevy_reflect?/critical-section", | ||
] | ||
|
||
## `portable-atomic` provides additional platform support for atomic types and | ||
## operations, even on targets without native support. | ||
portable-atomic = [ | ||
"bevy_tasks?/portable-atomic", | ||
"bevy_platform_support/portable-atomic", | ||
"concurrent-queue/portable-atomic", | ||
"bevy_reflect?/portable-atomic", | ||
] | ||
|
||
[dependencies] | ||
bevy_ptr = { path = "../bevy_ptr", version = "0.16.0-dev" } | ||
bevy_reflect = { path = "../bevy_reflect", version = "0.16.0-dev", features = [ | ||
|
@@ -139,6 +130,11 @@ tracing = { version = "0.1", default-features = false, optional = true } | |
log = { version = "0.4", default-features = false } | ||
bumpalo = "3" | ||
|
||
[target.'cfg(not(all(target_has_atomic = "8", target_has_atomic = "16", target_has_atomic = "32", target_has_atomic = "64", target_has_atomic = "ptr")))'.dependencies] | ||
concurrent-queue = { version = "2.5.0", default-features = false, features = [ | ||
"portable-atomic", | ||
] } | ||
|
||
Comment on lines
+133
to
+137
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The trick could be upstreamed at some point |
||
[dev-dependencies] | ||
rand = "0.8" | ||
static_assertions = "1.1.0" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,32 +24,20 @@ serialize = ["hashbrown/serde"] | |
std = [ | ||
"alloc", | ||
"critical-section?/std", | ||
"portable-atomic?/std", | ||
"portable-atomic-util?/std", | ||
"portable-atomic/std", | ||
"portable-atomic-util/std", | ||
"spin/std", | ||
"foldhash/std", | ||
] | ||
|
||
alloc = ["portable-atomic-util?/alloc", "dep:hashbrown"] | ||
alloc = ["portable-atomic-util/alloc", "dep:hashbrown"] | ||
|
||
## `critical-section` provides the building blocks for synchronization primitives | ||
## on all platforms, including `no_std`. | ||
critical-section = ["dep:critical-section", "portable-atomic?/critical-section"] | ||
|
||
## `portable-atomic` provides additional platform support for atomic types and | ||
## operations, even on targets without native support. | ||
portable-atomic = [ | ||
"dep:portable-atomic", | ||
"dep:portable-atomic-util", | ||
"spin/portable_atomic", | ||
] | ||
critical-section = ["dep:critical-section", "portable-atomic/critical-section"] | ||
|
||
[dependencies] | ||
critical-section = { version = "1.2.0", default-features = false, optional = true } | ||
portable-atomic = { version = "1", default-features = false, features = [ | ||
"fallback", | ||
], optional = true } | ||
portable-atomic-util = { version = "0.2.4", default-features = false, optional = true } | ||
spin = { version = "0.9.8", default-features = false, features = [ | ||
"mutex", | ||
"spin_mutex", | ||
|
@@ -68,6 +56,17 @@ hashbrown = { version = "0.15.1", features = [ | |
web-time = { version = "1.1", default-features = false } | ||
getrandom = { version = "0.2.0", default-features = false, features = ["js"] } | ||
|
||
[target.'cfg(not(all(target_has_atomic = "8", target_has_atomic = "16", target_has_atomic = "32", target_has_atomic = "64", target_has_atomic = "ptr")))'.dependencies] | ||
portable-atomic = { version = "1", default-features = false, features = [ | ||
"fallback", | ||
] } | ||
spin = { version = "0.9.8", default-features = false, features = [ | ||
"portable_atomic", | ||
] } | ||
Comment on lines
+59
to
+65
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Essentially, "If any atomic feature isn't available, pessimistically include |
||
|
||
[target.'cfg(not(target_has_atomic = "ptr"))'.dependencies] | ||
portable-atomic-util = { version = "0.2.4", default-features = false } | ||
Comment on lines
+67
to
+68
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since we only need |
||
|
||
[lints] | ||
workspace = true | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -217,11 +217,6 @@ impl_reflect_opaque!(::core::num::Wrapping<T: Clone + Send + Sync>()); | |
impl_reflect_opaque!(::core::num::Saturating<T: Clone + Send + Sync>()); | ||
impl_reflect_opaque!(::bevy_platform_support::sync::Arc<T: Send + Sync + ?Sized>); | ||
|
||
// We check despite `portable-atomic` being enabled, if the standard library `Arc` is | ||
// also available, and implement Reflect for it. | ||
#[cfg(all(feature = "portable-atomic", target_has_atomic = "ptr"))] | ||
impl_reflect_opaque!(::alloc::sync::Arc<T: Send + Sync + ?Sized>); | ||
|
||
Comment on lines
-220
to
-224
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No longer required, since we can now guarantee that |
||
// `Serialize` and `Deserialize` only for platforms supported by serde: | ||
// https://github.com/serde-rs/serde/blob/3ffb86fc70efd3d329519e2dddfa306cc04f167c/serde/src/de/impls.rs#L1732 | ||
#[cfg(all(any(unix, windows), feature = "std"))] | ||
|
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.
Since
bevy_platform_support
can now automatically detect the need forportable-atomic
, user-facing crates no longer need to provide that feature.