* Implement wasm trap handlers. This adds signal handlers based on SpiderMonkey's signal-handler code. The functionality for looking up the trap code and wasm bytecode offset isn't yet implemented, but this is a start. I considered rewriting this code in Rust, but decided against it for now as C++ allows us to talk to the relevant OS APIs more directly. Fixes #15. * Compile with -std=c++11. * Refactor InstallState initialization. * Compile with -fPIC. * Factor out the code for calling a wasm function with a given index. * Fix unclear wording in a comment.
39 lines
1.1 KiB
Rust
39 lines
1.1 KiB
Rust
extern crate bindgen;
|
|
extern crate cmake;
|
|
extern crate regex;
|
|
|
|
use cmake::Config;
|
|
use regex::Regex;
|
|
use std::env;
|
|
use std::path::PathBuf;
|
|
|
|
fn main() {
|
|
let dst = Config::new("signalhandlers").build();
|
|
|
|
println!("cargo:rustc-link-search=native={}", dst.display());
|
|
println!("cargo:rustc-link-lib=static=SignalHandlers");
|
|
|
|
let mut bindings_builder = bindgen::Builder::default()
|
|
.header("signalhandlers/SignalHandlers.h")
|
|
.whitelist_type("CodeSegment")
|
|
.whitelist_type("TrapContext")
|
|
.whitelist_type("jmp_buf")
|
|
.whitelist_function("EnsureEagerSignalHandlers");
|
|
|
|
// If we're compiling for Darwin, compile in extra Darwin support routines.
|
|
if Regex::new(r"-darwin[[:digit:].]*$")
|
|
.unwrap()
|
|
.is_match(&env::var("TARGET").unwrap())
|
|
{
|
|
bindings_builder = bindings_builder.whitelist_function("EnsureDarwinMachPorts");
|
|
}
|
|
|
|
let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
|
|
|
|
bindings_builder
|
|
.generate()
|
|
.expect("Unable to generate bindings")
|
|
.write_to_file(out_path.join("signalhandlers.rs"))
|
|
.expect("Couldn't write bindings!");
|
|
}
|