Joel Dice [Thu, 11 Apr 2024 22:27:43 +0000 (16:27 -0600)]
add `__wasilibc_reset_preopens` (#489)
This resets the preopens table to an uninitialized state, forcing it to be
reinitialized next time it is needed. This is useful when pre-initializing
using e.g. `wizer` or `component-init`. Such tools are capable of taking a
snapshot of a running application which may later be resumed on an unrelated
runtime (which may have its own, unrelated preopens).
Joel Dice [Tue, 2 Apr 2024 23:54:41 +0000 (17:54 -0600)]
implement `getsockname`, `getpeername`, and `getaddrinfo` (#488)
This also includes stubs for `gethostbyname`, `gethostbyaddr`, etc. which were
necessary to get CPython to build. I believe it will be possible to implement
them all properly at some point, but don't have the bandwidth at the moment.
Finally, this includes a few fixes for issues I missed in earlier PRs that
surfaced when running the CPython `asyncio` test suite.
Signed-off-by: Joel Dice <joel.dice@fermyon.com> Co-authored-by: Dave Bakker <github@davebakker.io>
Add setjmp/longjump support based on Wasm EH proposal.
It's provided as a separate library (libsetjmp) from libc so that
runtimes w/o EH support can still load libc.so.
To use this setjmp/longjmp implementation, an application should
be compiled with `-mllvm -wasm-enable-sjlj` and linked with `-lsetjmp`.
(You need an LLVM with the change mentioned below.)
Also, you need a runtime with EH support to run such an application.
If you want to use the latest EH instructions, you can use
`binaryen --translate-eh-old-to-new` on your application.
Note: You don't need to translate libsetjmp.a/so to the new EH.
While LLVM currently produces bytecode for an old version of the EH
proposal, luckily for us, the bytecode used in this library (ie. the tag
definition and the "throw" instruction) is compatible with the latest
version of the proposal.
The runtime logic is basically copy-and-paste from:
https://github.com/yamt/garbage/tree/wasm-sjlj-alt2/wasm/longjmp
The corresponding LLVM change:
https://github.com/llvm/llvm-project/pull/84137
(Note: you need this change to build setjmp/longjmp using code.
otoh, you don't need this to build libsetjmp.)
A similar change for emscripten:
https://github.com/emscripten-core/emscripten/pull/21502
An older version of this PR, which doesn't require LLVM changes:
https://github.com/WebAssembly/wasi-libc/pull/467
An example to use the latest EH instructions:
```
clang -mllvm -wasm-enable-sjlj -o your_app.wasm your_app.c -lsetjmp
wasm-opt --translate-eh-old-to-new -o your_app.wasm your_app.wasm
toywasm --wasi your_app.wasm
```
Note: use toywasm built with `-DTOYWASM_ENABLE_WASM_EXCEPTION_HANDLING=ON`.
An example to use the older EH instructions, which LLVM currently produces:
```
clang -mllvm -wasm-enable-sjlj -o your_app.wasm your_app.c -lsetjmp
iwasm your_app.wasm
```
Note: use wasm-micro-runtime built with `-DWAMR_BUILD_EXCE_HANDLING=1`.
Note: as of writing this, only the classic interpreter supports EH.
* Make libsetjmp build optional
* CI: Disable libsetjmp for old LLVM
* libc-top-half/musl/include/setjmp.h: fix a rebase botch
Joel Dice [Wed, 27 Mar 2024 19:24:10 +0000 (13:24 -0600)]
wasip2 support for `close`, `poll`, `pselect` (#486)
This enables `wasm32-wasip2` support for `close`, `poll`, and `pselect`. I
cheated a bit for the latter by re-implementing `pselect` in terms of `poll` to
avoid having to implement wasip2 versions of both.
Signed-off-by: Joel Dice <joel.dice@fermyon.com> Co-authored-by: Dave Bakker <github@davebakker.io>
Joel Dice [Tue, 19 Mar 2024 00:54:07 +0000 (18:54 -0600)]
add wasip2 implementations of more socket APIs (#482)
This adds `wasm32-wasip2` implementations of `shutdown`, `getsockopt`, and
`setsockopt`. It also extends the existing `ioctl` implementation to handle
both p1 and p2 file descriptors since we can't know until runtime which kind we
have. Once we've moved `wasm32-wasip2` fully to WASI 0.2 and remove the need for
the p1 adapter, we'll be able to switch to separate p1 and p2 `ioctl`
implementations.
Signed-off-by: Joel Dice <joel.dice@fermyon.com> Co-authored-by: Dave Bakker <github@davebakker.io>
Joel Dice [Wed, 13 Mar 2024 17:59:27 +0000 (11:59 -0600)]
implement basic TCP/UDP client support (#477)
* implement basic TCP/UDP client support
This implements `socket`, `connect`, `recv`, `send`, etc. in terms of
`wasi-sockets` for the `wasm32-wasip2` target.
I've introduced a new public header file: `__wasi_snapshot.h`, which will define
a preprocessor symbol `__wasilibc_use_wasip2` if using the `wasm32-wasip2`
version of the header, in which case we provide features only available for that
target.
Co-authored-by: Dave Bakker <github@davebakker.io> Signed-off-by: Joel Dice <joel.dice@fermyon.com>
* fix grammar in __wasi_snapshot.h comment
Co-authored-by: Dan Gohman <dev@sunfishcode.online> Signed-off-by: Joel Dice <joel.dice@fermyon.com>
---------
Signed-off-by: Joel Dice <joel.dice@fermyon.com> Co-authored-by: Dave Bakker <github@davebakker.io> Co-authored-by: Dan Gohman <dev@sunfishcode.online>
Alex Crichton [Mon, 4 Mar 2024 23:57:34 +0000 (17:57 -0600)]
Start renaming preview1 to p1 and preview2 to p2 (#478)
* Start renaming preview1 to p1 and preview2 to p2
This is an initial start at renaming the "preview" terminology in WASI
targets to "pX". For example the `wasm32-wasi` target should transition
to `wasm32-wasip1`, `wasm32-wasi-preview2` should transition to
`wasm32-wasip2`, and `wasm32-wasi-threads` should transition to
`wasm32-wasip1-threads`. This commit applies a few renames in the
`Makefile` such as:
* `WASI_SNAPSHOT` is now either "p1" or "p2"
* The default p2 target triple is now `wasm32-wasip2` instead of
`wasm32-wasi-preview2` (in the hopes that it's early enough to change
the default).
* Bindings for WASIp2 were renamed from "preview2" terminology to "wasip2".
* The expected-defines files are renamed and the logic of which
expectation was used has been updated slightly.
With this commit the intention is that non-preview2 defaults do not
change. For example the default build still produces a `wasm32-wasi`
sysroot. If `TARGET_TRIPLE=wasm32-wasip1` is passed, however, then that
sysroot is produced instead. Similarly a `THREAD_MODEL=posix` build
produces a `wasm32-wasi-threads` sysroot target but you can now also
pass `TARGET_TRIPLE=wasm32-wasip1-threads` to rename the sysroot.
My hope is to integrate this into the wasi-sdk repository and build a
dual sysroot for these new targets for a release or two so both are
supported and then in the future the defaults can be switched away from
`wasm32-wasi` to `wasm32-wasip1` as built-by-default.
Joel Dice [Tue, 27 Feb 2024 20:57:54 +0000 (13:57 -0700)]
add descriptor table for mapping fds to handles (#464)
* add descriptor table for mapping fds to handles
This introduces `descriptor_table.h` and `descriptor_table.c`, providing a
global hashtable for tracking `wasi-libc`-managed file descriptors.
WASI Preview 2 has no notion of file descriptors and instead uses unforgeable
resource handles. Moreover, there's not necessarily a one-to-one correspondence
between POSIX file descriptors and resource handles (e.g. a TCP connection may
require separate handles for reading, writing, and polling the same connection).
We use this table to map each POSIX descriptor to a set of one or more handles
and any extra state which libc needs to track.
Note that we've added `descriptor_table.h` to the
libc-bottom-half/headers/public/wasi directory, making it part of the public
API. The intention is to give applications access to the mapping, enabling them
to convert descriptors to handles and vice-versa should they need to
interoperate with both libc and WASI directly.
Co-authored-by: Dave Bakker <github@davebakker.io> Signed-off-by: Joel Dice <joel.dice@fermyon.com>
* add dummy fields to otherwise empty structs
The C standard doesn't allow empty structs. Clang doesn't currently complain,
but we might as well stick to the spec in case it becomes more strict in the
future.
Signed-off-by: Joel Dice <joel.dice@fermyon.com>
* move descriptor_table.h to headers/private
We're not yet ready to commit to making this API public, so we'll make it
private for now.
I've also expanded a comment in descriptor_table.c to explain the current ABI
for resource handles.
Signed-off-by: Joel Dice <joel.dice@fermyon.com>
* re-run clang-format to fix indentation
Signed-off-by: Joel Dice <joel.dice@fermyon.com>
---------
Signed-off-by: Joel Dice <joel.dice@fermyon.com> Co-authored-by: Dave Bakker <github@davebakker.io>
Joel Dice [Thu, 22 Feb 2024 22:09:50 +0000 (15:09 -0700)]
add preview2_component_type.o to libc.a and libc.so (#472)
This file adds a custom section to each core module linked with wasi-libc. That
custom section contains component type information needed by e.g. `wasm-tools
component new` to generate a component from the module. It will be required
once we start using any part of WASI 0.2.0 directly (vs. via a Preview 1
adapter). In addition, it allows developers to `#include <wasi/preview2.h>` in
their code and make use of those APIs directly even if wasi-libc is not using
them yet.
Joel Dice [Thu, 22 Feb 2024 01:57:58 +0000 (18:57 -0700)]
Update bindings and dependencies to WASI 0.2.0 (#471)
* make the Makefiles a bit more robust
- Escape "." character in `sed` regex
- Ensure that %.wasm target fails cleanly (i.e. without generating the target file) if `wasm-tools` fails
Signed-off-by: Joel Dice <joel.dice@fermyon.com>
* split `component new` rule out of link rule for Preview 2
We now explicitly distinquish between core module files (%.core.wasm) and
component files (%.wasm), which helps avoid the trickery in my previous commit.
In order to test this properly, I needed to update the Wasmtime URL to point to
v17.0.0 instead of dev (which we needed to do anyway), and that in turn required
updating the bindings to use the final WASI 0.2.0 release.
Signed-off-by: Joel Dice <joel.dice@fermyon.com>
---------
Joel Dice [Tue, 13 Feb 2024 17:54:59 +0000 (10:54 -0700)]
add realpath.c to `LIBC_TOP_HALF_MUSL_SOURCES` (#473)
* provide a `realpath` stub
In https://github.com/WebAssembly/wasi-libc/pull/463, I added stubs for
`statvfs`, `chmod`, etc. but forgot to add one for `realpath`, which is also
required by `libc++`'s `<filesystem>` implementation.
Signed-off-by: Joel Dice <joel.dice@fermyon.com>
* remove `realpath` stub and use musl's version instead
Signed-off-by: Joel Dice <joel.dice@fermyon.com>
---------
test: use the same version of wasmtime and adapter (#468)
To avoid errors like:
```
Caused by:
0: import `wasi:cli/environment@0.2.0-rc-2023-12-05` has the wrong type
1: instance export `get-arguments` has the wrong type
2: expected func found nothing
make: *** [Makefile:185: /home/runner/work/wasi-libc/wasi-libc/test/build/functional/argv.wasm.err] Error 1
Error: Process completed with exit code 2.
```
Joel Dice [Thu, 11 Jan 2024 20:16:59 +0000 (13:16 -0700)]
add stubs for `statvfs`, `chmod`, etc. (#463)
Per https://github.com/WebAssembly/wasi-sdk/issues/373, LLVM's libc++ no longer
allows us to enable `<fstream>` and `<filesystem>` separately -- it's both or
neither. Consequently, we either need to patch libc++ to not use `statvfs`,
`chmod`, etc. or add stub functions for those features to `wasi-libc`. Since
we're planning to eventually support those features with WASI Preview 2 and
beyond, it makes sense to do the latter.
Note that since libc++ uses `DT_SOCK`, I've added a definition for it -- even
though WASI Preview 1 does not define it. No Preview 1 file will ever have that
type, so code that handles that type will never be reached, but defining it
allows us to avoid WASI-specific patches to libc++.
Related to `DT_SOCK`, I had to change the `S_IFIFO` value so it does not
conflict with `S_IFSOCK`, thereby avoiding ambiguity in `__wasilibc_iftodt`.
Joel Dice [Thu, 11 Jan 2024 19:53:15 +0000 (12:53 -0700)]
add WASI Preview 2 bindings (#460)
* add WASI Preview 2 bindings
This adds C bindings generated from the `wasi:cli/imports@0.2.0-rc-2023-12-05`
world, plus a makefile target to regenerate them from the WIT source files.
We'll use these bindings to call Preview 2 host functions when building for the
`wasm32-wasi-preview2` target.
Signed-off-by: Joel Dice <joel.dice@fermyon.com>
* update to pre-release of `wit-bindgen` 0.17.0
This includes https://github.com/bytecodealliance/wit-bindgen/pull/804 (fix
broken indentation in generated code) and
https://github.com/bytecodealliance/wit-bindgen/pull/805 (support overriding
world name and adding a suffix to the component type custom section).
Signed-off-by: Joel Dice <joel.dice@fermyon.com>
* test all targets; update preview2 expected output files
Signed-off-by: Joel Dice <joel.dice@fermyon.com>
* build for `wasm32-wasi-threads` before testing it
Signed-off-by: Joel Dice <joel.dice@fermyon.com>
* move generated bindings per review feedback
Since these files aren't part of cloudlibc, no reason to put them under the
cloudlibc directory.
Signed-off-by: Joel Dice <joel.dice@fermyon.com>
* move preview2.h to wasi directory
Signed-off-by: Joel Dice <joel.dice@fermyon.com>
---------
Joel Dice [Fri, 22 Dec 2023 22:03:07 +0000 (15:03 -0700)]
add `wasm32-wasi-preview2` target (#457)
Currently, this is identical to the `wasm32-wasi` in all but name. See #449 for
the next step, which is to incrementally add Preview 2 features,
e.g. `wasi-sockets`. Per the discussion in that PR, I've split the
`wasi-sysroot/include` directory into per-target directories. Eventually, we'll
want to build a separate sysroot for each target, but there's currently
uncertainty about how to configure the default sysroot for e.g. clang, so we're
not tackling that yet.
Joel Dice [Wed, 15 Nov 2023 00:34:57 +0000 (17:34 -0700)]
add stubs for dlopen, dlsym, etc. (#443)
* add stubs for dlopen, dlsym, etc.
This adds weak exports for the POSIX `dlopen`, `dlsym`, `dlclose`, and `dlerror`
functions, allowing code which uses those features to compile. The
implementations are stubs which always fail since there is currently no official
standard for runtime dynamic linking.
Since the symbols are weak, they can be overriden with useful, runtime-specific
implementations, e.g. based on host functions or statically-generated tables
(see https://github.com/dicej/component-linking-demo for an example of the
latter).
Signed-off-by: Joel Dice <joel.dice@fermyon.com>
* move `dlopen` stubs out of libc and into libdl
Per review feedback, it's easier to simply replace libdl.so with a working
implementation at runtime than it is to override a handful of symbols in libc.
Note that I've both added libdl.so and replaced the empty libdl.a we were
previously creating with one that contains the stubs. I'm thinking we might as
well be consistent about what symbols the .so and the .a contain. Otherwise,
e.g. the CPython build gets confused when the dlfcn.h says `dlopen` etc. exist
but libdl.a is empty.
Signed-off-by: Joel Dice <joel.dice@fermyon.com>
* customize dlfcn.h for WASI
For WASI, we use flag values which match MacOS rather than musl. This gives
`RTLD_LOCAL` a non-zero value, avoiding ambiguity and allowing us to defer the
decision of whether `RTLD_LOCAL` or `RTLD_GLOBAL` should be the default when
neither is specified.
We also avoid declaring `dladdr`, `dlinfo`, and friends on WASI since they are
neither supported nor stubbed at this time.
Signed-off-by: Joel Dice <joel.dice@fermyon.com>
* use musl's RTLD_* flags except for RTLD_LOCAL
This minimizes the divergence from upstream while still giving us the
flexibility to choose a default value later.
Signed-off-by: Joel Dice <joel.dice@fermyon.com>
* use `NULL` instead of `0` for null pointers
Signed-off-by: Joel Dice <joel.dice@fermyon.com>
---------
YAMAMOTO Takashi [Wed, 15 Nov 2023 00:22:28 +0000 (09:22 +0900)]
ifdef out pthread_cancel (#445)
as we don't actually support thread cancellation.
note: currently we don't build pthread_cancel.c either. this commit
just disables it in our header too to make users notice that it isn't
provided a bit earlier.
should we disable other cancellation related functions like
pthread_testcancel? maybe. but they are harmless to ignore.
Joel Dice [Sat, 7 Oct 2023 00:10:58 +0000 (18:10 -0600)]
remove `-nostdlib` from libc.so link command (#440)
Per https://reviews.llvm.org/D156205 (which we're planning to backport to LLVM
17 and pull into `wasi-sdk`), we want to link crt1-reactor.o into libc.so so it
exports `_initialize` instead of `__wasm_call_ctors`.
* add `-nodefaultlibs` to libc.so link command
This ensures that `-lc` is not passed to `wasm-ld`.
Joel Dice [Thu, 28 Sep 2023 13:11:09 +0000 (07:11 -0600)]
add shared library support (#429)
* add shared library support
This adds support for building WASI shared libraries per
https://github.com/WebAssembly/tool-conventions/blob/main/DynamicLinking.md.
For the time being, the goal is to allow "pseudo-dynamic" linking using the
Component Model per
https://github.com/WebAssembly/component-model/blob/main/design/mvp/examples/SharedEverythingDynamicLinking.md.
This requires all libraries to be available when the component is created, but
still allows runtime symbol resolution via `dlopen`/`dlsym` backed by a static
lookup table. This is sufficient to support Python native extensions, for
example. A complete demo using `wit-component` is available at
https://github.com/dicej/component-linking-demo.
This commit adds support for building `libc.so`, `libc++.so`, and `libc++abi.so`
alongside their static counterparts.
Notes:
- I had to refactor `errno` support a bit to avoid a spurious `_ZTH5errno` (AKA "thread-local initialization routine for errno") import in `libc++.so`.
- Long double print and scan are included by default in `libc.so` rather than in a separate library.
- `__main_argc_argv` is now a weak symbol since it's not relevant for reactors.
- `dlopen`/`dlsym` rely on a lookup table provided by the "dynamic" linker via `__wasm_set_libraries`. Not all flags are supported yet, and unrecognized flags will result in an error.
- This requires https://reviews.llvm.org/D153293, which we will need to backport to LLVM 16 until 17 is released. I'll open a `wasi-sdk` PR with that change and various Makefile tweaks to support shared libraries.
- `libc.so` is temporarily disabled for the `wasi-threads` build until someone can make `wasi_thread_start.s` position-independent.
Signed-off-by: Joel Dice <joel.dice@fermyon.com>
build `-fPIC` .o files separately from non-`-fPIC` ones
This allows us to build both libc.so and libc.a without incurring indirection
penalties in the latter.
Signed-off-by: Joel Dice <joel.dice@fermyon.com>
only build libc.so when explicitly requested
Shared library support in LLVM for non-Emscripten Wasm targets will be added in
version 17, which has not yet been released, so we should not attempt to build
libc.so by default (at least not yet).
Signed-off-by: Joel Dice <joel.dice@fermyon.com>
remove dl.c
I'll open a separate PR for this later.
Signed-off-by: Joel Dice <joel.dice@fermyon.com>
update `check-symbols` files
Signed-off-by: Joel Dice <joel.dice@fermyon.com>
* generate separate .so files for emulated features
Signed-off-by: Joel Dice <joel.dice@fermyon.com>
* revert errno changes in favor of a smaller change
@yamt pointed out there's an easier way to address the `_ZTH5errno` issue I
described in an earlier commit: use `_Thread_local` for both C and C++. This
gives us a simpler ABI and avoids needing to import a thread-local initializer
for `errno` in libc++.so.
Signed-off-by: Joel Dice <joel.dice@fermyon.com>
* remove redundant `$(OBJDIR)/%.long-double.pic.o` rule in Makefile
Signed-off-by: Joel Dice <joel.dice@fermyon.com>
* consolidate libwasi-emulated-*.so into a single library
Signed-off-by: Joel Dice <joel.dice@fermyon.com>
* add comment explaining use of `--whole-archive`
Signed-off-by: Joel Dice <joel.dice@fermyon.com>
* Revert "remove redundant `$(OBJDIR)/%.long-double.pic.o` rule in Makefile"
* move `__main_void` from __main_void.c to crt1-command.c
This and `__main_argc_argv` are only relevant for commands (not reactors), so it
makes sense to scope them accordingly. In addition, the latter was being
imported from libc.so, forcing applications to provide it even if it wasn't
relevant.
Signed-off-by: Joel Dice <joel.dice@fermyon.com>
* Revert "consolidate libwasi-emulated-*.so into a single library"
Andrew Brown [Fri, 13 Jan 2023 02:56:52 +0000 (18:56 -0800)]
threads: change `wasm32-wasi-pthread` to `wasm32-wasi-threads` (#381)
* Change `wasm32-wasi-pthread` to `wasm32-wasi-threads`
After some thought, I think that we should rename the `THREAD_MODEL=posix` build to avoid confusion. Why? Though in this project the use of this target does involve pthreads, it will not be so in other standard libraries or languages (see, e.g., https://github.com/rust-lang/compiler-team/issues/574). I think it would be preferable to emphasize the "threads" Wasm-level proposal and the "wasi-threads" proposal rather than the specific details of which threading API is being exposed.
* fix: rename the `expected` output directory as well
Alex Crichton [Mon, 9 Jan 2023 16:33:05 +0000 (10:33 -0600)]
Don't use sbrk(0) to determine the initial heap size (#377)
* Don't use sbrk(0) to determine the initial heap size
This commit changes the `try_init_allocator` function as part of
dlmalloc to not use `sbrk(0)` to determine the initial heap size. The
purpose of this function is to use the extra memory at the end of linear
memory for the initial allocation heap before `memory.grow` is used to
allocate more memory. To learn the extent of this region the code
previously would use `sbrk(0)` to find the current size of linear
memory. This does not work, however, when other systems have called
`memory.grow` before this function is called. For example if another
allocator is used or if another component of a wasm binary grows memory
for its own purposes then that memory will be incorrectly claimed to be
owned by dlmalloc.
Instead this commit rounds up the `__heap_base` address to the nearest
page size, since that must be allocatable. Otherwise anything above this
rounded address is assumed to be used by something else, even if it's
addressable.
Dan Gohman [Wed, 21 Dec 2022 23:47:53 +0000 (15:47 -0800)]
Use `ENOENT` rather than `ENOTCAPABLE` for missing preopens. (#370)
When a user calls `open` with a path that does not have a corresponding
preopen, set errno to `ENOENT` rather than `ENOTCAPABLE`. This
conceptually represents an attempt to open a path which has not been
provided within the sandbox, so it's more accurately represented as
"not present" rather than "insufficient capabilities".
YAMAMOTO Takashi [Wed, 21 Dec 2022 01:24:09 +0000 (10:24 +0900)]
Disable pthread_exit for now (#366)
The current wasi-threads has no thread-exit functionality.
Thus it isn't straightforward to implement pthread_exit
without leaking thread context. This commit simply disables
pthread_exit for now.
Also, instead of abusing `wasi_proc_exit` for thread exit,
make `wasi_thread_start` return.
Note: `wasi_proc_exit` is supposed to terminate all threads
in the "process", not only the calling thread.
Note: Depending on the conclusion of the discussion about
`wasi_thread_exit`, we might revisit this change later.
Marcin Kolny [Mon, 19 Dec 2022 12:18:19 +0000 (12:18 +0000)]
threads: Retrieve default stack size from __heap_base/__data_end (#350)
When compiling with `-z stack-size` flag, only the main thread's stack
size is set to the specified value and other threads use musl's default value.
That's inconsistent with LLD's `-Wl,-stack_size`.
I think we can make it similar to MUSL's behavior, where thread's stack
size can be set via `PT_GNU_STACK` program header (via `-Wl,-z,stack-size`
flag).
Configuring stack size through `pthread_attr_t` still work as expected and
overrides the defaults ([pthread_create.c](https://github.com/WebAssembly/wasi-libc/blob/be1ffd6a9eba1704085987482557c2a32724227f/libc-top-half/musl/src/thread/pthread_create.c#L362))
default settings.
Andrew Brown [Tue, 13 Dec 2022 17:19:32 +0000 (09:19 -0800)]
threads: enable access to `pthread_barrier_*` functions (#358)
In building some `libc-test` tests, I found these functions were not
compiled in. This change adds `pthread_barrier_init`,
`pthread_barrier_wait`, and `pthread_barrier_destroy` to the
`THREAD_MODEL=posix` build. As has been done with previous pthreads PRs,
this PR skips any inter-process locking by removing any calls to
`__vm_lock` and friends. If in the future WASI gains the "process"
concept, then these locations (and the pre-existing ones) will need to
be modified.
Andrew Brown [Thu, 8 Dec 2022 22:55:42 +0000 (14:55 -0800)]
threads: enable access to `pthread_attr_get` functions (#357)
The pthreads API exposes functions for querying the attributes of a
thread. This change allows these functions to be compiled in the
`THREAD_MODEL=posix` build. Some functions are skipped (and documented);
they can be added if/when needed. This change is motivated by a
`libc-test` test that uses these functions.
__wasi_thread_spawn: stop truncating the return value (#353)
as __wasi_errno_t is uint16_t, with the current coding,
__pthread_create will never see negative return values from
wasi:thread_spawn.
eg. (int)(uint16_t)-1 == 65535.
Mike Hommey [Wed, 7 Dec 2022 16:27:06 +0000 (01:27 +0900)]
Adjust Makefile for LLVM trunk (16) as of 2022-11-08 (#344)
https://github.com/llvm/llvm-project/commit/1e4e2433bcd1a0296ef1043c462252f0d087d90c
enabled sign-ext and mutable-globals by default, which adds
corresponding __wasm_-prefixed #defines.
https://github.com/llvm/llvm-project/commit/9e956995db1fc7e792e3dfb3a465a52626195557
changed the definition of __GNUC_VA_LIST to match that of GCC headers,
leaving it without a value.