-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Some functions in core::sync
are annotated to only support targets with 8-bit atomic support
#106845
Comments
Thanks for creating the issue! I will submit a PR soon (I'm AFK now). |
vadorovsky
added a commit
to vadorovsky/rust
that referenced
this issue
Jan 17, 2023
Atomic operations for different widths (8-bit, 16-bit, 32-bit etc.) are guarded by `target_has_atomic = "value"` symbol (i.e. `target_has_atomic = "8"`) (and the other derivatives), but before this change, there was no width-agnostic symbol indicating a general availability of atomic operations. This change introduces: * `target_has_atomic_load_store` symbol when atomics for any integer width are supported by the target. * `target_has_atomic` symbol when also CAS is supported. Fixes rust-lang#106845 Signed-off-by: Michal Rostecki <[email protected]>
vadorovsky
added a commit
to vadorovsky/rust
that referenced
this issue
Jan 18, 2023
Before this change, the following functions and macros were annotated with `#[cfg(target_has_atomic = "8")]` or `#[cfg(target_has_atomic_load_store = "8")]`: * `atomic_int` * `strongest_failure_ordering` * `atomic_swap` * `atomic_add` * `atomic_sub` * `atomic_compare_exchange` * `atomic_compare_exchange_weak` * `atomic_and` * `atomic_nand` * `atomic_or` * `atomic_xor` * `atomic_max` * `atomic_min` * `atomic_umax` * `atomic_umin` However, none of those functions and macros actually depend on 8-bit width and they are needed for all atomic widths (16-bit, 32-bit, 64-bit etc.). Some targets might not support 8-bit atomics (i.e. BPF, if we would enable atomic CAS for it). This change fixes that by removing the `"8"` argument from annotations, which results in accepting the whole variety of widths. Fixes rust-lang#106845 Signed-off-by: Michal Rostecki <[email protected]>
vadorovsky
added a commit
to vadorovsky/rust
that referenced
this issue
Jan 25, 2023
Before this change, the following functions and macros were annotated with `#[cfg(target_has_atomic = "8")]` or `#[cfg(target_has_atomic_load_store = "8")]`: * `atomic_int` * `strongest_failure_ordering` * `atomic_swap` * `atomic_add` * `atomic_sub` * `atomic_compare_exchange` * `atomic_compare_exchange_weak` * `atomic_and` * `atomic_nand` * `atomic_or` * `atomic_xor` * `atomic_max` * `atomic_min` * `atomic_umax` * `atomic_umin` However, none of those functions and macros actually depend on 8-bit width and they are needed for all atomic widths (16-bit, 32-bit, 64-bit etc.). Some targets might not support 8-bit atomics (i.e. BPF, if we would enable atomic CAS for it). This change fixes that by removing the `"8"` argument from annotations, which results in accepting the whole variety of widths. Fixes rust-lang#106845 Fixes rust-lang#106795 Signed-off-by: Michal Rostecki <[email protected]>
JohnTitor
added a commit
to JohnTitor/rust
that referenced
this issue
Jan 27, 2023
… r=joshtriplett core: Support variety of atomic widths in width-agnostic functions Before this change, the following functions and macros were annotated with `#[cfg(target_has_atomic = "8")]` or `#[cfg(target_has_atomic_load_store = "8")]`: * `atomic_int` * `strongest_failure_ordering` * `atomic_swap` * `atomic_add` * `atomic_sub` * `atomic_compare_exchange` * `atomic_compare_exchange_weak` * `atomic_and` * `atomic_nand` * `atomic_or` * `atomic_xor` * `atomic_max` * `atomic_min` * `atomic_umax` * `atomic_umin` However, none of those functions and macros actually depend on 8-bit width and they are needed for all atomic widths (16-bit, 32-bit, 64-bit etc.). Some targets might not support 8-bit atomics (i.e. BPF, if we would enable atomic CAS for it). This change fixes that by removing the `"8"` argument from annotations, which results in accepting the whole variety of widths. Fixes rust-lang#106845 Fixes rust-lang#106795 Signed-off-by: Michal Rostecki <[email protected]>
JohnTitor
added a commit
to JohnTitor/rust
that referenced
this issue
Jan 27, 2023
… r=joshtriplett core: Support variety of atomic widths in width-agnostic functions Before this change, the following functions and macros were annotated with `#[cfg(target_has_atomic = "8")]` or `#[cfg(target_has_atomic_load_store = "8")]`: * `atomic_int` * `strongest_failure_ordering` * `atomic_swap` * `atomic_add` * `atomic_sub` * `atomic_compare_exchange` * `atomic_compare_exchange_weak` * `atomic_and` * `atomic_nand` * `atomic_or` * `atomic_xor` * `atomic_max` * `atomic_min` * `atomic_umax` * `atomic_umin` However, none of those functions and macros actually depend on 8-bit width and they are needed for all atomic widths (16-bit, 32-bit, 64-bit etc.). Some targets might not support 8-bit atomics (i.e. BPF, if we would enable atomic CAS for it). This change fixes that by removing the `"8"` argument from annotations, which results in accepting the whole variety of widths. Fixes rust-lang#106845 Fixes rust-lang#106795 Signed-off-by: Michal Rostecki <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This issue was discussed at #106795
and at #106796 (comment)
Some functions in
core::sync
are defined to only compile if the target has 8-bit atomic support. While they should be compiled for all targets with atomic support.This can cause unnecessary compilation issues when using a custom target json.
This can probably be solved by changing the definitions to
from
#[cfg(target_has_atomic = "8")]
like you can see at vadorovsky@041978b
Examples:
rust/library/core/src/sync/atomic.rs
Lines 3014 to 3016 in bfffe40
rust/library/core/src/sync/atomic.rs
Lines 3047 to 3049 in bfffe40
rust/library/core/src/sync/atomic.rs
Lines 3133 to 3135 in bfffe40
@vadorovsky @alessandrod
The text was updated successfully, but these errors were encountered: