Giter Site home page Giter Site logo

wasm2native's Introduction

SWUbanner

wasm2native

Turn WASI apps into native executables

How it works

The approach is similar to WasmBoxC or RLBox:

WASM file ๐Ÿ – WASM to C translator ๐Ÿ – platform C compiler + libuvwasi + libuv ๐Ÿ – native executable

Prerequisites

  • CMake
  • Native toolchain (GCC/Clang/MSVC). Optional: Zig

Usage examples

# Single step:
export CC="clang-12"
export LDFLAGS="-fuse-ld=lld"
./build.sh ./examples/coremark.wasm

# Cross-compile with Zig CC: x86_64-windows-gnu, x86_64-linux-gnu, x86_64-macos-gnu
CC="zig cc -target x86_64-linux-musl" ./build.sh ./examples/coremark.wasm

# Cross-compilation to other architectures
# For full targets list: zig targets | jq .libc
CC="zig cc -target aarch64-linux-musl" ./build.sh ./examples/hello.wasm
qemu-aarch64-static hello.elf
Hello from WebAssembly!

Note: this tool can be used for building WASI apps, not emscripten-generated wasm+js output.

Coremark 1.0 results

Intel(R) Core(TM) i5-10400 CPU @ 2.90GHz, single-thread:

  • Native: 32475
  • wasm2c: 27400 (84% of native)

TODO

  • Big-endian target support
  • Windows host support
  • Convert main script to zig
    • Allow setting CFLAGS, overriding optimization flags
  • CI via Github Actions
  • Get rid of mandatory CMake dependency (write build script for libuv and uvwasi for major platforms)

License

This project is released under The MIT License (MIT)

wasm2native's People

Contributors

vshymanskyy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

wasm2native's Issues

WASM Executable from NodeJS

Hello, I have this project that supports WASM module as alternative.
The module here needs an external resource file to run, files requested are the following

fasttext.js (api header)
fasttext_wasm.js (wasm loader)
lid.176.ftz (resource/model file to load)

Is it possibile to use wasm2native to compile and bundle these three files to one executable file?

Thank you.

wasm2c support

Is wasm2c still supported? It looks like this project switched from wasm2c to w2c2 as the default, but there is still some leftover code from wasm2c. I briefly tried to get it working, but it looks like maybe the old code is no longer compatible with the latest version of wasm2c, is that correct?

[Documentation] Could more small examples be added?

Could more small examples be added?

A bit like an "actionable FAQ".

"How to turn this hello-world into a WASM application"

or how to respond to this button click-event, from WASM point of view;
how to interoperate with it from ruby, python etc...

I understand that time is limited, so I am really just asking on SMALL
and simple examples how to make things work from a practical
point of view. With WASM in general I found there is a lack of
clear, concise and simple documentation + example, at the least
in ruby. Hopefully the whole WASM ecosystem can become better
in this regard, to avoid having to use StackOverflow all of the
time. :D

(Once people understand a specific part of software better, they
no longer need this basic information, so this is really more of
"getting new people on board of WASM".)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.