From 31c8d87a7c14c307279b91b3047516681e0868ee Mon Sep 17 00:00:00 2001 From: Wildan M Date: Tue, 3 Mar 2026 10:37:07 +0700 Subject: [PATCH] Fix static linker error caused by setjmp aarch64 --- src/header/setjmp/mod.rs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/header/setjmp/mod.rs b/src/header/setjmp/mod.rs index 32679f4008..fd444537bf 100644 --- a/src/header/setjmp/mod.rs +++ b/src/header/setjmp/mod.rs @@ -2,7 +2,9 @@ //! //! See . -use core::arch::global_asm; +use core::{arch::global_asm, ffi::c_int}; + +use crate::header::signal::sigsetjmp; macro_rules! platform_specific { ($($rust_arch:expr,$c_arch:expr,$ext:expr;)+) => { @@ -29,3 +31,15 @@ unsafe extern "C" { /// See . pub fn longjmp(jb: *mut u64, ret: i32); } + +#[cfg(target_arch = "aarch64")] +#[unsafe(no_mangle)] +pub unsafe extern "C" fn __relibc_unused_but_exist_to_avoid_linker_error_on_setjmp(arg: c_int) { + /// Workaround to https://www.openwall.com/lists/musl/2023/09/07/2 + /// By keeping setjmp close to sigsetjmp in link time + let jb: *mut u64 = core::ptr::null_mut(); + unsafe { + setjmp(jb); + sigsetjmp(jb, arg); + } +}