Skip to content

Commit

Permalink
Remove C++ dependency from wasmtime (#1365)
Browse files Browse the repository at this point in the history
* Remove C++ dependency from `wasmtime`

This commit removes the last wads of C++ that we have in wasmtime,
meaning that building wasmtime no longer requires a C++ compiler. It
still does require a C toolchain for some minor purposes, but hopefully
we can remove that over time too!

The motivation for doing this is to consolidate all our signal-handling
code into one location in one language so you don't have to keep
crossing back and forth when understanding what's going on. This also
allows us to remove some extra cruft that wasn't necessary from the C++
original implementation. Additionally this should also make building
wasmtime a bit more portable since it's often easier to acquire a C
toolchain than it is to acquire a C++ toolchain. (e.g. if you're
cross-compiling to a musl target)

* Typos
  • Loading branch information
alexcrichton authored Mar 20, 2020
1 parent c50c24e commit f700efe
Show file tree
Hide file tree
Showing 9 changed files with 260 additions and 879 deletions.
2 changes: 1 addition & 1 deletion crates/runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ cfg-if = "0.1.9"
backtrace = "0.3.42"

[target.'cfg(target_os = "windows")'.dependencies]
winapi = { version = "0.3.7", features = ["winbase", "memoryapi"] }
winapi = { version = "0.3.7", features = ["winbase", "memoryapi", "errhandlingapi"] }

[build-dependencies]
cc = "1.0"
Expand Down
23 changes: 5 additions & 18 deletions crates/runtime/build.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,7 @@
fn main() {
println!("cargo:rerun-if-changed=signalhandlers/SignalHandlers.cpp");
println!("cargo:rerun-if-changed=signalhandlers/SignalHandlers.hpp");
println!("cargo:rerun-if-changed=signalhandlers/Trampolines.cpp");
let target = std::env::var("TARGET").unwrap();
let mut build = cc::Build::new();
build
.cpp(true)
.warnings(false)
.file("signalhandlers/SignalHandlers.cpp")
.file("signalhandlers/Trampolines.cpp");
if !target.contains("windows") {
build
.flag("-std=c++11")
.flag("-fno-exceptions")
.flag("-fno-rtti");
}

build.compile("signalhandlers");
println!("cargo:rerun-if-changed=src/helpers.c");
cc::Build::new()
.warnings(true)
.file("src/helpers.c")
.compile("helpers");
}
Loading

0 comments on commit f700efe

Please sign in to comment.