Build Guide
Please follow this guide to build and test WasmEdge from the source code.
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.
What Will Be Built
WasmEdge provides various tools for enabling different runtime environments for optimal performance. You can find that there are several wasmedge related tools:
wasmedge
is the general wasm runtime.wasmedge
executes aWASM
file in the interpreter mode or a compiledWASM
file in the ahead-of-time compilation mode.- To disable building all tools, you can set the CMake option
WASMEDGE_BUILD_TOOLS
toOFF
.
wasmedgec
is the ahead-of-timeWASM
compiler.wasmedgec
compiles a generalWASM
file into a compiledWASM
file.- To disable building the ahead-of-time compiler only, you can set the CMake option
WASMEDGE_BUILD_AOT_RUNTIME
toOFF
.
备注The usage of
wasmedgec
is equal towasmedge compile
. We decide to deprecatewasmedgec
in the future.libwasmedge.so
is the WasmEdge C API shared library. (libwasmedge.dylib
on MacOS andwasmedge.dll
on Windows)libwasmedge.so
,libwasmedge.dylib
, orwasmedge.dll
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 asOFF
. - To disable building just the shared library, you can set the CMake option
WASMEDGE_BUILD_SHARED_LIB
toOFF
.
ssvm-qitc
is for AI applications and supports the ONNC runtime for AI models in the ONNX format.- If you want to try
ssvm-qitc
, please refer to ONNC-Wasm project to set up the working environment and tryout several examples. - And here is our tutorial for ONNC-WASM project(YouTube Video).
- If you want to try
CMake Building Options
Developers can set the CMake options to customize the WasmEdge building.
WASMEDGE_BUILD_TESTS
: build the WasmEdge tests. Default isOFF
.WASMEDGE_USE_LLVM
: build with LLVM-based runtime for supporting Ahead-of-Time and Just-In-Time compiler. Default isON
.WASMEDGE_BUILD_SHARED_LIB
: build the WasmEdge shared library (libwasmedge.so
,libwasmedge.dylib
, orwasmedge.dll
). Default isON
.- By default, the WasmEdge shared library will link to the LLVM shared library.
WASMEDGE_BUILD_STATIC_LIB
: build the WasmEdge static library (libwasmedge.a
, Linux and MacOS platforms, experimental). Default isOFF
.- If this option is set as
ON
, the optionWASMEDGE_FORCE_DISABLE_LTO
will forcefully be set asON
. - If this option is set as
ON
, thelibz
andlibtinfo
on Linux platforms will be statically linked. - For linking with
libwasmedge.a
, developers should also add the-ldl
,-pthread
,-lm
, and-lstdc++
linker options on both Linux and MacOS platforms, and-lrt
on Linux platforms.
- If this option is set as
WASMEDGE_BUILD_TOOLS
: build thewasmedge
andwasmedgec
tools. Default isON
.- The
wasmedge
andwasmedgec
tools will link to the WasmEdge shared library by default. - If this option is set as
ON
andWASMEDGE_USE_LLVM
is set asOFF
, thewasmedgec
tool for the AOT compiler will not be built. - If this option is set as
ON
but the optionWASMEDGE_LINK_TOOLS_STATIC
is set asOFF
, the optionWASMEDGE_BUILD_SHARED_LIB
will forcefully be set asON
. - If this option and the option
WASMEDGE_LINK_TOOLS_STATIC
are both set asON
, theWASMEDGE_LINK_LLVM_STATIC
andWASMEDGE_BUILD_STATIC_LIB
will both be set asON
, and thewasmedge
andwasmedgec
tools will link to the WasmEdge static library instead. In this case, the plug-ins will not work in tools.
- The
WASMEDGE_BUILD_PLUGINS
: build the WasmEdge plug-ins. Default isON
.WASMEDGE_BUILD_EXAMPLE
: build the WasmEdge examples. Default isOFF
.WASMEDGE_FORCE_DISABLE_LTO
: forcefully turn off the link time optimization. Default isOFF
.WASMEDGE_LINK_LLVM_STATIC
: link the LLVM and lld libraries statically (Linux and MacOS platforms only). Default isOFF
.WASMEDGE_LINK_TOOLS_STATIC
: make thewasmedge
andwasmedgec
tools to link the WasmEdge library and LLVM libraries statically (Linux and MacOS platforms only). Default isOFF
.- If the option
WASMEDGE_BUILD_TOOLS
and this option are both set asON
, theWASMEDGE_LINK_LLVM_STATIC
will be set asON
.
- If the option
WASMEDGE_ENABLE_UB_SANITIZER
: enable the undefined behavior sanitizer. Default isOFF
.WASMEDGE_PLUGIN_WASI_NN_BACKEND
: build the WasmEdge WASI-NN plug-in (Linux platforms only). Default is empty.- This option is useless if the option
WASMEDGE_BUILD_PLUGINS
is set asOFF
. - To build the WASI-NN plug-in with backend, please use
-DWASMEDGE_PLUGIN_WASI_NN_BACKEND=<backend_name>
. - To build the WASI-NN plug-in with multiple backends, please use
-DWASMEDGE_PLUGIN_WASI_NN_BACKEND=<backend_name1>,<backend_name2>
.
- This option is useless if the option
WASMEDGE_PLUGIN_WASI_CRYPTO
: build the WasmEdge WASI-Crypto plug-in (Linux and MacOS platforms only). Default isOFF
.- This option is useless if the option
WASMEDGE_BUILD_PLUGINS
is set asOFF
.
- This option is useless if the option
WASMEDGE_PLUGIN_WASI_LOGGING
: build the WasmEdge WASI-Logging plug-in (Linux and MacOS platforms only). Default isON
.- In WasmEdge
0.14.1
, the WASI-Logging plug-in is bundled into the WasmEdge library and will not generate the plug-in shared library target. - This option is useless if the option
WASMEDGE_BUILD_PLUGINS
is set asOFF
.
- In WasmEdge
WASMEDGE_PLUGIN_WASM_BPF
: build the WasmEdge wasm_bpf plugin (Linux platforms only). Default isOFF
.- This option is useless if the option
WASMEDGE_BUILD_PLUGINS
is set asOFF
.
- This option is useless if the option
WASMEDGE_PLUGIN_IMAGE
: build the WasmEdge image plugin (Linux and MacOS platforms only). Default isOFF
.- This option is useless if the option
WASMEDGE_BUILD_PLUGINS
is set asOFF
.
- This option is useless if the option
WASMEDGE_PLUGIN_TENSORFLOW
: build the WasmEdge TensorFlow plugin (Linux and MacOS platforms only). Default isOFF
.- This option is useless if the option
WASMEDGE_BUILD_PLUGINS
is set asOFF
.
- This option is useless if the option
WASMEDGE_PLUGIN_TENSORFLOWLITE
: build the WasmEdge TensorFlow-Lite plug-in (Linux and MacOS platforms only). Default isOFF
.- This option is useless if the option
WASMEDGE_BUILD_PLUGINS
is set asOFF
.
- This option is useless if the option
Build WasmEdge with Plug-ins
Developers can follow the steps to build WasmEdge with plug-ins from source.
- WASI-NN (with several backends)
- WASI-Crypto
- WasmEdge-Image
- WasmEdge-TensorFlow
- WasmEdge-TensorFlowLite
- WASI-Logging
Run Tests
The tests are only available when the build option WASMEDGE_BUILD_TESTS
is set to ON
.
Users can use these tests to verify the correctness of WasmEdge binaries built.
cd <path/to/wasmedge/build_folder>
LD_LIBRARY_PATH=$(pwd)/lib/api ctest