Skip to content

Commit

Permalink
Mark atomic __sync_* intrinsics always strong on android
Browse files Browse the repository at this point in the history
After <rust-lang#598>,
arm-android was failing to complete in CI because it was hanging on some
tests. This issue appears to have been caused by symbols related to
atomics, e.g. `__sync_val_compare_and_swap_4`, to have become weak.

It turns out that these symbols were always strong before, even though
Android was always setting the `weak-intrinsics` feature. So, making
them weak presumably caused the system implementation to get linked,
which appears buggy.

Resolve this by making `__sync_*` symbols weak on Android.

(this includes a recursion limit increase, our macros are getting big).

Link: rust-lang#641
  • Loading branch information
tgross35 committed Jul 18, 2024
1 parent 0bd840c commit c0cb6b6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/arm_linux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ unsafe fn atomic_cmpxchg<T>(ptr: *mut T, oldval: u32, newval: u32) -> u32 {
macro_rules! atomic_rmw {
($name:ident, $ty:ty, $op:expr, $fetch:expr) => {
intrinsics! {
#[always_strong_if(target_os = "android")]
pub unsafe extern "C" fn $name(ptr: *mut $ty, val: $ty) -> $ty {
atomic_rmw(ptr, |x| $op(x as $ty, val) as u32, |old, new| $fetch(old, new)) as $ty
}
Expand All @@ -105,9 +106,11 @@ macro_rules! atomic_rmw {
atomic_rmw!($name, $ty, $op, |_, new| new);
};
}

macro_rules! atomic_cmpxchg {
($name:ident, $ty:ty) => {
intrinsics! {
#[always_strong_if(target_os = "android")]
pub unsafe extern "C" fn $name(ptr: *mut $ty, oldval: $ty, newval: $ty) -> $ty {
atomic_cmpxchg(ptr, oldval as u32, newval as u32) as $ty
}
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#![allow(clippy::manual_swap)]
// Support compiling on both stage0 and stage1 which may differ in supported stable features.
#![allow(stable_features)]
#![recursion_limit = "256"] // We have some large macros

// We disable #[no_mangle] for tests so that we can verify the test results
// against the native compiler-rt implementations of the builtins.
Expand Down

0 comments on commit c0cb6b6

Please sign in to comment.