Implement wasm trap handlers. (#27)
* 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.
This commit is contained in:
38
lib/execute/build.rs
Normal file
38
lib/execute/build.rs
Normal file
@@ -0,0 +1,38 @@
|
||||
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!");
|
||||
}
|
||||
Reference in New Issue
Block a user