second-state/rustwasmc

Rust compiler toolkit for WebAssembly apps in the WasmEdge Runtime

Developers: Getting started with the Tencent Serverless Functions for AI inference, or WasmEdge Runtime

rustwasmc

Rust compiler toolkit for WebAssembly apps in the WasmEdge Runtime

Developers: Getting started with the Second State Functions (a serverless FaaS service), Tencent Serverless Functions for AI inference, or your own Node.js server.

About

A one-stop tool for building Rust functions into WebAssembly for deployment on the WasmEdge Runtime.

Prerequisite

You will need to install the Rust compiler in order to use rustwasmc. Currently, we support up to Rust 1.50.0.

Install

From Linux command line

From NPM and Node.js

Usage

To build Rust functions for Node.js applications, use the following command. See a template application. The rustwasmc compiles and generates the wasm file, and the corresponding JavaScript file to call wasm functions from JavaScript. If the rust package contains only binary crate(s) and there are no library crate, the build command will only generate a wasm-wasi file for running as a standalone command program in the WasmEdge VM.

In most cases, you will want to enable AOT optimization in order to improve performance.

If you would like to use WasmEdge's extended APIs including Tensorflow, enable the extensions. Make sure that you install the wasmedge-extensions NPM module in this case.

To build Rust functions for Deno applications, use the following command. See a template application.

By default, rustwasmc will generate a directory for it's build output called pkg. If you'd like to customize this you can use the --out-dir flag.

Use clean subcommand to remove pkg and target directories.

Logging

rustwasmc uses env_logger to produce logs when rustwasmc runs.

To configure your log level, use the RUST_LOG environment variable. For example:

Known issues

For Rust version 1.51 and above, rustwasmc generates bytecode without WASI support. That means programs that access the file system, date and time, environment variables, and command line arguments would fail on Rust 1.50+. This should not affect most application use cases. We are working on a solution.

Acknowledgment

This project is derived from the open source wasm-pack.

Issues

Collection of the latest Issues

watzon

watzon

Comment Icon0

This is going to be similar to this issue, but I feel like this is a better place for it since it seems like the error is coming from the JS code generation. First, the code:

I've omitted the ige_decrypt method for brevity.

When generating a JS file for this code using the command: rustwasmc build --target deno I end up with a mostly correct file. The error seems to be happening the it comes to setting the wasi_snapshot_preview1 key on the imports object. Instead of assigning the key to the existing object, it overwrites the object entirely.

Here are the relevant code snippets:

Hope this is enough info. I'm running the latest version of rustwasmc currently, 0.1.28.

alexl0gan

alexl0gan

Comment Icon0

I'm trying to compile the following lib file

Using the command

However this causes the following error in Deno

It looks like the offending line is

Which is clearing the other imports added earlier in the file.

Versions

Find the latest versions by id

v0.1.29 - Jul 20, 2021

v0.1.28 - Jun 29, 2021

v0.1.27 - Jun 02, 2021

v0.1.26 - May 26, 2021

Fix tiny bug

v0.1.25 - May 26, 2021

revert the default target back to wasm32-wasi. set target to wasm32-unknown-unknown if the crate type is clib and version of rustc is 1.51.0 or higher

v0.1.24 - May 25, 2021

v0.1.23 - May 25, 2021

wasm32-unknown-unknown will be the default target. Use --wasi to compile to wasm32-wasi.

v0.1.22 - May 03, 2021

v0.1.21 - Apr 14, 2021

There is an installation issue reported in https://github.com/second-state/rustwasmc/issues/11#issue-874031180 It seems that these binaries need to be rebuilt and then re-uploaded here.

For example: a) the name of the compressed binary must be rustwasmc instead of ssvmup (so that the URL for the fetch in the installer is correct) b) the actual root dir of the repo (once uncompressed) needs to be rustwasmc instead of ssvmup or the installer will break.

v0.1.20 - Dec 11, 2020

v0.1.19 - Dec 06, 2020

v0.1.18 - Nov 05, 2020

When --enable-aot, compile .wasm to .so using ssvmc 0.7.0.

v0.1.17 - Sep 08, 2020

v0.1.16 - Aug 10, 2020

v0.1.15 - Aug 03, 2020

v0.1.14 - Jul 24, 2020

v0.1.13 - Jul 22, 2020

v0.1.12 - Jul 21, 2020

v0.1.11 - Jun 10, 2020

v0.1.10 - Jun 09, 2020

v0.1.9 - Jun 04, 2020

v0.1.8 - May 18, 2020

v0.1.7 - May 16, 2020

v0.1.6 - Apr 30, 2020

v0.1.5 - Apr 28, 2020

v0.1.4 - Apr 04, 2020

v0.1.3 - Apr 02, 2020

v0.1.2 - Mar 24, 2020

v0.1.1 - Mar 21, 2020

Information - Updated Apr 30, 2022

Stars: 101
Forks: 10
Issues: 5

This is an example of a Rust server that functions as a remote schema for...

Rust + Hasura Rust server that functions as a Hasura

This is an example of a Rust server that functions as a remote schema for...

Newport Engine is a modular 2D and 3D game engine built in Rust for Rust

It is designed to be easily extendable and easy to use

Newport Engine is a modular 2D and 3D game engine built in Rust for Rust

Newport Engine is a modular 2D and 3D game engine built in Rust for Rust

It is designed to be easily extendable and easy to use

Newport Engine is a modular 2D and 3D game engine built in Rust for Rust

liboqs-rust: Rust bindings for liboqs

Qyantum Safe liboqs rust bindings

liboqs-rust: Rust bindings for liboqs

msgflo-rust: Rust participant support for MsgFlo

Flowhub visual programming IDE

msgflo-rust: Rust participant support for MsgFlo
Actix

1.0K

How to be a full stack Rust Developer

Read Rust the Rust blog posts at Steadylearner

How to be a full stack Rust Developer

Rust library translation (rust-src/rust-std/stdlib/rustlib translation)

This is the place to translate Having a documentation in your native language is essential if you don't speak English, and still enjoyable even if...

Rust library translation (rust-src/rust-std/stdlib/rustlib translation)

False Positive for rust-lang/rust#83583

The deprecation lint proc_macro_derive_resolution_fallback is intended to catch proc macro generated code that refers to items from parent modules that should not be in scope:

False Positive for rust-lang/rust#83583

A CHIP-8 & SuperChip interpreter written in Rust using rust-sdl2

If you're getting compile errors it may be because

A CHIP-8 & SuperChip interpreter written in Rust using rust-sdl2

Rust-Svelte-on-Rust

Starter template for Rocket backend server

Rust-Svelte-on-Rust

xbuild is a build tool for rust and rust/flutter projects with support for cross compiling...

xbuild is a build tool for rust and rust/flutter projects with support for cross compiling and

xbuild is a build tool for rust and rust/flutter projects with support for cross compiling...
Facebook Instagram Twitter GitHub Dribbble
Privacy