wasi-libc/libc-bottom-half
Dan Gohman 9efc2f4283
Lazy-initialize the environment variables. (#184)
* Lazy-initialize the environment variables.

This is the first in a series of PRs to make it easier to use WASI libc
in Wasm modules that don't have a `main` function. By initializing the
environment on demand, we avoid depending on having `__wasm_call_ctors`
run.

This uses weak symbols strategically to ensure that if `environ` is
used, it is initialized eagerly, but if only `getenv` and friends
are used, the environment is initialized lazily.

Eventually, I expect we'll have a convention for wasm modules without
main functions which will allow the `__wasm_call_ctors` function to be
called automatically, but this helps in simple cases for now.

Fixes #180.

* Add comments explaining the libc-environ-compat.h header usage.
2020-03-19 09:32:41 -07:00
..
cloudlibc Update to musl 1.1.24. 2020-02-26 10:23:05 -08:00
crt Add support for __main_argc_argv. 2020-02-27 13:09:38 -08:00
headers Lazy-initialize the environment variables. (#184) 2020-03-19 09:32:41 -07:00
libpreopen Lazy-initialize the environment variables. (#184) 2020-03-19 09:32:41 -07:00
mman Multi-license wasi-libc under Apache and MIT licenses. (#174) 2020-02-29 10:52:28 +01:00
sources Lazy-initialize the environment variables. (#184) 2020-03-19 09:32:41 -07:00
README.md Update to libpreopen 8835639f27fc42d32096d59d294a0bbb857dc368. 2019-05-09 09:16:56 -07:00

"WASI" the WebAssembly System Interface.

WASI libc is conceptually the lower half of a traditional libc implementation. It provides C interfaces to the low-level WASI syscalls.

This is largely based on CloudABI, cloudlibc, and libpreopen, however we use just the low-level syscall wrappers rather than all of cloudlibc and libpreopen, and we have several customizations for use in a WebAssembly sysroot.

The upstream repositories and versions used here are:

cloudlibc - https://github.com/NuxiNL/cloudlibc 8835639f27fc42d32096d59d294a0bbb857dc368 libpreopen - https://github.com/musec/libpreopen b29e9287cc75a7db7291ce3eb468a3d2bad8ceb1

Whole files which are unused are omitted. Changes to upstream code are wrapped in preprocessor directives controlled by the macro __wasilibc_unmodified_upstream, except that CloudABI names have also been renamed to WASI names without annotations.

WASI libc currently depends on the basics and dlmalloc components of reference-sysroot.