Skip to content

Commit b46f344

Browse files
authored
libunwind: Do not use __attribute__((target("gcs"))) with non-clang compilers (#138077)
This attribute is unsupported in GCC, so far it worked because before GCC15 did not define this macros in _CHKFEAT_GCS in arm_acle.h [1] 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. 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 d8118ed commit b46f344

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

libunwind/src/UnwindLevel1.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -188,10 +188,11 @@ 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
194-
unwind_phase2(unw_context_t *uc, unw_cursor_t *cursor, _Unwind_Exception *exception_object) {
194+
unwind_phase2(unw_context_t *uc, unw_cursor_t *cursor,
195+
_Unwind_Exception *exception_object) {
195196
__unw_init_local(cursor, uc);
196197

197198
_LIBUNWIND_TRACE_UNWINDING("unwind_phase2(ex_obj=%p)",
@@ -332,12 +333,12 @@ unwind_phase2(unw_context_t *uc, unw_cursor_t *cursor, _Unwind_Exception *except
332333

333334
#if defined(_LIBUNWIND_USE_GCS)
334335
// Enable the GCS target feature to permit gcspop instructions to be used.
335-
__attribute__((target("gcs")))
336+
__attribute__((target("+gcs")))
336337
#endif
337338
static _Unwind_Reason_Code
338339
unwind_phase2_forced(unw_context_t *uc, unw_cursor_t *cursor,
339-
_Unwind_Exception *exception_object,
340-
_Unwind_Stop_Fn stop, void *stop_parameter) {
340+
_Unwind_Exception *exception_object, _Unwind_Stop_Fn stop,
341+
void *stop_parameter) {
341342
__unw_init_local(cursor, uc);
342343

343344
// uc is initialized by __unw_getcontext in the parent frame. The first stack
@@ -443,7 +444,6 @@ unwind_phase2_forced(unw_context_t *uc, unw_cursor_t *cursor,
443444
return _URC_FATAL_PHASE2_ERROR;
444445
}
445446

446-
447447
/// Called by __cxa_throw. Only returns if there is a fatal error.
448448
_LIBUNWIND_EXPORT _Unwind_Reason_Code
449449
_Unwind_RaiseException(_Unwind_Exception *exception_object) {

0 commit comments

Comments
 (0)