Skip to content

Commit da24bdd

Browse files
committed
C/C++ guide fixes, links
1 parent 79d99ad commit da24bdd

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

c_cpp_guide.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
# C/C++ to ewasm contracts
1+
# Compiling C/C++ to Ewasm
22

33
First an introduction to discuss quirks, then a step-by-step guide for how to compile ewasm contracts from C and C++. Warning: the ewasm spec and tools below are subject to change.
44

55
## Introduction
66

7-
An ewasm contracts is a WebAssembly module with restrictions. The module's imports must be among the [ewasm helper functions](https://github.com/ewasm/design/blob/master/eth_interface.md) which resemble EVM opcodes to interact with the client. The module's exports must be a `main` function which takes no arguments and returns nothing, and the `memory` of the module. The module can't using floats and other non-determinisms.
7+
An ewasm contract is a WebAssembly module with restrictions. The module's imports must be among the [ewasm helper functions](https://github.com/ewasm/design/blob/master/eth_interface.md) which resemble EVM opcodes to interact with the client. The module's exports must be a `main` function which takes no arguments and returns nothing, and the `memory` of the module. The module can't using floats and other sources of non-determinism.
88

99
There are four quirks to using C/C++ to write ewasm smart contracts. These quirks may improve as tools and ewasm improve.
1010

@@ -24,13 +24,13 @@ The wasmception package offers patches to libc and libc++ which allow using `mal
2424
```sh
2525
git clone https://github.com/yurydelendik/wasmception.git
2626
cd wasmception
27-
make -j4 # Warning: this required lots of bandwidth, RAM, and time. One hours on a mid-level laptop.
27+
make -j4 # Warning: this required lots of bandwidth, RAM, and time. One hour on a mid-level laptop.
2828
cd ..
2929
```
3030

3131
Write down the end of the output of the above make command, it should be something like: `--sysroot=/home/user/repos/wasmception/sysroot`.
3232

33-
Next we modified the wasmception examples into an ewasm contract, and is available for download. Make sure to edit the Makefile with the sysroot above, and change the path to our newly compiled version of clang to something like `/home/user/repos/wasmception/dist/bin/clang`. Make sure that `main.syms` has a list of ewasm helper functions you are using. If you are using C++, make sure to modify the Makefile to clang++, use `extern "C"` around the helper function declarations, and follow other tips from wasmception.
33+
We modified the wasmception example into an ewasm contract, which we will now download. Make sure to edit the Makefile with the sysroot above, and change the path to our newly compiled version of clang to something like `/home/user/repos/wasmception/dist/bin/clang`. Make sure that `main.syms` has a list of ewasm helper functions you are using. If you are using C++, make sure to modify the Makefile to clang++, use `extern "C"` around the helper function declarations, and follow other tips from wasmception.
3434

3535
```sh
3636
git clone https://gist.github.com/poemm/91b64ecd2ca2f1cb4a88d31315313b9b.git cwrc20
@@ -41,7 +41,7 @@ make
4141

4242
The output is `main.wasm`, but it needs some cleanup to remove some of it's extra import and export junk. For this, we use PyWebAssembly.
4343

44-
Aside: Alternatively, one can use a rust implementation of `wasm_chisel`. But that requires a rust compiler.
44+
Aside: Alternatively, one can use a rust implementation of [wasm-chisel](https://github.com/wasmx/wasm-chisel), or install with `cargo install chisel`. But that requires a rust compiler.
4545
```
4646
cd ..
4747
git clone https://github.com/poemm/pywebassembly.git
@@ -65,4 +65,4 @@ cd ../../cwrc20
6565
../binaryen/build/bin/wasm-dis main_chiseled.wasm > main_chiseled.wat
6666
```
6767

68-
Now `main_chiseled.wat` can be pasted into ewasm explorer and deployed. Happy hacking!
68+
Now `main_chiseled.wat` can be pasted into [ewasm studio](http://ewasm.ethereum.org/studio/) and deployed. Happy hacking!

0 commit comments

Comments
 (0)