[compiler-rt] [compiler-rt][AArch64][Android] Use getauxval on Android. (PR #102979)
Daniel Kiss via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 13 06:57:10 PDT 2024
https://github.com/DanielKristofKiss updated https://github.com/llvm/llvm-project/pull/102979
>From 3d36920a76e992c9a723ca4d3bccee8d0bef3251 Mon Sep 17 00:00:00 2001
From: Daniel Kiss <daniel.kiss at arm.com>
Date: Mon, 12 Aug 2024 23:05:50 +0200
Subject: [PATCH 1/3] [compiler-rt][AArch64][Android] Use getauxval on Android.
__getauxval is a libgcc function that doesn't exist on Android.
---
compiler-rt/lib/builtins/aarch64/sme-abi-init.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/compiler-rt/lib/builtins/aarch64/sme-abi-init.c b/compiler-rt/lib/builtins/aarch64/sme-abi-init.c
index b6ee12170d56db..8b6715bd2254cd 100644
--- a/compiler-rt/lib/builtins/aarch64/sme-abi-init.c
+++ b/compiler-rt/lib/builtins/aarch64/sme-abi-init.c
@@ -7,7 +7,8 @@ _Bool __aarch64_has_sme_and_tpidr2_el0;
// We have multiple ways to check that the function has SME, depending on our
// target.
-// * For Linux we can use __getauxval().
+// * For Linux/glibc we can use __getauxval().
+// * For Android we can use getauxval().
// * For newlib we can use __aarch64_sme_accessible().
#if defined(__linux__)
@@ -20,11 +21,15 @@ _Bool __aarch64_has_sme_and_tpidr2_el0;
#define HWCAP2_SME (1 << 23)
#endif
+#ifdef __ANDROID__
+extern unsigned long int getauxval(unsigned long int);
+#define GETAUXVAL(x) getauxval(x)
+#else
extern unsigned long int __getauxval (unsigned long int);
+#define GETAUXVAL(x) __getauxval(x)
+#endif
-static _Bool has_sme(void) {
- return __getauxval(AT_HWCAP2) & HWCAP2_SME;
-}
+static _Bool has_sme(void) { return GETAUXVAL(AT_HWCAP2) & HWCAP2_SME; }
#else // defined(__linux__)
>From 4f12df164a77ab352303c3c4d9368df44783ad59 Mon Sep 17 00:00:00 2001
From: Daniel Kiss <daniel.kiss at arm.com>
Date: Tue, 13 Aug 2024 08:33:32 +0200
Subject: [PATCH 2/3] drop __getauxval support, compiler-rt anyway usues
getauxval everywhere.
---
.../lib/builtins/aarch64/sme-abi-init.c | 23 +++++++------------
1 file changed, 8 insertions(+), 15 deletions(-)
diff --git a/compiler-rt/lib/builtins/aarch64/sme-abi-init.c b/compiler-rt/lib/builtins/aarch64/sme-abi-init.c
index 8b6715bd2254cd..c888acab202c5a 100644
--- a/compiler-rt/lib/builtins/aarch64/sme-abi-init.c
+++ b/compiler-rt/lib/builtins/aarch64/sme-abi-init.c
@@ -7,29 +7,22 @@ _Bool __aarch64_has_sme_and_tpidr2_el0;
// We have multiple ways to check that the function has SME, depending on our
// target.
-// * For Linux/glibc we can use __getauxval().
+// * For Linux/Glibc we can use getauxval().
// * For Android we can use getauxval().
// * For newlib we can use __aarch64_sme_accessible().
#if defined(__linux__)
-#ifndef AT_HWCAP2
-#define AT_HWCAP2 26
-#endif
-
-#ifndef HWCAP2_SME
-#define HWCAP2_SME (1 << 23)
-#endif
-
-#ifdef __ANDROID__
-extern unsigned long int getauxval(unsigned long int);
-#define GETAUXVAL(x) getauxval(x)
+#if defined(__ANDROID__)
+#include <sys/auxv.h>
+#elif __has_include(<sys/auxv.h>)
+#include <sys/auxv.h>
#else
-extern unsigned long int __getauxval (unsigned long int);
-#define GETAUXVAL(x) __getauxval(x)
+#define getauxval(x) 0
#endif
+#include "cpumodel/aarch64/hwcap.inc"
-static _Bool has_sme(void) { return GETAUXVAL(AT_HWCAP2) & HWCAP2_SME; }
+static _Bool has_sme(void) { return getauxval(AT_HWCAP2) & HWCAP2_SME; }
#else // defined(__linux__)
>From ef5bdd0f5513b5b60cf0a405edb6e8d2e5285095 Mon Sep 17 00:00:00 2001
From: Daniel Kiss <daniel.kiss at arm.com>
Date: Tue, 13 Aug 2024 15:56:40 +0200
Subject: [PATCH 3/3] fix typo
---
compiler-rt/lib/builtins/aarch64/sme-abi-init.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/compiler-rt/lib/builtins/aarch64/sme-abi-init.c b/compiler-rt/lib/builtins/aarch64/sme-abi-init.c
index c888acab202c5a..d3cd8278a5d214 100644
--- a/compiler-rt/lib/builtins/aarch64/sme-abi-init.c
+++ b/compiler-rt/lib/builtins/aarch64/sme-abi-init.c
@@ -20,7 +20,7 @@ _Bool __aarch64_has_sme_and_tpidr2_el0;
#else
#define getauxval(x) 0
#endif
-#include "cpumodel/aarch64/hwcap.inc"
+#include "../cpu_model/aarch64/hwcap.inc"
static _Bool has_sme(void) { return getauxval(AT_HWCAP2) & HWCAP2_SME; }
More information about the llvm-commits
mailing list