Skip to content

Commit 27f6ed9

Browse files
ojhuntLukacma
authored andcommitted
[PAC][libunwind] Fix gcc build of libunwind and compiler-rt (llvm#164535)
This adds guards on the ptrauth feature checks so that they are only performed if __has_feature is actually available.
1 parent 45b95eb commit 27f6ed9

File tree

4 files changed

+19
-5
lines changed

4 files changed

+19
-5
lines changed

compiler-rt/lib/builtins/gcc_personality_v0.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ EXCEPTION_DISPOSITION _GCC_specific_handler(PEXCEPTION_RECORD, void *, PCONTEXT,
3030
_Unwind_Personality_Fn);
3131
#endif
3232

33+
#ifndef __has_feature
34+
#define __has_feature(__feature) 0
35+
#endif
36+
3337
#if __has_feature(ptrauth_calls)
3438
#include <ptrauth.h>
3539

libunwind/include/__libunwind_config.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -212,11 +212,13 @@
212212
# define _LIBUNWIND_HIGHEST_DWARF_REGISTER 287
213213
#endif // _LIBUNWIND_IS_NATIVE_ONLY
214214

215-
#if __has_feature(ptrauth_calls) && __has_feature(ptrauth_returns)
216-
# define _LIBUNWIND_TARGET_AARCH64_AUTHENTICATED_UNWINDING 1
217-
#elif __has_feature(ptrauth_calls) != __has_feature(ptrauth_returns)
218-
# error "Either both or none of ptrauth_calls and ptrauth_returns "\
219-
"is allowed to be enabled"
215+
#if defined(__has_feature)
216+
# if __has_feature(ptrauth_calls) && __has_feature(ptrauth_returns)
217+
# define _LIBUNWIND_TARGET_AARCH64_AUTHENTICATED_UNWINDING 1
218+
# elif __has_feature(ptrauth_calls) != __has_feature(ptrauth_returns)
219+
# error "Either both or none of ptrauth_calls and ptrauth_returns "\
220+
"is allowed to be enabled"
221+
# endif
220222
#endif
221223

222224
#endif // ____LIBUNWIND_CONFIG_H__

libunwind/src/UnwindRegistersRestore.S

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,10 @@ Lnovec:
634634

635635
#elif defined(__aarch64__)
636636

637+
#ifndef __has_feature
638+
#define __has_feature(__feature) 0
639+
#endif
640+
637641
#if defined(__ARM_FEATURE_GCS_DEFAULT)
638642
.arch_extension gcs
639643
#endif

libunwind/src/UnwindRegistersSave.S

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -763,6 +763,10 @@ LnoR2Fix:
763763

764764
#elif defined(__aarch64__)
765765

766+
#ifndef __has_feature
767+
#define __has_feature(__feature) 0
768+
#endif
769+
766770
//
767771
// extern int __unw_getcontext(unw_context_t* thread_state)
768772
//

0 commit comments

Comments
 (0)