Skip to content

Commit e9870d6

Browse files
committed
libunwind: Do not use __attribute__((target("gcs"))) with non-clang compilers
unwindlib: Use +gcs instead of gcs target attribute GCC-15 has added gcs intrinsics [1] but the syntax for enabling it is slightly different. This syntax works with clang too. With gcc15 compiler libunwind's check for this macros is succeeding and it ends up enabling 'gcs' by using function attribute, this works with clang but not with gcc but '+gcs' works with both We can see this in rust compiler bootstrap for aarch64/musl when system uses gcc15, it ends up with these errors Building libunwind.a for aarch64-poky-linux-musl cargo:warning=/mnt/b/yoe/master/sources/poky/build/tmp/work/cortexa57-poky-linux-musl/rust/1.85.1/rustc-1.85.1-src/src/llvm-project/libunwind/src/UnwindLevel1.c:191:1: error: arch extension 'gcs' should be prefixed by '+' cargo:warning= 191 | unwind_phase2(unw_context_t *uc, unw_cursor_t *cursor, _Unwind_Exception *exception_object) { cargo:warning= | ^~~~~~~~~~~~~ cargo:warning=/mnt/b/yoe/master/sources/poky/build/tmp/work/cortexa57-poky-linux-musl/rust/1.85.1/rustc-1.85.1-src/src/llvm-project/libunwind/src/UnwindLevel1.c:337:22: error: arch extension 'gcs' should be prefixed by '+' cargo:warning= 337 | _Unwind_Stop_Fn stop, void *stop_parameter) { cargo:warning= | ^~~~~~~~~~~~~~~ [1] https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=5a6af707f0af Signed-off-by: Khem Raj <[email protected]>
1 parent c588224 commit e9870d6

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

libunwind/src/UnwindLevel1.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ extern int __unw_step_stage2(unw_cursor_t *);
188188

189189
#if defined(_LIBUNWIND_USE_GCS)
190190
// Enable the GCS target feature to permit gcspop instructions to be used.
191-
__attribute__((target("gcs")))
191+
__attribute__((target("+gcs")))
192192
#endif
193193
static _Unwind_Reason_Code
194194
unwind_phase2(unw_context_t *uc, unw_cursor_t *cursor, _Unwind_Exception *exception_object) {
@@ -332,7 +332,7 @@ unwind_phase2(unw_context_t *uc, unw_cursor_t *cursor, _Unwind_Exception *except
332332

333333
#if defined(_LIBUNWIND_USE_GCS)
334334
// Enable the GCS target feature to permit gcspop instructions to be used.
335-
__attribute__((target("gcs")))
335+
__attribute__((target("+gcs")))
336336
#endif
337337
static _Unwind_Reason_Code
338338
unwind_phase2_forced(unw_context_t *uc, unw_cursor_t *cursor,

libunwind/src/shadow_stack_unwind.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
#include <arm_acle.h>
4343

4444
// We can only use GCS if arm_acle.h defines the GCS intrinsics.
45-
#ifdef _CHKFEAT_GCS
45+
#if defined(_CHKFEAT_GCS)
4646
#define _LIBUNWIND_USE_GCS 1
4747
#endif
4848

0 commit comments

Comments
 (0)