]> git.proxmox.com Git - wasi-libc.git/blame - README.md
Fix typo
[wasi-libc.git] / README.md
CommitLineData
94d34a13 1# WASI Libc
dcf13b6f 2
c33ea73e
DG
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.
dcf13b6f 7
c33ea73e
DG
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.
dcf13b6f
DG
11
12## Usage
13
c33ea73e
DG
14The easiest way to get started with this is to use [wasi-sdk], which includes a
15build of WASI Libc in its sysroot.
320054e8
DG
16
17## Building from source
18
19To build a WASI sysroot from source, obtain a WebAssembly-supporting C compiler
7a21011e 20(currently this is only clang 10+, though we'd like to support other compilers as well),
320054e8 21and then run:
dcf13b6f 22
b1e234b6 23```sh
9e09e02a 24make CC=/path/to/clang/with/wasm/support \
9eb4a995 25 AR=/path/to/llvm-ar \
a279514a 26 NM=/path/to/llvm-nm
dcf13b6f
DG
27```
28
c9850bfd 29This makes a directory called "sysroot", by default. See the top of the Makefile
dcf13b6f
DG
30for customization options.
31
32To use the sysroot, use the `--sysroot=` option:
33
b1e234b6 34```sh
dcf13b6f 35/path/to/wasm/supporting/c/compiler --sysroot=/path/to/the/newly/built/sysroot ...
f2049d9b 36```
dcf13b6f
DG
37
38to run the compiler using the newly built sysroot.
c33ea73e
DG
39
40Note that Clang packages typically don't include cross-compiled builds of
42e6901e
DG
41compiler-rt, libcxx, or libcxxabi, for `libclang_rt.builtins-wasm32.a`, libc++.a,
42or libc++abi.a, respectively, so they may not be usable without
c33ea73e 43extra setup. This is one of the things [wasi-sdk] simplifies, as it includes
42e6901e 44cross-compiled builds of compiler-rt, libc++.a, and libc++abi.a.
c33ea73e 45
ca4d2f0c
ZL
46## Arch Linux AUR package
47For Arch Linux users, there's an unofficial AUR package tracking this git repo that can be installed under the name [wasi-libc-git].
b6390079 48
c33ea73e 49[wasi-sdk]: https://github.com/WebAssembly/wasi-sdk
b6390079 50[wasi-libc-git]: https://aur.archlinux.org/packages/wasi-libc-git/