1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
//! Trap-only stubs for the tiny surface of the Itanium C++ ABI that
//! libc++ still references even when compiled with `-fno-exceptions`.
//!
//! Any call to these functions indicates the C++ backend hit an
//! unexpected error path (e.g. out-of-memory inside `std::vector`).
//! We trap immediately so the browser surfaces a WebAssembly
//! RuntimeError with a clear stack frame rather than returning
//! nonsense to the caller.
/// libc++ calls `__cxa_allocate_exception` before constructing the
/// exception object. With `-fno-exceptions` the call is only emitted
/// for unwind-friendly STL helpers; none of them are on the steady-
/// state hot path, so aborting is fine.
pub extern "C"
/// Paired with `__cxa_allocate_exception`; libc++ calls this after
/// filling in the exception object to start unwinding. We never reach
/// here in practice because `__cxa_allocate_exception` traps first,
/// but linkers still want the symbol resolved.
pub extern "C" !
/// libc++ may probe for an active exception while evaluating internal
/// error-handling paths. Exceptions are not supported in this build, so
/// reporting zero active exceptions is the least surprising behavior and keeps
/// the final wasm self-contained.
pub extern "C"
// `__funcs_on_exit` / `__stdio_exit` do not appear in the final wasm
// at all: because we never link wasi-libc and our
// `wasm_runtime_shims` module covers every libc reference, the
// cdylib has zero `wasi_snapshot_preview1` imports, so wasm-bindgen
// emits a normal library module rather than one wrapped in
// `command_export` shims. Nothing ever calls the exit hooks, so we
// don't need to shadow them.