* Fixes for the THREAD_MODEL=posix build
* Fix expected symbols from previous commit
* Enable `lock` in `random.c` when threads are enabled
This uses the `_REENTRANT` definition to indicate when the `lock` should
be available.
* Disable `aio.h` when compiling for threads
In talking to @sunfishcode about `aio.h`, this functionality is not yet
a primary concern (it was already disabled in the default,
single-threaded mode). Additionally, this change adds expectation lines
for the new symbols/includes added and removed by `pthread.h`.
This change was reached by running:
```console
$ git diff --no-index expected/wasm32-wasi sysroot/share/wasm32-wasi > patch.diff
# replace "sysroot/share" with "expected" in `patch.diff`
$ git apply patch.diff --reject
# manually fix any rejections
```
* Specify the TLS model until LLVM 15 is released
The `-ftls-model` configuration can be removed once https://reviews.llvm.org/D130053 makes its way into an upstream release.
* Rename `__wasi_libc_pthread_self` to `__wasilibc_pthread_self`
The symbol is still undefined, though.
* Add different sets of expected output based on THREAD_MODEL
* Re-add trailing whitespace to `predefined-macros.txt`
@sbc100 wanted to retain the whitespace trailing after certain
predefined macro lines. This change restores that whitespace from
upstream and re-generates the POSIX version using the following command:
```console
$ git diff --no-index expected/wasm32-wasi/posix/predefined-macros.txt sysroot/share/wasm32-wasi/predefined-macros.txt | sed 's/sysroot\/share\/wasm32-wasi/expected\/wasm32-wasi\/posix/' | git apply
```
* Protect `preopens.c` against concurrent access
* Only build thread-capable wasi-libc on latest version of Clang
* Use `thrd_sleep` from MUSL instead of aliasing `nanosleep`
* Define `pthread_setcancelstate` in `THREAD_MODEL=posix` builds
There are other options here (e.g., always define the `pthread_*`
symbols with stubs) but until we discuss that this is an intermediate
working step.
* Define a Wasm global to store `pthread_self`
* Remove `g_needs_dynamic_alloc` global
* Document the state of pthread support
* review: de-duplicate symbols based on #314
* review: only define `__wasilibc_cwd_{un}lock` when needed
* review: add #ifdefs to `__pthread_setcancelstate`
* review: add additional #ifdefs to `pthread_self.c`
* review: put lock definition behind #ifdef _REENTRANT
* review: remove pthread_setcancelstate.c
* review: re-fix indentation
* review: alias __clock_nanosleep in bottom half
* review: remove extra line
Co-authored-by: Sam Clegg <sbc@chromium.org>
Update the description, point users to wasi-sdk as a simpler place to
get started using this library, and remove old text about being a
"reference" implementation.
This populates the repo with a very minimal set of files. This is just
enough to set out a basic outline. Hopefully as we move forward we'll
be replacing many of these parts, but this is just something basic to
get things started.
This tree isn't really usable yet, as it doesn't yet have an easy way
to obtain a compiler-rt/libgcc build.