Skip to content

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

  1. Install system dependencies (see apt in Dockerfile)

  2. 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.

  3. Build glibc and generate sysroot (see make sysroot)

    1. Configure and compile glibc for the WASI target with Clang

    2. Compile extra files:

      • nptl/pthread_create.c
      • lind_syscall/lind_syscall.c
      • csu/wasm32/wasi_thread_start.s
      • csu/wasm32/set_stack_pointer.s
    3. 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.

  4. Build custom wasmtime (see make wasmtime)

    Builds src/wasmtime workspace. Custom dependencies fdtables, RawPOSIX and sysdefs 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.