diff mbox series

[meta-lts-mixins,kirkstone/rust,08/13] rust: Disable cross-unwinding support in llvm libunwind

Message ID eb7f33df49b43cf641d91b904d89aed883e3869a.1753296167.git.scott.murray@konsulko.com
State New
Headers show
Series Update to Rust 1.87.0 | expand

Commit Message

Scott Murray July 23, 2025, 7:05 p.m. UTC
From: Khem Raj <raj.khem@gmail.com>

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 <raj.khem@gmail.com>
Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(adapted from oe-core commit f05d42d11e56cbbda6034bd7f773dc690b68bdbd)
Signed-off-by: Scott Murray <scott.murray@konsulko.com>
---
 ...bunwind-cross-architecture-unwinding.patch | 46 +++++++++++++++++++
 recipes-devtools/rust/rust-source.inc         |  1 +
 2 files changed, 47 insertions(+)
 create mode 100644 recipes-devtools/rust/files/0001-Disable-libunwind-cross-architecture-unwinding.patch
diff mbox series

Patch

diff --git a/recipes-devtools/rust/files/0001-Disable-libunwind-cross-architecture-unwinding.patch b/recipes-devtools/rust/files/0001-Disable-libunwind-cross-architecture-unwinding.patch
new file mode 100644
index 0000000..4a28203
--- /dev/null
+++ b/recipes-devtools/rust/files/0001-Disable-libunwind-cross-architecture-unwinding.patch
@@ -0,0 +1,46 @@ 
+From 56b669cd7adcc413bb1e64c3d2d7c347a82ae35a Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Wed, 21 May 2025 18:47:09 -0700
+Subject: [PATCH] Disable libunwind cross-architecture unwinding
+
+Building with _LIBUNWIND_IS_NATIVE_ONLY disables code for cross-architecture unwinding
+it is disabled by default in LLVM [1], replicate the cmake behavior in bootstrap process
+
+It also enables some additional code that handles PAC-specific unwind info
+it helps compiling with the -mbranch-protection=pac or -mbranch-protection=standard flags
+
+This fixes build with clang/musl on aarch64
+
+[1] https://github.com/llvm/llvm-project/commit/85624c5de3e831ffa01fdc2d159e3d69c30de08d
+
+Upstream-Status: Submitted [https://github.com/rust-lang/rust/pull/141375]
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+---
+ src/bootstrap/src/core/build_steps/llvm.rs | 3 +--
+ 1 file changed, 1 insertion(+), 2 deletions(-)
+
+diff --git a/src/bootstrap/src/core/build_steps/llvm.rs b/src/bootstrap/src/core/build_steps/llvm.rs
+index a3788197471..5e4a1c7d9f0 100644
+--- a/src/bootstrap/src/core/build_steps/llvm.rs
++++ b/src/bootstrap/src/core/build_steps/llvm.rs
+@@ -1430,6 +1430,7 @@ fn run(self, builder: &Builder<'_>) -> Self::Output {
+             cfg.flag("-funwind-tables");
+             cfg.flag("-fvisibility=hidden");
+             cfg.define("_LIBUNWIND_DISABLE_VISIBILITY_ANNOTATIONS", None);
++            cfg.define("_LIBUNWIND_IS_NATIVE_ONLY", "1");
+             cfg.include(root.join("include"));
+             cfg.cargo_metadata(false);
+             cfg.out_dir(&out_dir);
+@@ -1447,12 +1448,10 @@ fn run(self, builder: &Builder<'_>) -> Self::Output {
+                 cfg.define("__NO_STRING_INLINES", None);
+                 cfg.define("__NO_MATH_INLINES", None);
+                 cfg.define("_LIBUNWIND_IS_BAREMETAL", None);
+-                cfg.define("__LIBUNWIND_IS_NATIVE_ONLY", None);
+                 cfg.define("NDEBUG", None);
+             }
+             if self.target.is_windows() {
+                 cfg.define("_LIBUNWIND_HIDE_SYMBOLS", "1");
+-                cfg.define("_LIBUNWIND_IS_NATIVE_ONLY", "1");
+             }
+         }
+ 
diff --git a/recipes-devtools/rust/rust-source.inc b/recipes-devtools/rust/rust-source.inc
index 177de53..5fb11b5 100644
--- a/recipes-devtools/rust/rust-source.inc
+++ b/recipes-devtools/rust/rust-source.inc
@@ -9,6 +9,7 @@  SRC_URI += "https://static.rust-lang.org/dist/rustc-${RUST_VERSION}-src.tar.xz;n
             file://revert-link-std-statically-in-rustc_driver-feature.patch;patchdir=${RUSTSRC} \
             file://Zdual-proc-macros-additional-check.patch;patchdir=${RUSTSRC} \
             file://0001-libunwind-Use-gcs-instead-of-gcs-target-attribute.patch;patchdir=${RUSTSRC} \
+            file://0001-Disable-libunwind-cross-architecture-unwinding.patch;patchdir=${RUSTSRC} \
 "
 SRC_URI[rust.sha256sum] = "b1fbf809efe9f036939401e142631c201a53bcf43ec1696bd9f5290ba236a266"