Skip to content

Commit 05566cc

Browse files
authored
Work around naked-function-plus-LTO issue (#11960) (#11972)
This is an attempt to apply a local fix for #11957 which works around the upstream Rust issue mentioned in that issue.
1 parent e7eb46b commit 05566cc

File tree

6 files changed

+36
-6
lines changed

6 files changed

+36
-6
lines changed

crates/fiber/src/stackswitch/aarch64.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,13 @@ cfg_if::cfg_if! {
3636
}
3737
}
3838

39+
#[inline(never)] // FIXME(rust-lang/rust#148307)
40+
pub(crate) unsafe extern "C" fn wasmtime_fiber_switch(top_of_stack: *mut u8) {
41+
unsafe { wasmtime_fiber_switch_(top_of_stack) }
42+
}
43+
3944
#[unsafe(naked)]
40-
pub(crate) unsafe extern "C" fn wasmtime_fiber_switch(top_of_stack: *mut u8 /* x0 */) {
45+
unsafe extern "C" fn wasmtime_fiber_switch_(top_of_stack: *mut u8 /* x0 */) {
4146
naked_asm!(concat!(
4247
"
4348
.cfi_startproc

crates/fiber/src/stackswitch/arm.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,13 @@
1010

1111
use core::arch::naked_asm;
1212

13+
#[inline(never)] // FIXME(rust-lang/rust#148307)
14+
pub(crate) unsafe extern "C" fn wasmtime_fiber_switch(top_of_stack: *mut u8) {
15+
unsafe { wasmtime_fiber_switch_(top_of_stack) }
16+
}
17+
1318
#[unsafe(naked)]
14-
pub(crate) unsafe extern "C" fn wasmtime_fiber_switch(top_of_stack: *mut u8 /* r0 */) {
19+
unsafe extern "C" fn wasmtime_fiber_switch_(top_of_stack: *mut u8 /* r0 */) {
1520
naked_asm!(
1621
"
1722
// Save callee-saved registers

crates/fiber/src/stackswitch/riscv64.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,13 @@
77

88
use core::arch::naked_asm;
99

10+
#[inline(never)] // FIXME(rust-lang/rust#148307)
11+
pub(crate) unsafe extern "C" fn wasmtime_fiber_switch(top_of_stack: *mut u8) {
12+
unsafe { wasmtime_fiber_switch_(top_of_stack) }
13+
}
14+
1015
#[unsafe(naked)]
11-
pub(crate) unsafe extern "C" fn wasmtime_fiber_switch(top_of_stack: *mut u8 /* a0 */) {
16+
unsafe extern "C" fn wasmtime_fiber_switch_(top_of_stack: *mut u8 /* a0 */) {
1217
naked_asm!(
1318
"
1419
// See https://github.com/rust-lang/rust/issues/80608.

crates/fiber/src/stackswitch/s390x.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,13 @@
77

88
use core::arch::naked_asm;
99

10+
#[inline(never)] // FIXME(rust-lang/rust#148307)
11+
pub(crate) unsafe extern "C" fn wasmtime_fiber_switch(top_of_stack: *mut u8) {
12+
unsafe { wasmtime_fiber_switch_(top_of_stack) }
13+
}
14+
1015
#[unsafe(naked)]
11-
pub(crate) unsafe extern "C" fn wasmtime_fiber_switch(top_of_stack: *mut u8 /* x0 */) {
16+
unsafe extern "C" fn wasmtime_fiber_switch_(top_of_stack: *mut u8 /* x0 */) {
1217
naked_asm!(
1318
"
1419
// Save all callee-saved registers on the stack since we're assuming

crates/fiber/src/stackswitch/x86.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,13 @@
1212

1313
use core::arch::naked_asm;
1414

15-
#[unsafe(naked)]
15+
#[inline(never)] // FIXME(rust-lang/rust#148307)
1616
pub(crate) unsafe extern "C" fn wasmtime_fiber_switch(top_of_stack: *mut u8) {
17+
unsafe { wasmtime_fiber_switch_(top_of_stack) }
18+
}
19+
20+
#[unsafe(naked)]
21+
unsafe extern "C" fn wasmtime_fiber_switch_(top_of_stack: *mut u8) {
1722
naked_asm!(
1823
"
1924
// Load our stack-to-use

crates/fiber/src/stackswitch/x86_64.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,13 @@
77

88
use core::arch::naked_asm;
99

10+
#[inline(never)] // FIXME(rust-lang/rust#148307)
11+
pub(crate) unsafe extern "C" fn wasmtime_fiber_switch(top_of_stack: *mut u8) {
12+
unsafe { wasmtime_fiber_switch_(top_of_stack) }
13+
}
14+
1015
#[unsafe(naked)]
11-
pub(crate) unsafe extern "C" fn wasmtime_fiber_switch(top_of_stack: *mut u8 /* rdi */) {
16+
unsafe extern "C" fn wasmtime_fiber_switch_(top_of_stack: *mut u8 /* rdi */) {
1217
naked_asm!(
1318
"
1419
// We're switching to arbitrary code somewhere else, so pessimistically

0 commit comments

Comments
 (0)