wasm-bpf/docs/build.md

1.8 KiB

Build the runtime and examples

We have two types of runtime examples:

  • A C/C++ runtime example, which is a minimal runtime based on WAMR. see runtime/cpp for more details.
  • A Rust runtime example, which is a more complex runtime based on Wasmtime. see runtime/rust for more details.

A new runtime is easy to implement with only a few hundred lines of code, in any language, using any wasm runtime or any ebpf user space library.

Build the C++ minimal runtime based on WAMR1

The dependencies are libbpf and wasm-micro-runtime only, they are registered as git submodules.

git submodule update --init --recursive
cd runtime/cpp

Install Dependencies

You will need clang, libelf and zlib to build the examples, package names may vary across distros.

on Ubuntu/Debian, you need:

sudo apt install clang libelf1 libelf-dev zlib1g-dev

on CentOS / Fedora, you need:

sudo dnf install clang elfutils-libelf elfutils-libelf-devel zlib-devel

Build runtime as a executable tool

Run make in the runtime/cpp directory to build the runtime, which will be placed in the build directory. cmake is required to build the runtime.

make build

Build runtime as a library

make build-lib

You may refer to CI for more details on how to build and run the examples.

Build the Rust runtime based on Wasmtime2

install rust toolchain

curl https://sh.rustup.rs -sSf | sh -s

Build runtime as a executable tool

Run make in the runtime/rust directory to build the runtime, which will be placed in the target directory.

make build