https://github.com/kraj updated https://github.com/llvm/llvm-project/pull/138077

>From aabc92ee06f3ccf89bcccf759c50a667d4eada0c Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.k...@gmail.com>
Date: Wed, 30 Apr 2025 19:51:19 -0700
Subject: [PATCH] libunwind: Use +gcs instead of gcs target attribute

__attribute__((target("gcs"))) does not work with gcc

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 <raj.k...@gmail.com>
---
 libunwind/src/UnwindLevel1.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libunwind/src/UnwindLevel1.c b/libunwind/src/UnwindLevel1.c
index a258a832a9c31..ccc36fab1ee88 100644
--- a/libunwind/src/UnwindLevel1.c
+++ b/libunwind/src/UnwindLevel1.c
@@ -188,7 +188,7 @@ extern int __unw_step_stage2(unw_cursor_t *);
 
 #if defined(_LIBUNWIND_USE_GCS)
 // Enable the GCS target feature to permit gcspop instructions to be used.
-__attribute__((target("gcs")))
+__attribute__((target("+gcs")))
 #endif
 static _Unwind_Reason_Code
 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
 
 #if defined(_LIBUNWIND_USE_GCS)
 // Enable the GCS target feature to permit gcspop instructions to be used.
-__attribute__((target("gcs")))
+__attribute__((target("+gcs")))
 #endif
 static _Unwind_Reason_Code
 unwind_phase2_forced(unw_context_t *uc, unw_cursor_t *cursor,

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to