]> git.proxmox.com Git - wasi-libc.git/log
wasi-libc.git
6 weeks agobump version to 0.0~git20240411.9e8c542-3~bpo12+pve1 proxmox/bookworm
Fabian Grünbichler [Wed, 31 Jul 2024 18:08:45 +0000 (20:08 +0200)]
bump version to 0.0~git20240411.9e8c542-3~bpo12+pve1

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
6 weeks agoMerge branch 'master' into proxmox/bookworm
Fabian Grünbichler [Wed, 31 Jul 2024 18:08:36 +0000 (20:08 +0200)]
Merge branch 'master' into proxmox/bookworm

6 weeks agobump version to 0.0~git20240411.9e8c542-3
Fabian Grünbichler [Wed, 31 Jul 2024 07:21:24 +0000 (09:21 +0200)]
bump version to 0.0~git20240411.9e8c542-3

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
6 weeks agoadapt lintian overrides
Fabian Grünbichler [Wed, 31 Jul 2024 18:01:17 +0000 (20:01 +0200)]
adapt lintian overrides

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2 months agobuild and install p2 snapshot target
Fabian Grünbichler [Thu, 11 Jul 2024 08:06:34 +0000 (10:06 +0200)]
build and install p2 snapshot target

and symlink the existing one under the 'p1' suffix as well, both needed to
build the corresponding targets in rustc.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2 months agobump version to 0.0~git20240411.9e8c542-2
Fabian Grünbichler [Wed, 26 Jun 2024 06:47:43 +0000 (08:47 +0200)]
bump version to 0.0~git20240411.9e8c542-2

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2 months agobump version to 0.0~git20240411.9e8c542-1~bpo12+pve1
Fabian Grünbichler [Tue, 25 Jun 2024 10:16:53 +0000 (12:16 +0200)]
bump version to 0.0~git20240411.9e8c542-1~bpo12+pve1

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2 months agoMerge remote-tracking branch 'origin/master' into proxmox/bookworm
Fabian Grünbichler [Tue, 25 Jun 2024 10:16:44 +0000 (12:16 +0200)]
Merge remote-tracking branch 'origin/master' into proxmox/bookworm

2 months agobump version to 0.0~git20240411.9e8c542-1
Fabian Grünbichler [Mon, 24 Jun 2024 11:43:21 +0000 (13:43 +0200)]
bump version to 0.0~git20240411.9e8c542-1

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2 months agoadapt to changed output dir
Fabian Grünbichler [Mon, 24 Jun 2024 11:55:05 +0000 (13:55 +0200)]
adapt to changed output dir

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2 months agorebase patches
Fabian Grünbichler [Mon, 24 Jun 2024 11:47:12 +0000 (13:47 +0200)]
rebase patches

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2 months agoadd `__wasilibc_reset_preopens` (#489)
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).

