Giter Site home page Giter Site logo

yujunjung / wasi-sdk Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dicej/wasi-sdk

0.0 0.0 0.0 196 KB

WASI-enabled WebAssembly C/C++ toolchain

License: Apache License 2.0

Shell 38.87% C++ 1.46% C 27.19% Makefile 18.35% CMake 7.84% Dockerfile 6.29%

wasi-sdk's Introduction

WASI SDK

Quick Start

Download SDK packages here.

About this repository

This repository contains no compiler or library code itself; it uses git submodules to pull in the upstream Clang and LLVM tree, as well as the wasi-libc tree.

The libc portion of this SDK is maintained in wasi-libc.

Upstream Clang and LLVM (from 9.0 onwards) can compile for WASI out of the box, and WebAssembly support is included in them by default. So, all that's done here is to provide builds configured to set the default target and sysroot for convenience.

One could also use a standard Clang installation, build a sysroot from the sources mentioned above, and compile with --target=wasm32-wasi --sysroot=/path/to/sysroot. In this scenario, one would also need the libclang_rt.builtins-wasm32.a objects available separately in the release downloads which must be extracted into $CLANG_INSTALL_DIR/$CLANG_VERSION/lib/wasi/.

Clone

This repository uses git submodule, to clone it you need use the command below :

git clone --recursive https://github.com/WebAssembly/wasi-sdk.git

Requirements

The Wasm-sdk's build process needs some packages :

  • cmake
  • clang
  • ninja

Please refer to your OS documentation to install those packages.

Build

To build the full package:

cd wasi-sdk
NINJA_FLAGS=-v make package

The built package can be found into dist directory. For releasing a new version of the package on GitHub, see RELEASING.md.

Install

A typical installation from the release binaries might look like the following:

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}-linux.tar.gz
tar xvf wasi-sdk-${WASI_VERSION_FULL}-linux.tar.gz

Use

Use the clang installed in the wasi-sdk directory:

export WASI_SDK_PATH=`pwd`/wasi-sdk-${WASI_VERSION_FULL}
CC="${WASI_SDK_PATH}/bin/clang --sysroot=${WASI_SDK_PATH}/share/wasi-sysroot"
$CC foo.c -o foo.wasm

Note: ${WASI_SDK_PATH}/share/wasi-sysroot contains the WASI-specific includes/libraries/etc. The --sysroot=... option is not necessary if WASI_SDK_PATH is /opt/wasi-sdk. For troubleshooting, one can replace the --sysroot path with a manual build of wasi-libc.

Notes for Autoconf

Autoconf 2.70 now recognizes WASI.

For convenience when building packages that aren't yet updated, updated config.sub and config.guess files are installed at share/misc/config.* in the install directory.

Docker Image

We provide a docker image including wasi-sdk that can be used for building projects without a separate installation of the SDK. Autotools, CMake, and Ninja are included in this image, and standard environment variables are set to use wask-sdk for building.

For example, this command can build a make-based project with the Docker image.

docker run -v `pwd`:/src -w /src ghcr.io/webassembly/wasi-sdk make

Take note of the notable limitations below when building projects, for example many projects will need threads support disabled in a configure step before building with wasi-sdk.

Notable Limitations

This repository does not yet support C++ exceptions. C++ code is supported only with -fno-exceptions for now. Similarly, there is not yet support for setjmp/longjmp. Work on support for exception handling is underway at the language level which will support both of these features.

This repository experimentally supports threads with --target=wasm32-wasi-threads. It uses WebAssembly's threads primitives (atomics, wait/notify, shared memory) and wasi-threads for spawning threads. Note: this is experimental โ€” do not expect long-term stability!

This repository does not yet support dynamic libraries. While there are some efforts to design a system for dynamic libraries in wasm, it is still in development and not yet generally usable.

There is no support for networking. It is a goal of WASI to support networking in the future though.

wasi-sdk's People

Contributors

sunfishcode avatar pchickey avatar sbc100 avatar abrown avatar terrorjack avatar lygstate avatar yamt avatar anuraaga avatar dicej avatar tschneidereit avatar acfoltzer avatar alexcrichton avatar gautric avatar glandium avatar vvuk avatar yurydelendik avatar brettcannon avatar caspervonb avatar whitequark avatar jedisct1 avatar kubkon avatar directhex avatar johalun avatar ericson2314 avatar jlb6740 avatar orestisfl avatar lopopolo avatar chicoxyzzy avatar nilslice avatar vnepogodin 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.