Skip to content

holzschu/wasi-sdk

 
 

Repository files navigation

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 the 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".

This fork differs from the original repository; it has been tailored for use with a-Shell. Functions that are part of the standard libc are working as usual. Functions that require interaction with the system (getenv, setenv, getcwd, chdir, mkstemp, system...) are transferred to iOS.

To download, use:

git clone --recurse-submodules https://github.com/holzschu/wasi-sdk.git

To compile, first edit src/llvm-project/clang/CMakeLists.txt and comment lines 296 to 316 (the 20 lines adter set(CUDA_ARCH_FLAGS "sm_35"), then type:

env PREFIX=/opt/ make

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.

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.

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 s underway at the language level which will support both of these features.

This repository does not yet support threads. Specifically, WASI does not yet have an API for creating and managing threads yet, and WASI libc does not yet have pthread support.

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.

About

WASI-enabled WebAssembly C/C++ toolchain

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Shell 31.6%
  • Makefile 31.3%
  • C 30.0%
  • CMake 2.9%
  • Dockerfile 2.1%
  • C++ 2.1%