Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use __chkstk for aarch64 instead of __rust_probestack. #800

Merged
merged 2 commits into from
Jan 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/jit/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ target-lexicon = { version = "0.9.0", default-features = false }
wasmparser = { version = "0.45.1", default-features = false }
more-asserts = "0.2.1"
anyhow = "1.0"
cfg-if = "0.1.9"

[target.'cfg(target_os = "windows")'.dependencies]
winapi = { version = "0.3.7", features = ["winnt", "impl-default"] }
Expand Down
55 changes: 30 additions & 25 deletions crates/jit/src/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,16 +335,7 @@ fn relocate(
FloorF64 => wasmtime_f64_floor as usize,
TruncF64 => wasmtime_f64_trunc as usize,
NearestF64 => wasmtime_f64_nearest as usize,
#[cfg(not(target_os = "windows"))]
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,
Probestack => PROBESTACK as usize,
other => panic!("unexpected libcall: {}", other),
}
}
Expand Down Expand Up @@ -398,19 +389,33 @@ fn relocate(
}
}

/// A declaration for the stack probe function in Rust's standard library, for
/// catching callstack overflow.
extern "C" {
#[cfg(not(target_os = "windows"))]
pub fn __rust_probestack();
#[cfg(all(
target_os = "windows",
target_env = "msvc",
target_pointer_width = "64"
))]
pub fn __chkstk();
// ___chkstk (note the triple underscore) is implemented in compiler-builtins/src/x86_64.rs
// by the Rust compiler for the MinGW target
#[cfg(all(target_os = "windows", target_env = "gnu"))]
pub fn ___chkstk();
// A declaration for the stack probe function in Rust's standard library, for
// catching callstack overflow.
cfg_if::cfg_if! {
if #[cfg(any(
target_arch="aarch64",
all(
target_os = "windows",
target_env = "msvc",
target_pointer_width = "64"
)
))] {
extern "C" {
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
// by the Rust compiler for the MinGW target
#[cfg(all(target_os = "windows", target_env = "gnu"))]
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;
}
}