[libunwind] libunwind: Do not use __attribute__((target("gcs"))) with non-clang … (PR #138077)

via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 30 20:00:31 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libunwind

Author: Khem Raj (kraj)

<details>
<summary>Changes</summary>

…compilers

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

---
Full diff: https://github.com/llvm/llvm-project/pull/138077.diff


1 Files Affected:

- (modified) libunwind/src/UnwindLevel1.c (+2-2) 


``````````diff
diff --git a/libunwind/src/UnwindLevel1.c b/libunwind/src/UnwindLevel1.c
index a258a832a9c31..4771632c49c31 100644
--- a/libunwind/src/UnwindLevel1.c
+++ b/libunwind/src/UnwindLevel1.c
@@ -186,7 +186,7 @@ unwind_phase1(unw_context_t *uc, unw_cursor_t *cursor, _Unwind_Exception *except
 }
 extern int __unw_step_stage2(unw_cursor_t *);
 
-#if defined(_LIBUNWIND_USE_GCS)
+#if defined(_LIBUNWIND_USE_GCS) && defined(__clang__)
 // Enable the GCS target feature to permit gcspop instructions to be used.
 __attribute__((target("gcs")))
 #endif
@@ -330,7 +330,7 @@ unwind_phase2(unw_context_t *uc, unw_cursor_t *cursor, _Unwind_Exception *except
   return _URC_FATAL_PHASE2_ERROR;
 }
 
-#if defined(_LIBUNWIND_USE_GCS)
+#if defined(_LIBUNWIND_USE_GCS) && defined(__clang__)
 // Enable the GCS target feature to permit gcspop instructions to be used.
 __attribute__((target("gcs")))
 #endif

``````````

</details>


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


More information about the cfe-commits mailing list