-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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 integer atomic types #33048
Add integer atomic types #33048
Conversation
r? @aturon (rust_highfive has picked a reviewer for you, use r? to override) |
5d10633
to
59a66d4
Compare
Thanks @Amanieu! Some thoughts of mine:
|
@@ -23,6 +23,7 @@ pub fn target() -> Target { | |||
options: TargetOptions { | |||
features: "+neon,+fp-armv8,+cyclone".to_string(), | |||
eliminate_frame_pointer: false, | |||
max_atomic_width: 128, |
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.
Just confirming, but this is inherent to aarch64 (e.g. 128-bit atomics are available everywhere?)
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.
Yes
Gah, I hit enter too quickly...
I wonder if this can also try to have a more comprehensive test? We don't run tests for platforms like ARM/MIPS/etc, but it'd be good to exercise those platforms as they're quite relevant here. Also, cc @rust-lang/libs, @brson |
The reason I left them out is because they use different stability attributes (
This is a bit complicated because some early AMD x86_64 CPUs don't support cmpxchg16b. Support for this instruction can be enabled in LLVM by targeting a CPU that supports it (which the OSX target does with I don't think there is a way to extract the maximum atomic size from LLVM's API. I've mostly copied what Clang does, which is to determine it from the target architecture and any compilation flags passed in (
Yes, these will never be lowered to compiler-rt calls. The test should be able to catch any cases that are lowered to libcalls.
How would you suggest doing this? |
59a66d4
to
7078819
Compare
Should I reuse the |
de5dcb7
to
f794e48
Compare
Right yeah, but perhaps that could be an input to the macro? (e.g. the macro takes a stability attribute as input)
Only statically, though, right? If I pass
Unfortunately this test won't catch anything because it's only run on x86_64 and x86 for now.
A "minimal cross-compiled libcore" could probably suffice. Something with a few lang items enough to just generate an object file should be enough. You could then call the intrinsics directly to ensure they're not lowered to libcalls. |
No, for that we would need to be able to recognize all the CPU variant and set the appropriate LLVM flags for them. See Clang: http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20130930/090167.html |
Should we expose |
Also, should I add constants like |
a86ad7f
to
702813d
Compare
Done
Done |
Yeah that's kinda unfortunate for now, although we're not even exposing the 128-bit types just yet, so it's ok to punt on this for now.
Nah I wouldn't bother. If it's easier to write the macro where they all have
Indeed! Awesome, thanks for the updates! |
702813d
to
7a2c77e
Compare
I've added the constants, is there anything else to do? |
Looks good to me, thanks @Amanieu! I want to double check with @rust-lang/libs about the |
Are the constants not going to be deprecated once |
They likely will be, yes, but |
missing comma |
Fixed |
@bors: r+ 1a6530803e1c38a105274d0554306fede183d9ce |
⌛ Testing commit 1a65308 with merge 4a133c2... |
💔 Test failed - auto-linux-64-cross-armsf |
Sorry about that, fixed again. |
@bors: r+ 033699ca561a7e8d2f33eee392a3a8a7373e891b |
⌛ Testing commit 033699c with merge 780897b... |
💔 Test failed - auto-win-gnu-32-opt-rustbuild |
☔ The latest upstream changes (presumably #33487) made this pull request unmergeable. Please resolve the merge conflicts. |
Rebased and changed the test to only run on Linux. |
Add integer atomic types Tracking issue: #32976 RFC: rust-lang/rfcs#1543 The changes to AtomicBool in the RFC are not included, they are in a separate PR (#32365).
…-abi, r=alexcrichton Update aarch64-linux-android target to match android abi. - Changed `target_env` to "gnu" to empty "" for all android targets because it does not matter for android. - The PR #33048 added "max_atomic_width" for arm-android but missed recently added armv7-android. Add it there too. - Added features `+neon,+fp-armv8` because they [must exist on `aarch64` android](http://developer.android.com/ndk/guides/cpu-features.html). - Update libc to include rust-lang/libc#282 so that rust's std lib works on android's aarch64 (the main issue there was incorrect structure alignment on 64-bit arm). r? @alexcrichton
Tracking issue: #32976
RFC: rust-lang/rfcs#1543
The changes to AtomicBool in the RFC are not included, they are in a separate PR (#32365).