Build WasmEdge from source

Please follow this guide to build and test WasmEdge from the source code.

The following guide is for Linux distributions. For MacOS, please refer to Build for macOS. For Windows, please refer to Build for Windows. For Android, please refer to Build for Android.

If you just want the latest builds from the HEAD of the master branch, and do not want to build it yourself, you can download the release package directly from our Github Action’s CI artifact. Here is an example.

Get Source Code

  1. git clone https://github.com/WasmEdge/WasmEdge.git
  2. cd WasmEdge

Check Dependencies

WasmEdge will try to use the latest LLVM release to build the nightly build. If you want to build from source, you may need to install these dependencies by yourself or using our docker images which support several Linux distributions.

  • LLVM 12.0.0 (>= 10.0.0)
  • GCC 11.1.0 (>= 9.4.0)

Prepare the Environment

Docker Images

Repository on dockerhub wasmedge/wasmedge

You can use the following commands to get our latest docker image:

  1. docker pull wasmedge/wasmedge # Pulls the latest - wasmedge/wasmedge:latest

Available Tags

tag namearchbased operating systemLLVM versionENVscompatibilitycomments
latestx86_64Ubuntu 20.04 LTS12.0.0CC=clang, CXX=clang++Ubuntu 20.04+This is for CI, will always use the latest Ubuntu release
ubuntu-build-gccx86_64Ubuntu 20.04 LTS12.0.0CC=gcc, CXX=g++Ubuntu 20.04+This is for CI, will always use the latest Ubuntu release
ubuntu-build-clangx86_64Ubuntu 20.04 LTS12.0.0CC=clang, CXX=clang++Ubuntu 20.04+This is for CI, will always use the latest Ubuntu release
ubuntu2004_x86_64x86_64Ubuntu 20.04 LTS10.0.0CC=gcc, CXX=g++Ubuntu 20.04+This is for developers who familiar with Ubuntu 20.04 LTS release
ubuntu2104_armv7larmhfUbuntu 21.0412.0.0CC=gcc, CXX=g++Ubuntu 21.04+This is for armhf release
manylinux2014_x86_64x86_64CentOS 7, 7.9.200912.0.0CC=gcc, CXX=g++Ubuntu 16.04+, CentOS 7+This is for developers who familiar with CentOS on x86_64 architecture
manylinux2014_aarch64aarch64CentOS 7, 7.9.200912.0.0CC=gcc, CXX=g++Ubuntu 16.04+, CentOS 7+This is for developers who familiar with CentOS on aarch64 architecture
manylinux2010_x86_64x86_64CentOS 6, 6.1012.0.0CC=gcc, CXX=g++Ubuntu 14.04+, CentOS 6+This is for developers who familiar with legacy system on x86_64 architecture, EOL
manylinux1_x86_64x86_64CentOS 5, 5.1112.0.0CC=gcc, CXX=g++Ubuntu 14.04+, CentOS 5+This is for developers who familiar with legacy system on x86_64 architecture, EOL

Install dependencies on Ubuntu 20.04 manually

  1. # Tools and libraries
  2. sudo apt install -y \
  3. software-properties-common \
  4. cmake \
  5. libboost-all-dev
  6. # And you will need to install llvm for wasmedgec tool
  7. sudo apt install -y \
  8. llvm-12-dev \
  9. liblld-12-dev
  10. # WasmEdge supports both clang++ and g++ compilers
  11. # You can choose one of them for building this project
  12. # If you prefer GCC then
  13. sudo apt install -y gcc g++
  14. # Or if you prefer clang then
  15. sudo apt install -y clang-12

Support for legacy operating systems

Our development environment requires libLLVM-12 and >=GLIBCXX_3.4.33.

If users are using operating systems older than Ubuntu 20.04, please use our special docker image to build WasmEdge. If you are looking for the pre-built binaries for the older operating system, we also provide several pre-built binaries based on manylinux* distribution.

Portable Linux Built Distributions TagsBase ImageProvided RequirementsDocker Image
manylinux1CentOS 5.11GLIBC <= 2.5
CXXABI <= 3.4.8
GLIBCXX <= 3.4.9
GCC <= 4.2.0
wasmedge/wasmedge:manylinux1_x86_64
manylinux2010CentOS 6.10GLIBC <= 2.12
CXXABI <= 1.3.3
GLIBCXX <= 3.4.13
GCC <= 4.5.0
wasmedge/wasmedge:manylinux2010_x86_64
manylinux2014CentOS 7.9GLIBC <= 2.17
CXXABI <= 1.3.7
GLIBCXX <= 3.4.19
GCC <= 4.8.0
wasmedge/wasmedge:manylinux2014_x86_64
manylinux2014CentOS 7.9GLIBC <= 2.17
CXXABI <= 1.3.7
GLIBCXX <= 3.4.19
GCC <= 4.8.0
wasmedge/wasmedge:manylinux2014_aarch64

Build WasmEdge

WasmEdge provides various tools for enabling different runtime environments for optimal performance. You can find that there are several wasmedge related tools:

  1. wasmedge is the general wasm runtime.
    • wasmedge executes a WASM file in the interpreter mode or a compiled WASM so (shared object) file in the ahead-of-time compilation mode.
    • To disable building all tools, you can set the CMake option WASMEDGE_BUILD_TOOLS to OFF.
  2. wasmedgec is the ahead-of-time WASM compiler.
    • wasmedgec compiles a general WASM file into a so (shared object) file.
    • To disable building the ahead-of-time compiler only, you can set the CMake option WASMEDGE_BUILD_AOT_RUNTIME to OFF.
  3. libwasmedge_c.so is the WasmEdge C API shared library.
    • libwasmedge_c.so provides the C API for the ahead-of-time compiler and the WASM runtime.
    • The APIs related to the ahead-of-time compiler will always fail if the CMake option WASMEDGE_BUILD_AOT_RUNTIME is set as OFF.
    • To disable building just the shared library, you can set the CMake option WASMEDGE_BUILD_SHARED_LIB to OFF.
  4. ssvm-qitc is for AI applications and supports the ONNC runtime for AI models in the ONNX format.
  1. # After pulling our wasmedge docker image
  2. docker run -it --rm \
  3. -v <path/to/your/wasmedge/source/folder>:/root/wasmedge \
  4. wasmedge/wasmedge:latest
  5. # In docker
  6. cd /root/wasmedge
  7. # If you don't use docker then you need to run only the following commands in the cloned repository root
  8. mkdir -p build && cd build
  9. cmake -DCMAKE_BUILD_TYPE=Release -DWASMEDGE_BUILD_TESTS=ON .. && make -j

If you don’t want to build Ahead-of-Time runtime/compiler

If you don’t need Ahead-of-Time runtime/compiler support, you can set the CMake option WASMEDGE_BUILD_AOT_RUNTIME to OFF.

  1. cmake -DCMAKE_BUILD_TYPE=Release -DWASMEDGE_BUILD_AOT_RUNTIME=OFF ..

Run built-in tests

The following built-in tests are only available when the build flag WASMEDGE_BUILD_TESTS is set to ON.

Users can use these tests to verify the correctness of WasmEdge binaries built.

  1. # In docker
  2. cd <path/to/wasmedge/build_folder>
  3. LD_LIBRARY_PATH=$(pwd)/lib/api ctest

Run applications

Next, follow this guide to run WebAssembly bytecode programs in wasmedge.