wasm-utils/README.md

40 lines
1.3 KiB
Markdown
Raw Normal View History

2017-05-30 15:06:46 +04:00
# wasm-utils
2017-04-12 20:52:01 +04:00
2017-05-30 15:06:46 +04:00
Collection of WASM utilities used in Parity and WASM contract devepment
2017-04-12 20:52:01 +04:00
2017-08-09 14:00:09 +03:00
## Build tools for cargo
Easiest way to use is to install via `cargo install`:
```
cargo install --git https://github.com/paritytech/wasm-utils wasm-build
```
2017-09-15 22:03:43 +03:00
## Symbols pruning (wasm-prune)
2017-04-12 20:52:01 +04:00
```
2017-09-15 22:03:43 +03:00
cargo run --release --bin wasm-prune -- <input_binary.wasm> <output_binary.wasm>
2017-04-12 20:52:01 +04:00
```
2017-05-31 15:10:20 +04:00
This will optimize WASM symbols tree to leave only those elements that are used by contract `_call` function entry.
2017-04-12 20:52:01 +04:00
2017-05-30 15:06:46 +04:00
## Gas counter (wasm-gas)
2017-04-12 20:53:31 +04:00
2017-05-30 15:06:46 +04:00
For development puposes, raw WASM contract can be injected with gas counters (the same way as it done by Parity runtime when running contracts)
2017-04-12 20:52:01 +04:00
2017-05-30 15:06:46 +04:00
```
2017-05-30 15:08:19 +04:00
cargo run --release --bin wasm-gas -- <input_binary.wasm> <output_binary.wasm>
2017-05-30 15:06:46 +04:00
```
## Allocators substiution (wasm-ext)
2017-05-30 15:15:11 +04:00
Parity WASM runtime provides simple memory allocators, if contract requires. When relied on this allocators, WASM binary size can be greatly reduced. This utility scans for `_malloc`, `_free` invokes inside the WASM binary and substitutes them with invokes of the imported `_malloc`, `_free`. Should be run before `wasm-opt` for better results.
2017-05-30 15:06:46 +04:00
2017-05-30 15:08:19 +04:00
```
cargo run --release --bin wasm-ext -- <input_binary.wasm> <output_binary.wasm>
```
## API
2017-05-30 15:08:42 +04:00
All executables use corresponding api methods of the root crate and can be combined in other build tools.