aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm-project/compiler-rt
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2021-09-06 19:23:10 +0000
committerDimitry Andric <dim@FreeBSD.org>2021-09-21 18:17:05 +0000
commitb2cfac207d60904b3a4738224361b8bf157724bb (patch)
treeab46cd3fcc0a3ae5dac37682472ab5502417f89b /contrib/llvm-project/compiler-rt
parent78a7d255e45dc04a389d4d2cc6697828a18245ae (diff)
downloadsrc-b2cfac207d60904b3a4738224361b8bf157724bb.tar.gz
src-b2cfac207d60904b3a4738224361b8bf157724bb.zip
compiler-rt: add aarch64 init function for LSE atomics
As reported by Ronald, adding the out-of-line LSE atomics helpers for aarch64 to compiler-rt was not sufficient to link programs using these, as they also require a __aarch64_have_lse_atomics global. This is initialized in compiler-rt's lib/builtins/cpu_model.c, roughly similar to the x86 CPU model and feature detection in that file. Since upstream does not yet have a FreeBSD specific implementation for getting the required information, add a simple one that should work for now, while I try to get it sorted with the LLVM people. Reported by: Ronald Klop <ronald-lists@klop.ws> Fixes: cc55ee8009a5 PR: 257392 (cherry picked from commit efe67f33c322265eb303ec0ab40275100795b22a)
Diffstat (limited to 'contrib/llvm-project/compiler-rt')
-rw-r--r--contrib/llvm-project/compiler-rt/lib/builtins/cpu_model.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/contrib/llvm-project/compiler-rt/lib/builtins/cpu_model.c b/contrib/llvm-project/compiler-rt/lib/builtins/cpu_model.c
index 51bedd98c3d3..13cfeb05dcb8 100644
--- a/contrib/llvm-project/compiler-rt/lib/builtins/cpu_model.c
+++ b/contrib/llvm-project/compiler-rt/lib/builtins/cpu_model.c
@@ -775,8 +775,14 @@ _Bool __aarch64_have_lse_atomics
#define HWCAP_ATOMICS (1 << 8)
#endif
static void CONSTRUCTOR_ATTRIBUTE init_have_lse_atomics(void) {
+#if defined(__FreeBSD__)
+ unsigned long hwcap;
+ int result = elf_aux_info(AT_HWCAP, &hwcap, sizeof hwcap);
+ __aarch64_have_lse_atomics = result == 0 && (hwcap & HWCAP_ATOMICS) != 0;
+#else
unsigned long hwcap = getauxval(AT_HWCAP);
__aarch64_have_lse_atomics = (hwcap & HWCAP_ATOMICS) != 0;
+#endif
}
#endif // defined(__has_include)
#endif // __has_include(<sys/auxv.h>)