Signed-off-by: Joel Dice <joel.dice@fermyon.com>
2 months agoimplement `getsockname`, `getpeername`, and `getaddrinfo` (#488)
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>
2 months agoAdd libsetjmp.a/so (#483)
YAMAMOTO Takashi [Mon, 1 Apr 2024 22:36:28 +0000 (07:36 +0900)]
Add libsetjmp.a/so (#483)

* Add libsetjmp.a/so

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

Discussion:
    https://docs.google.com/document/d/1ZvTPT36K5jjiedF8MCXbEmYjULJjI723aOAks1IdLLg/edit

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

2 months agowasip2 support for `close`, `poll`, `pselect` (#486)
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>
2 months agoadd wasip2 implementations of more socket APIs (#482)
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>
2 months agoimplement basic TCP/UDP server support (#481)
Joel Dice [Wed, 13 Mar 2024 21:50:55 +0000 (15:50 -0600)]
implement basic TCP/UDP server support (#481)

This adds `bind`, `listen`, and `accept` implementations based on
`wasi-sockets` for the `wasm32-wasip2` target.

Signed-off-by: Joel Dice <joel.dice@fermyon.com>
Co-authored-by: Dave Bakker <github@davebakker.io>
2 months agoimplement basic TCP/UDP client support (#477)
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>
2 months agocrt1-command.c: fix whitespace issues (#480)
YAMAMOTO Takashi [Tue, 12 Mar 2024 00:04:46 +0000 (09:04 +0900)]
crt1-command.c: fix whitespace issues (#480)

2 months agoAdd support for pthread_getattr_np (#470)
Milek7 [Mon, 11 Mar 2024 15:48:13 +0000 (16:48 +0100)]
Add support for pthread_getattr_np (#470)

2 months agofix `#ifdef __cplusplus` guard in dirent.h (#479)
韩朴宇 [Fri, 8 Mar 2024 14:08:11 +0000 (22:08 +0800)]
fix `#ifdef __cplusplus` guard in dirent.h (#479)

fix: https://github.com/WebAssembly/wasi-sdk/issues/390

2 months agoStart renaming preview1 to p1 and preview2 to p2 (#478)
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.

* Update builds in CI

* Update test workflow

* Fix test for wasm32-wasip1-threads

* Make github actions rules a bit more readable

2 months agoadd descriptor table for mapping fds to handles (#464)
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>
2 months agoadd preview2_component_type.o to libc.a and libc.so (#472)
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.

Signed-off-by: Joel Dice <joel.dice@fermyon.com>
2 months agoUpdate bindings and dependencies to WASI 0.2.0 (#471)
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>
---------

Signed-off-by: Joel Dice <joel.dice@fermyon.com>
2 months agoadd realpath.c to `LIBC_TOP_HALF_MUSL_SOURCES` (#473)
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>
---------

Signed-off-by: Joel Dice <joel.dice@fermyon.com>
2 months agotest: use the same version of wasmtime and adapter (#468)
YAMAMOTO Takashi [Thu, 1 Feb 2024 19:55:36 +0000 (04:55 +0900)]
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.
```

Also, bump them to 17.

2 months agoadd stubs for `statvfs`, `chmod`, etc. (#463)
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`.

Signed-off-by: Joel Dice <joel.dice@fermyon.com>
2 months agoadd WASI Preview 2 bindings (#460)
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>
---------

Signed-off-by: Joel Dice <joel.dice@fermyon.com>
2 months agoemmalloc: use __heap_end instead of sbrk(0) (#462)
Josh Stone [Wed, 10 Jan 2024 21:31:37 +0000 (13:31 -0800)]
emmalloc: use __heap_end instead of sbrk(0) (#462)

2 months agoCI: include wasi-threads in the sysroot (#458)
YAMAMOTO Takashi [Tue, 2 Jan 2024 23:55:52 +0000 (08:55 +0900)]
CI: include wasi-threads in the sysroot (#458)

2 months agoadd `wasm32-wasi-preview2` target (#457)
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.

See also #447 for further details.

Signed-off-by: Joel Dice <joel.dice@fermyon.com>
2 months agoRemove trailing backtick in README.md (#455)
Daniel Mangum [Mon, 18 Dec 2023 02:06:16 +0000 (20:06 -0600)]
Remove trailing backtick in README.md (#455)

Updates README.md with trailing backtick removed.

2 months agofix libdl.so symbol visibility (#450)
YAMAMOTO Takashi [Fri, 15 Dec 2023 18:07:28 +0000 (03:07 +0900)]
fix libdl.so symbol visibility (#450)

2 months agoAdjust Makefile for LLVM trunk (18) as of 2023-12-07 (#448)
Mike Hommey [Fri, 8 Dec 2023 18:35:18 +0000 (03:35 +0900)]
Adjust Makefile for LLVM trunk (18) as of 2023-12-07 (#448)

https://github.com/llvm/llvm-project/commit/4e80bc7d716b1f2344ffd7ad109413bfe5390879
added __MEMORY_SCOPE_* macros.

2 months agoUpdate Arch Linux package URL in README.md (#446)
Felix Yan [Tue, 21 Nov 2023 15:54:07 +0000 (23:54 +0800)]
Update Arch Linux package URL in README.md (#446)

The old URL returns 404 now.

2 months agoadd stubs for dlopen, dlsym, etc. (#443)
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>
---------

Signed-off-by: Joel Dice <joel.dice@fermyon.com>
2 months agoifdef out pthread_cancel (#445)
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.

2 months agogive a reasonable default of BUILTINS_LIB (#442)
YAMAMOTO Takashi [Wed, 11 Oct 2023 22:42:24 +0000 (07:42 +0900)]
give a reasonable default of BUILTINS_LIB (#442)

2 months agoshlib: specify the sysroot to find the correct crt1 (#441)
YAMAMOTO Takashi [Tue, 10 Oct 2023 15:57:23 +0000 (00:57 +0900)]
shlib: specify the sysroot to find the correct crt1 (#441)

2 months agoremove `-nostdlib` from libc.so link command (#440)
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`.

---------

Signed-off-by: Joel Dice <joel.dice@fermyon.com>
2 months agoAdjust Makefile for LLVM trunk (18) as of 2023-10-03 (#438)
Mike Hommey [Tue, 3 Oct 2023 14:23:29 +0000 (23:23 +0900)]
Adjust Makefile for LLVM trunk (18) as of 2023-10-03 (#438)

https://github.com/llvm/llvm-project/commit/457f582ffe23e951380bc345c4c96ec053c09681
added __FLT128_* macros.

2 months agoadd shared library support (#429)
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"

This reverts commit dbe2cb10541dd27e4e0ed71d30ce304b9c9133d6.

* 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"

This reverts commit c6518223a49f60e4bb254a3e77a411fdade18df2.

* build crt1-*.o with `-fPIC`

This ensures they can be used in a PIE or PIC context.

Signed-off-by: Joel Dice <joel.dice@fermyon.com>
* ignore `__memory_base` when checking undefined symbols

Whether this symbol appears varies between LLVM versions.

Signed-off-by: Joel Dice <joel.dice@fermyon.com>
* Revert "move `__main_void` from __main_void.c to crt1-command.c"

This reverts commit f3038354610b7eb18bfd39092a2ccc3b72842dc4.

* add explanatory comments to __main_void.c

Signed-off-by: Joel Dice <joel.dice@fermyon.com>
* add `__wasilibc_unmodified_upstream` and comment to `__lctrans_cur`

Signed-off-by: Joel Dice <joel.dice@fermyon.com>
---------

Signed-off-by: Joel Dice <joel.dice@fermyon.com>
2 months agoFix typo in signal.c error messages (#437)
Ingvar Stepanyan [Wed, 27 Sep 2023 15:42:02 +0000 (16:42 +0100)]
Fix typo in signal.c error messages (#437)

https://github.com/WebAssembly/wasi-libc/commit/613e154eb20f137f297acc6f54f2ede40de17b0b fixed it in one function but not the other two :)

2 months agoUpdate thread id validation returned by `__wasi_thread_spawn` (#435)
Marcin Kolny [Mon, 18 Sep 2023 18:41:36 +0000 (20:41 +0200)]
Update thread id validation returned by `__wasi_thread_spawn` (#435)

According to the documentation: https://github.com/WebAssembly/wasi-threads#design-choice-thread-ids, TID should be in the range <1, 0x1FFFFFFF>

3 months agobump version to 0.0~git20230821.ec4566b-2
Fabian Grünbichler [Tue, 28 May 2024 15:08:07 +0000 (17:08 +0200)]
bump version to 0.0~git20230821.ec4566b-2

Signed-off-by: Fabian Grünbichler <debian@fabian.gruenbichler.email>
3 months agobump version to 0.0~git20230821.ec4566b-1~bpo12+pve1
Fabian Grünbichler [Tue, 28 May 2024 07:10:28 +0000 (09:10 +0200)]
bump version to 0.0~git20230821.ec4566b-1~bpo12+pve1

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
3 months agoMerge branch 'master' into proxmox/bookworm
Fabian Grünbichler [Tue, 28 May 2024 07:10:12 +0000 (09:10 +0200)]
Merge branch 'master' into proxmox/bookworm

3 months agobump version to 0.0~git20230821.ec4566b-1
Fabian Grünbichler [Mon, 27 May 2024 12:52:42 +0000 (14:52 +0200)]
bump version to 0.0~git20230821.ec4566b-1

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
3 months agoswitch to LLVM 17
Fabian Grünbichler [Mon, 27 May 2024 12:52:01 +0000 (14:52 +0200)]
switch to LLVM 17

like rustc 1.73

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
3 months agoUpdate upstream source from tag 'upstream/0.0_git20230821.ec4566b'
Fabian Grünbichler [Mon, 27 May 2024 12:49:33 +0000 (14:49 +0200)]
Update upstream source from tag 'upstream/0.0_git20230821.ec4566b'

Update to upstream version '0.0~git20230821.ec4566b'
with Debian dir 419720976474c3cfbbaf2fd936969ed3e92d0c62

3 months agoNew upstream version 0.0~git20230821.ec4566b
Fabian Grünbichler [Mon, 27 May 2024 12:49:33 +0000 (14:49 +0200)]
New upstream version 0.0~git20230821.ec4566b

3 months agobump version to 0.0~git20230621.7018e24-2
Fabian Grünbichler [Mon, 27 May 2024 12:49:18 +0000 (14:49 +0200)]
bump version to 0.0~git20230621.7018e24-2

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
3 months agoNew upstream version 0.0~git20230821.ec4566b
Fabian Grünbichler [Mon, 27 May 2024 12:47:45 +0000 (14:47 +0200)]
New upstream version 0.0~git20230821.ec4566b

3 months agobump version to 0.0~git20230621.7018e24-1~bpo12+pve1
Fabian Grünbichler [Fri, 24 May 2024 08:40:06 +0000 (10:40 +0200)]
bump version to 0.0~git20230621.7018e24-1~bpo12+pve1

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
3 months agoMerge branch 'master' into proxmox/bookworm
Fabian Grünbichler [Fri, 24 May 2024 08:38:53 +0000 (10:38 +0200)]
Merge branch 'master' into proxmox/bookworm

3 months agobump version to 0.0~git20230621.7018e24-1
Fabian Grünbichler [Fri, 17 May 2024 10:11:14 +0000 (12:11 +0200)]
bump version to 0.0~git20230621.7018e24-1

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
4 months agorebase patches
Fabian Grünbichler [Fri, 17 May 2024 10:10:15 +0000 (12:10 +0200)]
rebase patches

and drop the one that is no longer needed, since those macros/constants are no
longer defined anyway.

Gbp-Dch: Ignore

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
4 months agoNew upstream version 0.0~git20230621.7018e24
Fabian Grünbichler [Fri, 17 May 2024 10:04:56 +0000 (12:04 +0200)]
New upstream version 0.0~git20230621.7018e24

4 months agoUpdate upstream source from tag 'upstream/0.0_git20230621.7018e24'
Fabian Grünbichler [Fri, 17 May 2024 10:04:56 +0000 (12:04 +0200)]
Update upstream source from tag 'upstream/0.0_git20230621.7018e24'

Update to upstream version '0.0~git20230621.7018e24'
with Debian dir 9b0d9c96eba5ffa7f6fabe1830e7115cacf6a5cb

7 months agobump version to 0.0~git20230113.4362b18-3
Fabian Grünbichler [Thu, 25 Jan 2024 20:48:42 +0000 (21:48 +0100)]
bump version to 0.0~git20230113.4362b18-3

Signed-off-by: Fabian Grünbichler <debian@fabian.gruenbichler.email>
7 months agoswitch to LLVM 16
Fabian Grünbichler [Thu, 25 Jan 2024 20:47:06 +0000 (21:47 +0100)]
switch to LLVM 16

the version currently used by rustc.

Closes: #1061217
Signed-off-by: Fabian Grünbichler <debian@fabian.gruenbichler.email>
12 months agobump version to 0.0~git20230113.4362b18-2
Fabian Grünbichler [Wed, 13 Sep 2023 06:20:01 +0000 (08:20 +0200)]
bump version to 0.0~git20230113.4362b18-2

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
12 months agoRevert "build: enable stack protection"
Fabian Grünbichler [Wed, 13 Sep 2023 06:18:16 +0000 (08:18 +0200)]
Revert "build: enable stack protection"

This reverts commit 6ffd497d926c8e72ac97fb34ffefceb2a05b836c.

Seems like enabling stack protection causes WASM runtimes like wasmedge to
fail, so disable again for now.

12 months agobump version to 0.0~git20230113.4362b18-1
Fabian Grünbichler [Sun, 10 Sep 2023 17:23:51 +0000 (19:23 +0200)]
bump version to 0.0~git20230113.4362b18-1

Signed-off-by: Fabian Grünbichler <debian@fabian.gruenbichler.email>
12 months agobump version to 0.0~git20230113.4362b18-1~exp1
Fabian Grünbichler [Fri, 8 Sep 2023 08:07:02 +0000 (10:07 +0200)]
bump version to 0.0~git20230113.4362b18-1~exp1

Signed-off-by: Fabian Grünbichler <debian@fabian.gruenbichler.email>
12 months agopatches: add DEP-3 metadata
Fabian Grünbichler [Fri, 8 Sep 2023 08:05:58 +0000 (10:05 +0200)]
patches: add DEP-3 metadata

Signed-off-by: Fabian Grünbichler <debian@fabian.gruenbichler.email>
12 months agocleanup lintian overrides
Fabian Grünbichler [Fri, 8 Sep 2023 07:55:56 +0000 (09:55 +0200)]
cleanup lintian overrides

Signed-off-by: Fabian Grünbichler <debian@fabian.gruenbichler.email>
12 months agoupdate d/copyright
Fabian Grünbichler [Fri, 8 Sep 2023 07:55:37 +0000 (09:55 +0200)]
update d/copyright

these files are no longer contained in the upstream sources.

Signed-off-by: Fabian Grünbichler <debian@fabian.gruenbichler.email>
12 months agod/control: update Standards-Version
Fabian Grünbichler [Fri, 8 Sep 2023 07:55:15 +0000 (09:55 +0200)]
d/control: update Standards-Version

Signed-off-by: Fabian Grünbichler <debian@fabian.gruenbichler.email>
12 months agobuild: enable stack protection
Fabian Grünbichler [Fri, 8 Sep 2023 07:38:49 +0000 (09:38 +0200)]
build: enable stack protection

supported now, at least without the control flow part.

Signed-off-by: Fabian Grünbichler <debian@fabian.gruenbichler.email>
12 months agorebase patches
Fabian Grünbichler [Wed, 2 Aug 2023 10:23:41 +0000 (12:23 +0200)]
rebase patches

some dirs got moved/renamed.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
12 months agothreads: change `wasm32-wasi-pthread` to `wasm32-wasi-threads` (#381)
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

12 months agothreads: add `pthread_attr_setdetachstate` (#382)
Andrew Brown [Thu, 12 Jan 2023 03:47:44 +0000 (19:47 -0800)]
threads: add `pthread_attr_setdetachstate` (#382)

This API may not make a lot of sense in a WebAssembly world but it
seemed helpful to include it, even if it doesn't have much effect.

12 months agoRemove hacks for clang 8 (#384)
Mike Hommey [Thu, 12 Jan 2023 02:09:45 +0000 (11:09 +0900)]
Remove hacks for clang 8 (#384)

__FLOAT128__ has been defined since clang 9
__FLT16_* were defined until clang 9

12 months agoAdjust Makefile for LLVM trunk (16) as of 2023-01-05 (#379)
Mike Hommey [Tue, 10 Jan 2023 00:21:58 +0000 (09:21 +0900)]
Adjust Makefile for LLVM trunk (16) as of 2023-01-05 (#379)

https://github.com/llvm/llvm-project/commit/d227c3b68cf5c236902c9ff4fdf8b719c9a3dd26
added __GCC_HAVE_SYNC_COMPARE_AND_SWAP macros.

12 months agoUse __BIGGEST_ALIGNMENT__ instead of max_align_t (#375)
YAMAMOTO Takashi [Mon, 9 Jan 2023 16:33:58 +0000 (01:33 +0900)]
Use __BIGGEST_ALIGNMENT__ instead of max_align_t (#375)

Also, remove no longer necessary __need_STDDEF_H_misc stuff.

References:
https://github.com/WebAssembly/wasi-libc/pull/335
https://github.com/WebAssembly/wasi-sdk/issues/111
https://github.com/llvm/llvm-project/blob/2e999b7dd1934a44d38c3a753460f1e5a217e9a5/clang/lib/Headers/stddef.h#L106-L113

12 months agoDon't use sbrk(0) to determine the initial heap size (#377)
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.

* Use `__heap_end` if defined

* Move mstate initialization earlier

12 months ago__init_tp: Initialize TID to non-zero value (#360)
YAMAMOTO Takashi [Fri, 6 Jan 2023 19:35:27 +0000 (04:35 +0900)]
__init_tp: Initialize TID to non-zero value (#360)

This fixes TID-based locking used within libc.

Also, initialize detach_state.

cf. https://github.com/WebAssembly/wasi-threads/pull/16

12 months agoImplement the critical part of wasi_thread_start in asm (#376)
YAMAMOTO Takashi [Fri, 6 Jan 2023 19:34:22 +0000 (04:34 +0900)]
Implement the critical part of wasi_thread_start in asm (#376)

* Implement the critical part of wasi_thread_start in asm

It's fragile to set up the critical part of C environment in C.

* Specify --target for asm files as well

* wasi_thread_start: Move __tls_base initialization to asm as well

12 months agoEnable pthread_equal function definition (#374)
Shengyun Zhou [Tue, 27 Dec 2022 10:34:03 +0000 (18:34 +0800)]
Enable pthread_equal function definition (#374)

12 months agoUse a separate OBJDIR for each TARGET_TRIPLE (#373)
YAMAMOTO Takashi [Mon, 26 Dec 2022 10:19:11 +0000 (19:19 +0900)]
Use a separate OBJDIR for each TARGET_TRIPLE (#373)

To make it easier to create a sysroot with both triples.

Eg.
```
make -j4 CC=/opt/wasi-sdk-16.0/bin/clang
make -j4 CC=/opt/wasi-sdk-16.0/bin/clang THREAD_MODEL=posix
```

12 months agowasi_thread_start: add a comment (#371)
YAMAMOTO Takashi [Fri, 23 Dec 2022 14:14:21 +0000 (23:14 +0900)]
wasi_thread_start: add a comment (#371)

12 months agoUse `ENOENT` rather than `ENOTCAPABLE` for missing preopens. (#370)
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".

12 months agoDisable pthread_exit for now (#366)
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.

References:
https://github.com/WebAssembly/wasi-threads/issues/7
https://github.com/WebAssembly/wasi-threads/pull/17

12 months agothreads: Retrieve default stack size from __heap_base/__data_end (#350)
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.

12 months agoReduce over-allocation of stack (#365)
YAMAMOTO Takashi [Mon, 19 Dec 2022 12:16:54 +0000 (21:16 +0900)]
Reduce over-allocation of stack (#365)

* Disable stack guard
* Stop rounding up stack size to PAGE_SIZE

12 months agoAdd a separate install target for threaded libc (#331)
Petr Penzin [Wed, 14 Dec 2022 01:57:57 +0000 (17:57 -0800)]
Add a separate install target for threaded libc (#331)

Produce a different sysroot directory for threaded target. Restructure
`expected` directory to correspond to the target.

12 months ago__wait.c: fix a timeout (#361)
YAMAMOTO Takashi [Tue, 13 Dec 2022 20:07:33 +0000 (05:07 +0900)]
__wait.c: fix a timeout (#361)

Note: The typical symptom of this bug is a busy waiting on a lock.

Note: 0 means immediate timeout. a negative value means no timeout.

12 months agoEnable flockfile and friends (#362)
YAMAMOTO Takashi [Tue, 13 Dec 2022 17:56:45 +0000 (02:56 +0900)]
Enable flockfile and friends (#362)

12 months agothreads: enable access to `pthread_barrier_*` functions (#358)
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.

12 months agoEnable pthread_detach (#359)
YAMAMOTO Takashi [Fri, 9 Dec 2022 17:58:46 +0000 (02:58 +0900)]
Enable pthread_detach (#359)

12 months agothreads: enable access to `pthread_attr_get` functions (#357)
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.

12 months agoDon't define `_POSIX_THREADS` unless threads are enabled. (#356)
Dan Gohman [Wed, 7 Dec 2022 21:54:19 +0000 (13:54 -0800)]
Don't define `_POSIX_THREADS` unless threads are enabled. (#356)

* Don't define `_POSIX_THREADS` unless threads are enabled.

Fixes #355.

* Remove `_POSIX_THREADS` from predefined-macros.txt.

12 months agowasi_thread_start: remove a useless cast (#354)
YAMAMOTO Takashi [Wed, 7 Dec 2022 17:31:41 +0000 (02:31 +0900)]
wasi_thread_start: remove a useless cast (#354)

12 months ago__wasi_thread_spawn: stop truncating the return value (#353)
YAMAMOTO Takashi [Wed, 7 Dec 2022 17:18:28 +0000 (02:18 +0900)]
__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.

12 months agoAdjust Makefile for LLVM trunk (16) as of 2022-11-08 (#344)
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.

12 months agobump version to 0.0~git20221206.8b7148f-1
Fabian Grünbichler [Sun, 3 Sep 2023 18:00:02 +0000 (20:00 +0200)]
bump version to 0.0~git20221206.8b7148f-1

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
12 months agoadd myself to Uploaders
Fabian Grünbichler [Sun, 3 Sep 2023 18:16:38 +0000 (20:16 +0200)]
add myself to Uploaders

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
12 months agodisable cf-protection as well
Fabian Grünbichler [Sun, 3 Sep 2023 18:09:21 +0000 (20:09 +0200)]
disable cf-protection as well

it's not supported yet, but is now enabled by default in Debian.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>