Skip to content

Commit d1d1982

Browse files
committed
[PAC][compiler-rt] Do not use __has_feature with non-clang
See compile failure with gcc: llvm#96478 (comment) The `__has_feature` directive was not supported in gcc until ~ Nov 2023 gcc-mirror/gcc@06280a9
1 parent de5081c commit d1d1982

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

compiler-rt/lib/builtins/crtbegin.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ static void __attribute__((used)) __do_init(void) {
5454
}
5555

5656
#ifdef CRT_HAS_INITFINI_ARRAY
57+
#ifdef __clang__
5758
#if __has_feature(ptrauth_init_fini)
5859
// TODO: use __ptrauth-qualified pointers when they are supported on clang side
5960
#if __has_feature(ptrauth_init_fini_address_discrimination)
@@ -70,6 +71,10 @@ __attribute__((section(".init_array"), used)) static void *__init =
7071
__attribute__((section(".init_array"),
7172
used)) static void (*__init)(void) = __do_init;
7273
#endif
74+
#else
75+
__attribute__((section(".init_array"),
76+
used)) static void (*__init)(void) = __do_init;
77+
#endif
7378
#elif defined(__i386__) || defined(__x86_64__)
7479
__asm__(".pushsection .init,\"ax\",@progbits\n\t"
7580
"call __do_init\n\t"
@@ -125,6 +130,7 @@ static void __attribute__((used)) __do_fini(void) {
125130
}
126131

127132
#ifdef CRT_HAS_INITFINI_ARRAY
133+
#ifdef __clang__
128134
#if __has_feature(ptrauth_init_fini)
129135
// TODO: use __ptrauth-qualified pointers when they are supported on clang side
130136
#if __has_feature(ptrauth_init_fini_address_discrimination)
@@ -141,6 +147,10 @@ __attribute__((section(".fini_array"), used)) static void *__fini =
141147
__attribute__((section(".fini_array"),
142148
used)) static void (*__fini)(void) = __do_fini;
143149
#endif
150+
#else
151+
__attribute__((section(".fini_array"),
152+
used)) static void (*__fini)(void) = __do_fini;
153+
#endif
144154
#elif defined(__i386__) || defined(__x86_64__)
145155
__asm__(".pushsection .fini,\"ax\",@progbits\n\t"
146156
"call __do_fini\n\t"

0 commit comments

Comments
 (0)