git: b2cfac207d60 - stable/13 - compiler-rt: add aarch64 init function for LSE atomics
Dimitry Andric
dim at FreeBSD.org
Tue Sep 21 18:18:27 UTC 2021
The branch stable/13 has been updated by dim:
URL: https://cgit.FreeBSD.org/src/commit/?id=b2cfac207d60904b3a4738224361b8bf157724bb
commit b2cfac207d60904b3a4738224361b8bf157724bb
Author: Dimitry Andric <dim at FreeBSD.org>
AuthorDate: 2021-09-06 19:23:10 +0000
Commit: Dimitry Andric <dim at FreeBSD.org>
CommitDate: 2021-09-21 18:17:05 +0000
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 at klop.ws>
Fixes: cc55ee8009a5
PR: 257392
(cherry picked from commit efe67f33c322265eb303ec0ab40275100795b22a)
---
contrib/llvm-project/compiler-rt/lib/builtins/cpu_model.c | 6 ++++++
lib/libcompiler_rt/Makefile.inc | 5 +++--
2 files changed, 9 insertions(+), 2 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>)
diff --git a/lib/libcompiler_rt/Makefile.inc b/lib/libcompiler_rt/Makefile.inc
index aa0a6a6c9e69..06d662e38d82 100644
--- a/lib/libcompiler_rt/Makefile.inc
+++ b/lib/libcompiler_rt/Makefile.inc
@@ -146,8 +146,9 @@ SRCF+= floatundisf
SRCF+= floatundixf
.endif
-# __cpu_model support, only used on x86
-.if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386"
+# __cpu_model support, only used on aarch64 and x86
+.if ${MACHINE_CPUARCH} == "aarch64" || ${MACHINE_CPUARCH} == "amd64" || \
+ ${MACHINE_CPUARCH} == "i386"
SRCF+= cpu_model
.endif
More information about the dev-commits-src-all
mailing list