brson / miri

An experimental compiler from Rust to WebAssembly (inactive - do not use)
Apache License 2.0
209 stars 15 forks source link

Generate binaries that run on V8 #38

Closed eholk closed 8 years ago

eholk commented 8 years ago

This change includes two major parts (and also includes #37, but that can be merged separately):

  1. Changes to build.rs to fetch a build of the Wasm toolchain from https://wasm-stat.us on linux. This also caches the build number and only downloads a new version if its changed.
  2. Binary output and exporting Rust functions.

mir2wasm now supports the -o option, which gives the name of a .wasm file to write the module to. You can then run this inside of the V8 shell, d8. It probably works with other VMs, but I haven't tested that.

This includes fact.rs and fact.js to demonstrate how this works. You can run this with the following steps, from the repo root:

cargo run -- rust-examples/fact.rs -o fact.wasm --crate-type=lib
./wasm-install/bin/d8 --expose_wasm fact.js

If all goes well, you should see the number 120 printed out to the console.

This doesn't yet make any attempt to run the test suite under V8, but we have a lot of the ground work in place to do that now.

brson commented 8 years ago

OMG :sparkler: