Use __chkstk for aarch64 instead of __rust_probestack. (#800)

* Use __chkstk for aarch64 instead of __rust_probestack.

* Demote rustdoc to a regular comment to fix the build.
This commit is contained in:
Sergei Pepyakin
2020-01-17 05:23:32 +01:00
committed by Dan Gohman
parent d81aa203bb
commit 7890fa6705
3 changed files with 32 additions and 25 deletions

1
Cargo.lock generated
View File

@@ -2204,6 +2204,7 @@ name = "wasmtime-jit"
version = "0.9.0" version = "0.9.0"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"cfg-if",
"cranelift-codegen", "cranelift-codegen",
"cranelift-entity", "cranelift-entity",
"cranelift-frontend", "cranelift-frontend",

View File

@@ -25,6 +25,7 @@ target-lexicon = { version = "0.10.0", default-features = false }
wasmparser = { version = "0.47.0", default-features = false } wasmparser = { version = "0.47.0", default-features = false }
more-asserts = "0.2.1" more-asserts = "0.2.1"
anyhow = "1.0" anyhow = "1.0"
cfg-if = "0.1.9"
[target.'cfg(target_os = "windows")'.dependencies] [target.'cfg(target_os = "windows")'.dependencies]
winapi = { version = "0.3.7", features = ["winnt", "impl-default"] } winapi = { version = "0.3.7", features = ["winnt", "impl-default"] }

View File

@@ -44,16 +44,7 @@ pub fn link_module(
FloorF64 => wasmtime_f64_floor as usize, FloorF64 => wasmtime_f64_floor as usize,
TruncF64 => wasmtime_f64_trunc as usize, TruncF64 => wasmtime_f64_trunc as usize,
NearestF64 => wasmtime_f64_nearest as usize, NearestF64 => wasmtime_f64_nearest as usize,
#[cfg(not(target_os = "windows"))] Probestack => PROBESTACK as usize,
Probestack => __rust_probestack as usize,
#[cfg(all(target_os = "windows", target_env = "gnu"))]
Probestack => ___chkstk as usize,
#[cfg(all(
target_os = "windows",
target_env = "msvc",
target_pointer_width = "64"
))]
Probestack => __chkstk as usize,
other => panic!("unexpected libcall: {}", other), other => panic!("unexpected libcall: {}", other),
} }
} }
@@ -107,19 +98,33 @@ pub fn link_module(
} }
} }
/// A declaration for the stack probe function in Rust's standard library, for // A declaration for the stack probe function in Rust's standard library, for
/// catching callstack overflow. // catching callstack overflow.
extern "C" { cfg_if::cfg_if! {
#[cfg(not(target_os = "windows"))] if #[cfg(any(
pub fn __rust_probestack(); target_arch="aarch64",
#[cfg(all( all(
target_os = "windows", target_os = "windows",
target_env = "msvc", target_env = "msvc",
target_pointer_width = "64" target_pointer_width = "64"
))] )
))] {
extern "C" {
pub fn __chkstk(); pub fn __chkstk();
}
const PROBESTACK: unsafe extern "C" fn() = __chkstk;
} else if #[cfg(all(target_os = "windows", target_env = "gnu"))] {
extern "C" {
// ___chkstk (note the triple underscore) is implemented in compiler-builtins/src/x86_64.rs // ___chkstk (note the triple underscore) is implemented in compiler-builtins/src/x86_64.rs
// by the Rust compiler for the MinGW target // by the Rust compiler for the MinGW target
#[cfg(all(target_os = "windows", target_env = "gnu"))] #[cfg(all(target_os = "windows", target_env = "gnu"))]
pub fn ___chkstk(); pub fn ___chkstk();
} }
const PROBESTACK: unsafe extern "C" fn() = ___chkstk;
} else {
extern "C" {
pub fn __rust_probestack();
}
static PROBESTACK: unsafe extern "C" fn() = __rust_probestack;
}
}