summaryrefslogtreecommitdiff
path: root/libunwind
diff options
context:
space:
mode:
authorOliver Hunt <oliver@apple.com>2025-10-22 13:41:50 -0700
committerGitHub <noreply@github.com>2025-10-22 13:41:50 -0700
commitc1678e52f956f75f62d3240cf89d69c90b6505a4 (patch)
tree5f8757d8a06cf3b501c3751eea2079a17d62a357 /libunwind
parentbfc322dd724735bedf763705f373749dd1b7ed65 (diff)
[PAC][libunwind] Fix gcc build of libunwind and compiler-rt (#164535)
This adds guards on the ptrauth feature checks so that they are only performed if __has_feature is actually available.
Diffstat (limited to 'libunwind')
-rw-r--r--libunwind/include/__libunwind_config.h12
-rw-r--r--libunwind/src/UnwindRegistersRestore.S4
-rw-r--r--libunwind/src/UnwindRegistersSave.S4
3 files changed, 15 insertions, 5 deletions
diff --git a/libunwind/include/__libunwind_config.h b/libunwind/include/__libunwind_config.h
index 343934e88536..980d11ef5d4f 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 1ab4c43b673b..198735fa800a 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 31a177f4a0df..619a59751151 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)
//