Skip to content

Implement wasm trap handlers. #27

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

Merged
merged 6 commits into from
Nov 27, 2018
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
9 changes: 8 additions & 1 deletion lib/execute/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,16 @@ readme = "README.md"
cranelift-codegen = "0.25.0"
cranelift-entity = "0.25.0"
cranelift-wasm = "0.25.0"
region = "1.0.0"
wasmtime-environ = { path = "../environ" }
region = "1.0.0"
memmap = "0.7.0"
lazy_static = "1.2.0"
libc = "0.2.44"

[build-dependencies]
cmake = "0.1.35"
bindgen = "0.43.2"
regex = "1.0.6"

[features]
default = ["std"]
Expand Down
38 changes: 38 additions & 0 deletions lib/execute/build.rs
Original file line number Diff line number Diff line change
@@ -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!");
}
8 changes: 8 additions & 0 deletions lib/execute/signalhandlers/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cmake_minimum_required(VERSION 3.0)
project(SignalHandlers CXX)

set(CMAKE_CXX_FLAGS "-std=c++11 -fno-exceptions -fno-rtti -fPIC")

add_library(SignalHandlers STATIC SignalHandlers.cpp)

install(TARGETS SignalHandlers DESTINATION .)
Loading