Skip to content

Commit ad2687d

Browse files
[compiler-rt] Check if the compiler supports __has_feature first
1 parent 9a2e825 commit ad2687d

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

compiler-rt/lib/builtins/gcc_personality_v0.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,13 @@ EXCEPTION_DISPOSITION _GCC_specific_handler(PEXCEPTION_RECORD, void *, PCONTEXT,
3030
_Unwind_Personality_Fn);
3131
#endif
3232

33+
#if defined(__has_feature)
3334
#if __has_feature(ptrauth_calls)
35+
#define __compiler_rt_use_ptrauth
36+
#endif
37+
#endif
38+
39+
#ifdef __compiler_rt_use_ptrauth
3440
#include <ptrauth.h>
3541

3642
// `__ptrauth_restricted_intptr` is a feature of apple clang that predates
@@ -292,7 +298,7 @@ COMPILER_RT_ABI _Unwind_Reason_Code __gcc_personality_v0(
292298
_Unwind_SetGR(context, __builtin_eh_return_data_regno(1), 0);
293299
size_t __ptrauth_gcc_personality_lpad landingPad =
294300
funcStart + landingPadOffset;
295-
#if __has_feature(ptrauth_calls)
301+
#ifdef __compiler_rt_use_ptrauth
296302
uintptr_t stackPointer = _Unwind_GetGR(context, -2);
297303
const uintptr_t existingDiscriminator = ptrauth_blend_discriminator(
298304
&landingPad, __ptrauth_gcc_personality_lpad_disc);

0 commit comments

Comments
 (0)