Skip to content

Commit 76a4adc

Browse files
committed
compiler-builtins: Account for Apple symbol access syntax
1 parent bed4250 commit 76a4adc

File tree

1 file changed

+25
-7
lines changed

1 file changed

+25
-7
lines changed

‎library/compiler-builtins/compiler-builtins/src/aarch64_outline_atomics.rs‎

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -135,18 +135,36 @@ macro_rules! stxp {
135135
};
136136
}
137137

138+
// Apple and Elf have different symbol access syntax
139+
#[cfg(not(target_vendor = "apple"))]
140+
macro_rules! sym {
141+
($sym:literal) => { $sym }
142+
}
143+
#[cfg(target_vendor = "apple")]
144+
macro_rules! sym {
145+
($sym:literal) => { concat!($sym, "@PAGE") }
146+
}
147+
#[cfg(not(target_vendor = "apple"))]
148+
macro_rules! sym_off {
149+
($sym:literal) => { concat!(":lo12:", $sym) }
150+
}
151+
#[cfg(target_vendor = "apple")]
152+
macro_rules! sym_off {
153+
($sym:literal) => { concat!($sym, "@PAGEOFF") }
154+
}
155+
138156
// If supported, perform the requested LSE op and return, or fallthrough.
139157
macro_rules! try_lse_op {
140158
($op: literal, $ordering:ident, $bytes:tt, $($reg:literal,)* [ $mem:ident ] ) => {
141159
concat!(
142-
".arch_extension lse; ",
143-
"adrp x16, {have_lse}; ",
144-
"ldrb w16, [x16, :lo12:{have_lse}]; ",
145-
"cbz w16, 8f; ",
160+
".arch_extension lse\n",
161+
concat!("adrp x16, ", sym!("{have_lse}"), "\n"),
162+
concat!("ldrb w16, [x16, ", sym_off!("{have_lse}"), "]\n"),
163+
"cbz w16, 8f\n",
146164
// LSE_OP s(reg),* [$mem]
147-
concat!(lse!($op, $ordering, $bytes), $( " ", reg!($bytes, $reg), ", " ,)* "[", stringify!($mem), "]; ",),
148-
"ret; ",
149-
"8:"
165+
concat!(lse!($op, $ordering, $bytes), $( " ", reg!($bytes, $reg), ", " ,)* "[", stringify!($mem), "]\n",),
166+
"ret
167+
8:"
150168
)
151169
};
152170
}

0 commit comments

Comments
 (0)