[compiler-rt] [libunwind] [PAC][libunwind] Fix gcc build of libunwind and compiler-rt (PR #164535)
Oliver Hunt via cfe-commits
cfe-commits at lists.llvm.org
Wed Oct 22 01:46:27 PDT 2025
https://github.com/ojhunt updated https://github.com/llvm/llvm-project/pull/164535
>From 540f395815ce331ffca429a8092f5c200510db4e Mon Sep 17 00:00:00 2001
From: Oliver Hunt <oliver at apple.com>
Date: Tue, 21 Oct 2025 19:19:04 -0700
Subject: [PATCH] [PAC][libunwind] Fix gcc build of libunwind and compiler-rt
This adds guards on the ptrauth feature checks so that they are
only performed if __has_feature is actually available.
---
compiler-rt/lib/builtins/gcc_personality_v0.c | 4 ++++
libunwind/include/__libunwind_config.h | 12 +++++++-----
libunwind/src/UnwindRegistersRestore.S | 4 ++++
libunwind/src/UnwindRegistersSave.S | 4 ++++
4 files changed, 19 insertions(+), 5 deletions(-)
diff --git a/compiler-rt/lib/builtins/gcc_personality_v0.c b/compiler-rt/lib/builtins/gcc_personality_v0.c
index 3ed17fa788c28..6d92a7b248f3c 100644
--- a/compiler-rt/lib/builtins/gcc_personality_v0.c
+++ b/compiler-rt/lib/builtins/gcc_personality_v0.c
@@ -30,6 +30,10 @@ EXCEPTION_DISPOSITION _GCC_specific_handler(PEXCEPTION_RECORD, void *, PCONTEXT,
_Unwind_Personality_Fn);
#endif
+#ifndef __has_feature
+#define __has_feature(__feature) 0
+#endif
+
#if __has_feature(ptrauth_calls)
#include <ptrauth.h>
diff --git a/libunwind/include/__libunwind_config.h b/libunwind/include/__libunwind_config.h
index 343934e885368..980d11ef5d4f2 100644
--- a/libunwind/include/__libunwind_config.h
+++ b/libunwind/include/__libunwind_config.h
@@ -212,11 +212,13 @@
# define _LIBUNWIND_HIGHEST_DWARF_REGISTER 287
#endif // _LIBUNWIND_IS_NATIVE_ONLY
-#if __has_feature(ptrauth_calls) && __has_feature(ptrauth_returns)
-# define _LIBUNWIND_TARGET_AARCH64_AUTHENTICATED_UNWINDING 1
-#elif __has_feature(ptrauth_calls) != __has_feature(ptrauth_returns)
-# error "Either both or none of ptrauth_calls and ptrauth_returns "\
- "is allowed to be enabled"
+#if defined(__has_feature)
+# if __has_feature(ptrauth_calls) && __has_feature(ptrauth_returns)
+# define _LIBUNWIND_TARGET_AARCH64_AUTHENTICATED_UNWINDING 1
+# elif __has_feature(ptrauth_calls) != __has_feature(ptrauth_returns)
+# error "Either both or none of ptrauth_calls and ptrauth_returns "\
+ "is allowed to be enabled"
+# endif
#endif
#endif // ____LIBUNWIND_CONFIG_H__
diff --git a/libunwind/src/UnwindRegistersRestore.S b/libunwind/src/UnwindRegistersRestore.S
index 1ab4c43b673b4..198735fa800a9 100644
--- a/libunwind/src/UnwindRegistersRestore.S
+++ b/libunwind/src/UnwindRegistersRestore.S
@@ -634,6 +634,10 @@ Lnovec:
#elif defined(__aarch64__)
+#ifndef __has_feature
+#define __has_feature(__feature) 0
+#endif
+
#if defined(__ARM_FEATURE_GCS_DEFAULT)
.arch_extension gcs
#endif
diff --git a/libunwind/src/UnwindRegistersSave.S b/libunwind/src/UnwindRegistersSave.S
index 31a177f4a0df4..619a59751151e 100644
--- a/libunwind/src/UnwindRegistersSave.S
+++ b/libunwind/src/UnwindRegistersSave.S
@@ -763,6 +763,10 @@ LnoR2Fix:
#elif defined(__aarch64__)
+#ifndef __has_feature
+#define __has_feature(__feature) 0
+#endif
+
//
// extern int __unw_getcontext(unw_context_t* thread_state)
//
More information about the cfe-commits
mailing list