Files
wasmtime/crates/runtime/Cargo.toml
Alex Crichton 3f9bff17c8 Support disabling backtraces at compile time (#3932)
* Support disabling backtraces at compile time

This commit adds support to Wasmtime to disable, at compile time, the
gathering of backtraces on traps. The `wasmtime` crate now sports a
`wasm-backtrace` feature which, when disabled, will mean that backtraces
are never collected at compile time nor are unwinding tables inserted
into compiled objects.

The motivation for this commit stems from the fact that generating a
backtrace is quite a slow operation. Currently backtrace generation is
done with libunwind and `_Unwind_Backtrace` typically found in glibc or
other system libraries. When thousands of modules are loaded into the
same process though this means that the initial backtrace can take
nearly half a second and all subsequent backtraces can take upwards of
hundreds of milliseconds. Relative to all other operations in Wasmtime
this is extremely expensive at this time. In the future we'd like to
implement a more performant backtrace scheme but such an implementation
would require coordination with Cranelift and is a big chunk of work
that may take some time, so in the meantime if embedders don't need a
backtrace they can still use this option to disable backtraces at
compile time and avoid the performance pitfalls of collecting
backtraces.

In general I tried to originally make this a runtime configuration
option but ended up opting for a compile-time option because `Trap::new`
otherwise has no arguments and always captures a backtrace. By making
this a compile-time option it was possible to configure, statically, the
behavior of `Trap::new`. Additionally I also tried to minimize the
amount of `#[cfg]` necessary by largely only having it at the producer
and consumer sites.

Also a noteworthy restriction of this implementation is that if
backtrace support is disabled at compile time then reference types
support will be unconditionally disabled at runtime. With backtrace
support disabled there's no way to trace the stack of wasm frames which
means that GC can't happen given our current implementation.

* Always enable backtraces for the C API
2022-03-16 09:18:16 -05:00

64 lines
1.9 KiB
TOML

[package]
name = "wasmtime-runtime"
version = "0.35.0"
authors = ["The Wasmtime Project Developers"]
description = "Runtime library support for Wasmtime"
documentation = "https://docs.rs/wasmtime-runtime"
license = "Apache-2.0 WITH LLVM-exception"
categories = ["wasm"]
keywords = ["webassembly", "wasm"]
repository = "https://github.com/bytecodealliance/wasmtime"
edition = "2018"
[dependencies]
wasmtime-environ = { path = "../environ", version = "=0.35.0" }
wasmtime-fiber = { path = "../fiber", version = "=0.35.0", optional = true }
wasmtime-jit-debug = { path = "../jit-debug", version = "=0.35.0", features = ["gdb_jit_int"] }
region = "2.1.0"
libc = { version = "0.2.112", default-features = false }
log = "0.4.8"
memoffset = "0.6.0"
indexmap = "1.0.2"
thiserror = "1.0.4"
more-asserts = "0.2.1"
cfg-if = "1.0"
backtrace = { version = "0.3.61", optional = true }
rand = "0.8.3"
anyhow = "1.0.38"
memfd = { version = "0.4.1", optional = true }
[target.'cfg(target_os = "macos")'.dependencies]
mach = "0.3.2"
[target.'cfg(unix)'.dependencies]
rustix = "0.33.0"
[target.'cfg(target_os = "windows")'.dependencies]
winapi = { version = "0.3.7", features = ["winbase", "memoryapi", "errhandlingapi", "handleapi"] }
[target.'cfg(target_os = "linux")'.dependencies]
userfaultfd = { version = "0.4.1", optional = true }
[build-dependencies]
cc = "1.0"
[badges]
maintenance = { status = "actively-developed" }
[features]
memory-init-cow = ['memfd']
wasm-backtrace = ["backtrace"]
async = ["wasmtime-fiber"]
# Enables support for the pooling instance allocator
pooling-allocator = []
# Enables support for userfaultfd in the pooling allocator when building on Linux
uffd = ["userfaultfd", "pooling-allocator"]
# Enables trap handling using POSIX signals instead of Mach exceptions on MacOS.
# It is useful for applications that do not bind their own exception ports and
# need portable signal handling.
posix-signals-on-macos = []