Skip to content

Commit 57152dc

Browse files
committed
Add a workaround for rust-lang/rust#80608 for riscv64.
1 parent b089d71 commit 57152dc

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

c-scape/src/jmp.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ unsafe extern "C" fn setjmp(env: jmp_buf) -> c_int {
7676
#[cfg(all(target_arch = "riscv64", not(target_feature = "soft-float")))]
7777
{
7878
naked_asm!(
79+
// arch option manipulation needed due to LLVM/Rust bug, see rust-lang/rust#80608
80+
".option push",
81+
".option arch, +d",
7982
// Save all the callee-saved registers, the incoming stack pointer
8083
// value, and the incoming return address into the `jmp_buf`.
8184
"sd s0, 0(a0)",
@@ -108,7 +111,9 @@ unsafe extern "C" fn setjmp(env: jmp_buf) -> c_int {
108111
// Return 0.
109112
"li a0, 0",
110113
// Return to the caller normally.
111-
"ret"
114+
"ret",
115+
// arch option manipulation needed due to LLVM/Rust bug, see rust-lang/rust#80608
116+
".option pop"
112117
)
113118
}
114119

0 commit comments

Comments
 (0)