Skip to content

Commit eb7f33d

Browse files
krajg-scott-murray
authored andcommitted
rust: Disable cross-unwinding support in llvm libunwind
This is default in LLVM but rust does not use cmake to build itself so it needs to replicate the behavior Fixes rust build with clang/musl for aarch64 Signed-off-by: Khem Raj <[email protected]> Signed-off-by: Mathieu Dubois-Briand <[email protected]> Signed-off-by: Richard Purdie <[email protected]> (adapted from oe-core commit f05d42d11e56cbbda6034bd7f773dc690b68bdbd) Signed-off-by: Scott Murray <[email protected]>
1 parent 0638216 commit eb7f33d

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
From 56b669cd7adcc413bb1e64c3d2d7c347a82ae35a Mon Sep 17 00:00:00 2001
2+
From: Khem Raj <[email protected]>
3+
Date: Wed, 21 May 2025 18:47:09 -0700
4+
Subject: [PATCH] Disable libunwind cross-architecture unwinding
5+
6+
Building with _LIBUNWIND_IS_NATIVE_ONLY disables code for cross-architecture unwinding
7+
it is disabled by default in LLVM [1], replicate the cmake behavior in bootstrap process
8+
9+
It also enables some additional code that handles PAC-specific unwind info
10+
it helps compiling with the -mbranch-protection=pac or -mbranch-protection=standard flags
11+
12+
This fixes build with clang/musl on aarch64
13+
14+
[1] https://github.com/llvm/llvm-project/commit/85624c5de3e831ffa01fdc2d159e3d69c30de08d
15+
16+
Upstream-Status: Submitted [https://github.com/rust-lang/rust/pull/141375]
17+
Signed-off-by: Khem Raj <[email protected]>
18+
---
19+
src/bootstrap/src/core/build_steps/llvm.rs | 3 +--
20+
1 file changed, 1 insertion(+), 2 deletions(-)
21+
22+
diff --git a/src/bootstrap/src/core/build_steps/llvm.rs b/src/bootstrap/src/core/build_steps/llvm.rs
23+
index a3788197471..5e4a1c7d9f0 100644
24+
--- a/src/bootstrap/src/core/build_steps/llvm.rs
25+
+++ b/src/bootstrap/src/core/build_steps/llvm.rs
26+
@@ -1430,6 +1430,7 @@ fn run(self, builder: &Builder<'_>) -> Self::Output {
27+
cfg.flag("-funwind-tables");
28+
cfg.flag("-fvisibility=hidden");
29+
cfg.define("_LIBUNWIND_DISABLE_VISIBILITY_ANNOTATIONS", None);
30+
+ cfg.define("_LIBUNWIND_IS_NATIVE_ONLY", "1");
31+
cfg.include(root.join("include"));
32+
cfg.cargo_metadata(false);
33+
cfg.out_dir(&out_dir);
34+
@@ -1447,12 +1448,10 @@ fn run(self, builder: &Builder<'_>) -> Self::Output {
35+
cfg.define("__NO_STRING_INLINES", None);
36+
cfg.define("__NO_MATH_INLINES", None);
37+
cfg.define("_LIBUNWIND_IS_BAREMETAL", None);
38+
- cfg.define("__LIBUNWIND_IS_NATIVE_ONLY", None);
39+
cfg.define("NDEBUG", None);
40+
}
41+
if self.target.is_windows() {
42+
cfg.define("_LIBUNWIND_HIDE_SYMBOLS", "1");
43+
- cfg.define("_LIBUNWIND_IS_NATIVE_ONLY", "1");
44+
}
45+
}
46+

recipes-devtools/rust/rust-source.inc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ SRC_URI += "https://static.rust-lang.org/dist/rustc-${RUST_VERSION}-src.tar.xz;n
99
file://revert-link-std-statically-in-rustc_driver-feature.patch;patchdir=${RUSTSRC} \
1010
file://Zdual-proc-macros-additional-check.patch;patchdir=${RUSTSRC} \
1111
file://0001-libunwind-Use-gcs-instead-of-gcs-target-attribute.patch;patchdir=${RUSTSRC} \
12+
file://0001-Disable-libunwind-cross-architecture-unwinding.patch;patchdir=${RUSTSRC} \
1213
"
1314
SRC_URI[rust.sha256sum] = "b1fbf809efe9f036939401e142631c201a53bcf43ec1696bd9f5290ba236a266"
1415

0 commit comments

Comments
 (0)