Setting up our tutorial environment

To run the example in our two part tutorial, create an example directory where our example app and tools will live, and enter that directory:

mkdir example
cd example

Then follow the instruction for setting up the RLBox environment.

Next, clone the repo for this book, which contains our example code, and copy it to its own directory, and build the example code.

git clone https://github.com/PLSysSec/rlbox-book
mkdir myapp
cp -r rlbox-book/src/chapters/examples/noop-hello-example/* myapp
cd myapp
cmake -S . -B ./build -DCMAKE_BUILD_TYPE=Release
cmake --build ./build --config Release --parallel

Then run it to make sure everything is working.

./build/main

You should see the following output:

Hello from mylib
Adding... 3+4 = 7
Adding... 3+4 = 7
OK? = 1
echo: hi hi!
hello_cb: hi again!

Finally, return to the example directory, and clone and build our wasm toolchain, which includes a copy of wasm2c, the wasi-sdk (everything you need to compile your C to wasm).

cd ..
git clone https://github.com/PLSysSec/rlbox_wasm2c_sandbox
cd rlbox_wasm2c_sandbox
cmake -S . -B ./build
cmake --build ./build --target all
cd ..