[libunwind] [libunwind] Fix -Wunused-function for hasPAuthLR in ra_sign_state_lr (PR #236660)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Oct 28 21:57:15 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libunwind
Author: Naveen (hsnaveen2u)
<details>
<summary>Changes</summary>
hasPAuthLR() is a static function defined unconditionally in ra_sign_state_lr.pass.cpp but it is only called from checkHasPAuthLR() when _LIBUNWIND_HAVE_GETAUXVAL, LIBUNWIND_HAVE_ELF_AUX_INFO or LIBUNWIND_IS_BAREMETAL is defined. On targets where none of these macros are set (e.g. embedded AArch64 variants built against picolibc), the #else branch is taken and hasPAuthLR() is unused causing a -Werror,-Wunused-function build failure.
Guard hasPAuthLR() with the same preprocessor conditions as its call-sites so it is only compiled when reachable.
---
Full diff: https://github.com/llvm/llvm-project/pull/236660.diff
1 Files Affected:
- (modified) libunwind/test/ra_sign_state_lr.pass.cpp (+3)
``````````diff
diff --git a/libunwind/test/ra_sign_state_lr.pass.cpp b/libunwind/test/ra_sign_state_lr.pass.cpp
index efcdbbbaf820c6..b3292b71f4fe06 100644
--- a/libunwind/test/ra_sign_state_lr.pass.cpp
+++ b/libunwind/test/ra_sign_state_lr.pass.cpp
@@ -37,6 +37,8 @@
// Note: This test requires FEAT_PAuth_LR (and is setup to pass on other
// targets).
+#if defined(_LIBUNWIND_HAVE_GETAUXVAL) || defined(_LIBUNWIND_HAVE_ELF_AUX_INFO) || \
+ defined(_LIBUNWIND_IS_BAREMETAL)
static bool hasPAuthLR() {
uint64_t isa_r1, isa_r2;
asm("mrs %0, ID_AA64ISAR1_EL1" : "=r"(isa_r1));
@@ -48,6 +50,7 @@ static bool hasPAuthLR() {
return api == 6 || apa == 6 || apa3 == 6;
}
+#endif
#if defined(_LIBUNWIND_HAVE_GETAUXVAL)
static bool checkHasPAuthLR() {
``````````
</details>
https://github.com/llvm/llvm-project/pull/236660
More information about the cfe-commits
mailing list