Lind toolchain
The toolchain to build and run lind programs consists of the following components:
- Clang with WebAssembly System Interface (WASI) support to build glibc and lind programs
- A custom glibc used as sysroot to build lind programs
- A custom
wasm-opt
binary to enable multi-processing in lind programs - A custom WebAssembly runtime (
wasmtime
) with RawPOSIX to run lind programs - Cargo to build
wasmtime
This document gives an overview of how the toolchain is built. The build process is automated with Docker, make and custom shell scripts. Please refer to the relevant files linked below for details about the build commands and used options.
Building the toolchain step by step
-
Install system dependencies (see
apt
in Dockerfile) -
Download Clang and install builtins (see "Install clang" in Dockerfile)
Clang supports the WASI cross-compilation target out of the box, provided the necessary compiler runtime builtins and a matching sysroot. See wasi-sdk docs for details.
A pre-built Clang can be downloaded from the llvm-project releases page. Matching builtins are available in the lind-wasm repo under
src/glibc/wasi
. -
Build glibc and generate sysroot (see
make sysroot
)-
Configure and compile glibc for the WASI target with Clang
-
Compile extra files:
nptl/pthread_create.c
lind_syscall/lind_syscall.c
csu/wasm32/wasi_thread_start.s
csu/wasm32/set_stack_pointer.s
-
Generate sysroot
Combine the built object files into a single archive file and copy along with headers and a pre-built C runtime into a sysroot directory structure as required by Clang.
-
-
Build custom wasmtime (see
make wasmtime
)Builds
src/wasmtime
workspace. Custom dependenciesfdtables
,RawPOSIX
andsysdefs
are included in the build automatically.
A customized wasm-opt
binary is included in the lind-wasm repo under
tools/binaryen/bin
and can be used as is.
Next steps
Automate the build and run programs with Docker
and make
.