Skip to content

Instantly share code, notes, and snippets.

@jwasinger
Last active January 23, 2019 13:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jwasinger/01016ec3d7f1d7cf8a10f26befbcd504 to your computer and use it in GitHub Desktop.
Save jwasinger/01016ec3d7f1d7cf8a10f26befbcd504 to your computer and use it in GitHub Desktop.
Instructions for compiling ecadd benchmark to native using wasm2c
> ( git clone https://github.com/jwasinger/ewasm-precompiles -b ecadd-benchmark && cd ewasm-precompiles && cargo build --target wasm32-unknown-unknown )
> git clone https://github.com/webassembly/wabt
> cd wabt/wasm2c && cp /path/to/ewasm-precompiles/target/wasm32-unknown-unknown/debug/ecadd_benchmark.wasm .
> ( build wabt )
> wasm2c ecadd_benchmark.wasm -o ecadd_benchmark.c
  1. In the same folder, create a file main.c:
#include "ecadd_benchmark.h"

int main(int argc, char** argv) {
  init();

  Z_ecadd_benchmarkZ_vv();

  return 0;
}

Note Z_ecadd_benchmarkZ_vv will have to be replaced with the mangled name of the exported function in ecadd_benchmark.h.

  1. Compile: gcc -o ecadd_benchmark wasm-rt-impl.c ecadd_benchmark.c main.c
@jwasinger
Copy link
Author

if you don't want to go through most of the steps, you can compile these C files to create the benchmark.

@poemm
Copy link

poemm commented Jan 23, 2019

Help?

$ cargo build --target wasm32-unknown-unknown
    Updating crates.io index
    Updating git repository `https://github.com/ewasm/ethereum-bls12.rs`
    Updating git repository `https://github.com/paritytech/parity-common`                                                          
    Updating git repository `https://github.com/ewasm/ethereum-bn128.rs`                                                           
    Updating git repository `https://github.com/paritytech/bn`                                                                     
error: no matching version `^0.7` found for package `subtle`                                                                       
location searched: registry `https://github.com/rust-lang/crates.io-index`
versions found: 2.0.0, 1.0.0
required by package `curve25519-dalek v0.19.1`
    ... which is depended on by `ed25519-dalek v0.8.0`
    ... which is depended on by `ewasm-precompile-ed25519 v0.0.1 (/home/user/Downloads/jareds_wasm2c_benchmark/ewasm-precompiles/ed25519)`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment