summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools
diff options
context:
space:
mode:
authorKhem Raj <raj.khem@gmail.com>2025-04-30 23:33:39 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2025-05-01 14:22:54 +0100
commit6410bbd6a6057ad154f96d5d94991c8e833cbc7a (patch)
tree6f1137c141316460b29498cb392573fa9f616610 /meta/recipes-devtools
parente5902fa07b5d4874533e5a87ebbe9d4b0e66c3c0 (diff)
downloadpoky-6410bbd6a6057ad154f96d5d94991c8e833cbc7a.tar.gz
rust: Fix build with GCC-15 on aarch64/musl
GCC-15 has _CHKFEAT_GCS defined in arm_acle.h to indicate gcs intrinsics support, this trips llvm libunwind gcs feature detection logic to set gcs feature on. However the contructs used in unwindlib are assuming clang and the needed target attribute is not available in gcc it should be +gcs to work with both clang and gcc (From OE-Core rev: aa5b42b32093fdd10e0a8f8a124322610c84f60b) Signed-off-by: Khem Raj <raj.khem@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-devtools')
-rw-r--r--meta/recipes-devtools/rust/files/0001-libunwind-Use-gcs-instead-of-gcs-target-attribute.patch66
-rw-r--r--meta/recipes-devtools/rust/rust-source.inc1
2 files changed, 67 insertions, 0 deletions
diff --git a/meta/recipes-devtools/rust/files/0001-libunwind-Use-gcs-instead-of-gcs-target-attribute.patch b/meta/recipes-devtools/rust/files/0001-libunwind-Use-gcs-instead-of-gcs-target-attribute.patch
new file mode 100644
index 0000000000..a704671fb9
--- /dev/null
+++ b/meta/recipes-devtools/rust/files/0001-libunwind-Use-gcs-instead-of-gcs-target-attribute.patch
@@ -0,0 +1,66 @@
1From e4f4094de8ddcbe6d5ff1cdf782d2b89e0563903 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Wed, 30 Apr 2025 19:51:19 -0700
4Subject: [PATCH] libunwind: Use +gcs instead of gcs target attribute
5
6__attribute__((target("gcs"))) does not work with gcc
7
8GCC-15 has added gcs intrinsics [1] but the syntax for enabling it is
9slightly different. This syntax works with clang too.
10
11With gcc15 compiler libunwind's check for this macros is succeeding and it
12ends up enabling 'gcs' by using function attribute, this works with clang
13but not with gcc but '+gcs' works with both
14
15We can see this in rust compiler bootstrap for aarch64/musl when system
16uses gcc15, it ends up with these errors
17
18Building libunwind.a for aarch64-poky-linux-musl
19cargo: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 '+'
20cargo:warning= 191 | unwind_phase2(unw_context_t *uc, unw_cursor_t *cursor, _Unwind_Exception *exception_object) {
21cargo:warning= | ^~~~~~~~~~~~~
22cargo: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 '+'
23cargo:warning= 337 | _Unwind_Stop_Fn stop, void *stop_parameter) {
24cargo:warning= | ^~~~~~~~~~~~~~~
25
26[1] https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=5a6af707f0af
27
28Upstream-Status: Submitted [https://github.com/llvm/llvm-project/pull/138077]
29
30Signed-off-by: Khem Raj <raj.khem@gmail.com>
31---
32 src/llvm-project/libunwind/src/UnwindLevel1.c | 4 ++--
33 1 file changed, 2 insertions(+), 2 deletions(-)
34
35--- a/src/llvm-project/libunwind/src/UnwindLevel1.c
36+++ b/src/llvm-project/libunwind/src/UnwindLevel1.c
37@@ -185,7 +185,7 @@ extern int __unw_step_stage2(unw_cursor_
38
39 #if defined(_LIBUNWIND_USE_GCS)
40 // Enable the GCS target feature to permit gcspop instructions to be used.
41-__attribute__((target("gcs")))
42+__attribute__((target("+gcs")))
43 #endif
44 static _Unwind_Reason_Code
45 unwind_phase2(unw_context_t *uc, unw_cursor_t *cursor, _Unwind_Exception *exception_object) {
46@@ -329,7 +329,7 @@ unwind_phase2(unw_context_t *uc, unw_cur
47
48 #if defined(_LIBUNWIND_USE_GCS)
49 // Enable the GCS target feature to permit gcspop instructions to be used.
50-__attribute__((target("gcs")))
51+__attribute__((target("+gcs")))
52 #endif
53 static _Unwind_Reason_Code
54 unwind_phase2_forced(unw_context_t *uc, unw_cursor_t *cursor,
55--- a/src/llvm-project/libunwind/src/cet_unwind.h
56+++ b/src/llvm-project/libunwind/src/cet_unwind.h
57@@ -42,7 +42,8 @@
58 #include <arm_acle.h>
59
60 // We can only use GCS if arm_acle.h defines the GCS intrinsics.
61-#ifdef _CHKFEAT_GCS
62+// Enable gcs with clang for now, gcc does not build unwindlevel1.c correctly
63+#if defined(_CHKFEAT_GCS) && defined(__clang__)
64 #define _LIBUNWIND_USE_GCS 1
65 #endif
66
diff --git a/meta/recipes-devtools/rust/rust-source.inc b/meta/recipes-devtools/rust/rust-source.inc
index 25c0a1ce52..82d28cf09f 100644
--- a/meta/recipes-devtools/rust/rust-source.inc
+++ b/meta/recipes-devtools/rust/rust-source.inc
@@ -8,6 +8,7 @@ SRC_URI += "https://static.rust-lang.org/dist/rustc-${RUST_VERSION}-src.tar.xz;n
8 file://0001-src-core-build_steps-tool.rs-switch-off-lto-for-rust.patch;patchdir=${RUSTSRC} \ 8 file://0001-src-core-build_steps-tool.rs-switch-off-lto-for-rust.patch;patchdir=${RUSTSRC} \
9 file://revert-link-std-statically-in-rustc_driver-feature.patch;patchdir=${RUSTSRC} \ 9 file://revert-link-std-statically-in-rustc_driver-feature.patch;patchdir=${RUSTSRC} \
10 file://Zdual-proc-macros-additional-check.patch;patchdir=${RUSTSRC} \ 10 file://Zdual-proc-macros-additional-check.patch;patchdir=${RUSTSRC} \
11 file://0001-libunwind-Use-gcs-instead-of-gcs-target-attribute.patch;patchdir=${RUSTSRC} \
11" 12"
12SRC_URI[rust.sha256sum] = "b1fbf809efe9f036939401e142631c201a53bcf43ec1696bd9f5290ba236a266" 13SRC_URI[rust.sha256sum] = "b1fbf809efe9f036939401e142631c201a53bcf43ec1696bd9f5290ba236a266"
13 14