Skip to content

A lightweight WebAssembly runtime that is fast, secure, and standards-compliant

Work around naked-function-plus-LTO issue (#11960)

Alex Crichton1700302c29cc
diff --git a/crates/fiber/src/stackswitch/aarch64.rs b/crates/fiber/src/stackswitch/aarch64.rs
index 0d2428516a..f14e062884 100644
--- a/crates/fiber/src/stackswitch/aarch64.rs
+++ b/crates/fiber/src/stackswitch/aarch64.rs
@@ -32,8 +32,13 @@ cfg_if::cfg_if! {
}
}
+#[inline(never)] // FIXME(rust-lang/rust#148307)
+pub(crate) unsafe extern "C" fn wasmtime_fiber_switch(top_of_stack: *mut u8) {
+ unsafe { wasmtime_fiber_switch_(top_of_stack) }
+}
+
#[unsafe(naked)]
-pub(crate) unsafe extern "C" fn wasmtime_fiber_switch(top_of_stack: *mut u8 /* x0 */) {
+unsafe extern "C" fn wasmtime_fiber_switch_(top_of_stack: *mut u8 /* x0 */) {
naked_asm!(concat!(
"
.cfi_startproc
diff --git a/crates/fiber/src/stackswitch/arm.rs b/crates/fiber/src/stackswitch/arm.rs
index f02ff757d4..fe1937f46c 100644
--- a/crates/fiber/src/stackswitch/arm.rs
+++ b/crates/fiber/src/stackswitch/arm.rs
@@ -10,8 +10,13 @@
use core::arch::naked_asm;
+#[inline(never)] // FIXME(rust-lang/rust#148307)
+pub(crate) unsafe extern "C" fn wasmtime_fiber_switch(top_of_stack: *mut u8) {
+ unsafe { wasmtime_fiber_switch_(top_of_stack) }
+}
+
#[unsafe(naked)]
-pub(crate) unsafe extern "C" fn wasmtime_fiber_switch(top_of_stack: *mut u8 /* r0 */) {
+unsafe extern "C" fn wasmtime_fiber_switch_(top_of_stack: *mut u8 /* r0 */) {
naked_asm!(
"
// Save callee-saved registers
diff --git a/crates/fiber/src/stackswitch/riscv64.rs b/crates/fiber/src/stackswitch/riscv64.rs
index 4883004fa5..20aa1ec8a6 100644
--- a/crates/fiber/src/stackswitch/riscv64.rs
+++ b/crates/fiber/src/stackswitch/riscv64.rs
@@ -7,8 +7,13 @@
use core::arch::naked_asm;
+#[inline(never)] // FIXME(rust-lang/rust#148307)
+pub(crate) unsafe extern "C" fn wasmtime_fiber_switch(top_of_stack: *mut u8) {
+ unsafe { wasmtime_fiber_switch_(top_of_stack) }
+}
+
#[unsafe(naked)]
-pub(crate) unsafe extern "C" fn wasmtime_fiber_switch(top_of_stack: *mut u8 /* a0 */) {
+unsafe extern "C" fn wasmtime_fiber_switch_(top_of_stack: *mut u8 /* a0 */) {
naked_asm!(
"
// See https://github.com/rust-lang/rust/issues/80608.
diff --git a/crates/fiber/src/stackswitch/s390x.rs b/crates/fiber/src/stackswitch/s390x.rs
index 15cb543b16..0d376b4647 100644
--- a/crates/fiber/src/stackswitch/s390x.rs
+++ b/crates/fiber/src/stackswitch/s390x.rs
@@ -7,8 +7,13 @@
use core::arch::naked_asm;
+#[inline(never)] // FIXME(rust-lang/rust#148307)
+pub(crate) unsafe extern "C" fn wasmtime_fiber_switch(top_of_stack: *mut u8) {
+ unsafe { wasmtime_fiber_switch_(top_of_stack) }
+}
+
#[unsafe(naked)]
-pub(crate) unsafe extern "C" fn wasmtime_fiber_switch(top_of_stack: *mut u8 /* x0 */) {
+unsafe extern "C" fn wasmtime_fiber_switch_(top_of_stack: *mut u8 /* x0 */) {
naked_asm!(
"
// Save all callee-saved registers on the stack since we're assuming
diff --git a/crates/fiber/src/stackswitch/x86.rs b/crates/fiber/src/stackswitch/x86.rs
index 79869e1bc0..15b05ef92e 100644
--- a/crates/fiber/src/stackswitch/x86.rs
+++ b/crates/fiber/src/stackswitch/x86.rs
@@ -12,8 +12,13 @@
use core::arch::naked_asm;
-#[unsafe(naked)]
+#[inline(never)] // FIXME(rust-lang/rust#148307)
pub(crate) unsafe extern "C" fn wasmtime_fiber_switch(top_of_stack: *mut u8) {
+ unsafe { wasmtime_fiber_switch_(top_of_stack) }
+}
+
+#[unsafe(naked)]
+unsafe extern "C" fn wasmtime_fiber_switch_(top_of_stack: *mut u8) {
naked_asm!(
"
// Load our stack-to-use
diff --git a/crates/fiber/src/stackswitch/x86_64.rs b/crates/fiber/src/stackswitch/x86_64.rs
index 8294073fd1..eb3ec36980 100644
--- a/crates/fiber/src/stackswitch/x86_64.rs
+++ b/crates/fiber/src/stackswitch/x86_64.rs
@@ -7,8 +7,13 @@
use core::arch::naked_asm;
+#[inline(never)] // FIXME(rust-lang/rust#148307)
+pub(crate) unsafe extern "C" fn wasmtime_fiber_switch(top_of_stack: *mut u8) {
+ unsafe { wasmtime_fiber_switch_(top_of_stack) }
+}
+
#[unsafe(naked)]
-pub(crate) unsafe extern "C" fn wasmtime_fiber_switch(top_of_stack: *mut u8 /* rdi */) {
+unsafe extern "C" fn wasmtime_fiber_switch_(top_of_stack: *mut u8 /* rdi */) {
naked_asm!(
"
// We're switching to arbitrary code somewhere else, so pessimistically