Skip to contentSkip to conversation

rust: Switch Cargo build to release mode to avoid DEBUG-mode stack overflow

PATCH New [email protected] 1 participant 1 message Jul 10, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rust: Switch Cargo build to release mode to avoid DEBUG-mode stack overflow

From: Yash Shinde <[email protected]>

DEBUG builds of Cargo (v1.85.1) result in a stack overflow during compilation of the p384 crate, causing a segmentation fault:

TOPDIR/tmp-glibc/work/cortexa15t2hf-neon-wrs-linux-gnueabi/cargo/1.85.1-r0/recipe-sysroot-native/usr/bin/../lib/librustc_driver-9603b88fd542d97b.so(+0x1f43519) [0x7f9749cf6519]

note: rustc unexpectedly overflowed its stack! this is a bug
note: maximum backtrace depth reached, frames may have been lost
note: we would appreciate a report at https://github.com/rust-lang/rust

    Building [=================>       ] 255/351: maybe-async, curl-sys(bui...

error: could not compile p384 (lib)

This issue is resolved in Rust v1.86.0. As a temporary workaround, this commit forces Cargo to be built in release mode to avoid the bug until the toolchain is updated.

Fix in Rust v1.86.0:
https://github.com/RustCrypto/elliptic-curves/commit/7652c5842cde60acc1e739ebbba34614cb158f8b

---
 recipes-devtools/rust/cargo_1.85.1.bb | 3 +++
 1 file changed, 3 insertions(+)
recipes-devtools/rust/cargo_1.85.1.bb +3 -0
index a6d3f17..f88f960 100644
@@ -19,6 +19,9 @@ CARGO_VENDORING_DIRECTORY = "${RUSTSRC}/vendor"
 
 inherit cargo pkgconfig
 
+CARGO_BUILD_FLAGS:append = "${@' --release' if d.getVar('DEBUG_BUILD') == '1' else ''}"
+BUILD_DIR = "release"
+
 DEBUG_PREFIX_MAP += "-fdebug-prefix-map=${RUSTSRC}/vendor=${TARGET_DBGSRC_DIR}"
 
 do_cargo_setup_snapshot () {
Signature · 1 line
2.49.0