Easy Compilation from Rust to WebAssembly portable code format



While WebAssembly (wasm) support direct compilation from C and C++, other source languages such as Rust are not easily compiled without the need for additional tools. Now, the latest nightly build of Rust, requires no extra tools to compile to the WebAssembly portable code format.

Albeit, it's not officially supported, this feature was added through a pull request to enable WebAssembly as a back end by default.

The latest nightly build uses the LLVM tool chain directly to support WebAssembly, with simpler setup and a bit more control over the output.

Though nightly builds are unsupported test offshoots of the formal Rust language code, but their capabilities often get merged into the official build later. And the Rust nightly build’s WebAssembly compilation capability is an improvement over the existing WebAssembly support, which uses the Emscripten tool.

Emscripten is an LLVM to JavaScript compiler which takes LLVM bytecode (e.g. generated from C/C++ using Clang, or from another language) and compiles them into JavaScript.

The Rust’s WebAssembly compilation, however has just limited support and documentation. But LLVM provides the tool chain for Rust as well as for the Swift and Clang languages.

And the good news remains that the Mozilla-sponsored programming language geared to developing fast system-level software, Rust can now compile to the WebAssembly portable code format without the need for additional tools.
Previous
Next Post »