Skip to content

Commit c0cb6b6

Browse files
committed
Mark atomic __sync_* intrinsics always strong on android
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
1 parent 0bd840c commit c0cb6b6

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

src/arm_linux.rs

+3
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ unsafe fn atomic_cmpxchg<T>(ptr: *mut T, oldval: u32, newval: u32) -> u32 {
9191
macro_rules! atomic_rmw {
9292
($name:ident, $ty:ty, $op:expr, $fetch:expr) => {
9393
intrinsics! {
94+
#[always_strong_if(target_os = "android")]
9495
pub unsafe extern "C" fn $name(ptr: *mut $ty, val: $ty) -> $ty {
9596
atomic_rmw(ptr, |x| $op(x as $ty, val) as u32, |old, new| $fetch(old, new)) as $ty
9697
}
@@ -105,9 +106,11 @@ macro_rules! atomic_rmw {
105106
atomic_rmw!($name, $ty, $op, |_, new| new);
106107
};
107108
}
109+
108110
macro_rules! atomic_cmpxchg {
109111
($name:ident, $ty:ty) => {
110112
intrinsics! {
113+
#[always_strong_if(target_os = "android")]
111114
pub unsafe extern "C" fn $name(ptr: *mut $ty, oldval: $ty, newval: $ty) -> $ty {
112115
atomic_cmpxchg(ptr, oldval as u32, newval as u32) as $ty
113116
}

src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#![allow(clippy::manual_swap)]
2828
// Support compiling on both stage0 and stage1 which may differ in supported stable features.
2929
#![allow(stable_features)]
30+
#![recursion_limit = "256"] // We have some large macros
3031

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

0 commit comments

Comments
 (0)