Coder Social home page Coder Social logo

wasmer-example's Introduction

Requirements

One of the following compilers is enough.

Install WASM-SDK and WASMER

Wasienv seems to be abandoned. Use the following command in a setup folder to download MacOS builds.

export WASI_VERSION=20
export WASI_VERSION_FULL=${WASI_VERSION}.0
wget https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${WASI_VERSION}/wasi-sdk-${WASI_VERSION_FULL}-macos.tar.gz
tar xvf wasi-sdk-${WASI_VERSION_FULL}-macos.tar.gz

Then, in bashrc, export WASISDK_DIR to be the bin folder.

Install wasmer via Homebrew brew install wabt wasmer.

To check:

${WASISDK_DIR}/clang++ -v
# clang version 16.0.0 (https://github.com/llvm/llvm-project 08d094a0e457360ad8b94b017d2dc277e697ca76)
# Target: wasm32-unknown-wasi
# Thread model: posix

wasmer --version
# wasmer 3.3.0

Now we can use wasmc++ and wasic++ to compile C++ sources into WASM/WASI.

Install Emscripten

Install with brew install emscripten

To check:

emcc --version
# emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.39-git
# Copyright (C) 2014 the Emscripten authors (see AUTHORS.txt)
# This is free and open source software under the MIT license.
# There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Differences between compilers

  • wasic++ will include the standard library.
  • wasmc++ will not include any extra library. The generated wasm will be very small in size.
    • Note: wasic++ will also include syscalls, but by default Wasmer does not expose them.
  • Emscripten is more "on the browser's side".

Compilation

Execute make in csrc folder to compile C++ code into WASM. Then you can execute the main program by go run ..

wasmer-example's People

Contributors

zjkmxy avatar

Watchers

James Cloos avatar  avatar  avatar

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.