Throughout our examples, we make extensive use of the ssvmup tool. It is inspired by the wasm-pack project but is optimized for server-side applications. Specifically, it supports the SSVM WebAssembly virtual machine and Deno host runtime.
The ssvmup uses
The ssvmup depends on the Rust cargo toolchain to compile Rust source code to WebAssembly. You must have Rust installed on your machine.
$ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh $ source $HOME/.cargo/env
The easiest way to install ssvmup is to use its installer.
$ curl https://raw.githubusercontent.com/second-state/ssvmup/master/installer/init.sh -sSf | sh
Alternatively, you can install using the NPM if you'd like.
$ ssvmup build
--enable-ext flag to compile Rust programs that use WASI extensions, such as SSVM's storage, native command and tensorflow APIs. The
ssvmup will run the compiled WebAssembly bytecode program in the
ssvm-extensions Node.js module instead of plain
ssvm in this case.
$ ssvmup build --enable-ext
To build Rust functions for Deno applications, use the following command. See a template application.
$ ssvmup build --target deno
A key feature of the SSVM is its support for Ahead-of-Time (AOT) compilers. When you run WebAssembly programs in Node.js
ssvm-extensions add-ons, you typically do not need to worry about it as the add-on handles AOT compilation transparently. However, in some cases, you do want the
ssvmup to compile and generate native code for the program. An example is the Tensorflow as a Service template for Tencent Cloud.
Then, use the commands below to bring your operating system up to date with the latest developer tools. The commands here are tested on Ubuntu 20.04.
$ sudo apt-get update $ sudo apt-get -y upgrade $ sudo apt install build-essential curl wget git vim libboost-all-dev llvm-dev liblld-10-dev
Now, you can build the
.so files for the AOT native target like the following.
$ ssvmup build --enable-aot