]> git.proxmox.com Git - wasi-libc.git/blame_incremental - README.md
New upstream version 0.0~git20221206.8b7148f
[wasi-libc.git] / README.md
... / ...
CommitLineData
1# WASI Libc
2
3WASI Libc is a libc for WebAssembly programs built on top of WASI system calls.
4It provides a wide array of POSIX-compatible C APIs, including support for
5standard I/O, file I/O, filesystem manipulation, memory management, time, string,
6environment variables, program startup, and many other APIs.
7
8WASI Libc is sufficiently stable and usable for many purposes, as most of the
9POSIX-compatible APIs are stable, though it is continuing to evolve to better
10align with wasm and WASI. For example, pthread support is still a work in
11progress.
12
13## Usage
14
15The easiest way to get started with this is to use [wasi-sdk], which includes a
16build of WASI Libc in its sysroot.
17
18## Building from source
19
20To build a WASI sysroot from source, obtain a WebAssembly-supporting C compiler
21(currently this is only clang 10+, though we'd like to support other compilers as well),
22and then run:
23
24```sh
25make CC=/path/to/clang/with/wasm/support \
26 AR=/path/to/llvm-ar \
27 NM=/path/to/llvm-nm
28```
29
30This makes a directory called "sysroot", by default. See the top of the Makefile
31for customization options.
32
33To use the sysroot, use the `--sysroot=` option:
34
35```sh
36/path/to/wasm/supporting/c/compiler --sysroot=/path/to/the/newly/built/sysroot ...
37```
38
39to run the compiler using the newly built sysroot.
40
41Note that Clang packages typically don't include cross-compiled builds of
42compiler-rt, libcxx, or libcxxabi, for `libclang_rt.builtins-wasm32.a`, libc++.a,
43or libc++abi.a, respectively, so they may not be usable without
44extra setup. This is one of the things [wasi-sdk] simplifies, as it includes
45cross-compiled builds of compiler-rt, libc++.a, and libc++abi.a.
46
47## Arch Linux AUR package
48For Arch Linux users, there's an unofficial AUR package tracking this git repo that can be installed under the name [wasi-libc-git].
49
50[wasi-sdk]: https://github.com/WebAssembly/wasi-sdk
51[wasi-libc-git]: https://aur.archlinux.org/packages/wasi-libc-git/