Commit Graph

358 Commits

Author SHA1 Message Date
Dan Gohman
30094b6ed0 Fix gettimeofday to correctly handle a null argument.
`gettimeofday` is defined to do nothing if passed NULL.
2022-06-01 11:05:04 -07:00
Dan Gohman
d8d00bcd5a
Remove support for __original_main. (#295)
* Remove support for `__original_main`.

This was used in old LLVM versions. Recent LLVM versions all emit either
`__main_void` or `__main_argv_argc`, so we can use those directly.

* Update the CI to use LLVM 14.0.0.
2022-06-01 08:51:20 -07:00
Dan Gohman
5d8a1409aa
Update to musl 1.2.3.
* Update to musl 1.2.3.

See the WHATSNEW file for details.
2022-05-24 19:31:23 -07:00
Dan Gohman
225b285a61 Fix utimensat to avoid passing uninitialized values into WASI calls.
Previously, utimensat would leave the mtim and/or atim timestamps
uninitialized when the `MTIM_NOW` or `ATIM_NOW` were in use, because
that means the respective timestamps are not used.

However, clang now automatically adds `noundef` to the arguments in
functions like `__wasi_path_filestat_set_times`, and there are cases
where simplifycfg can see paths where the uninitialized values are
passed to those `noundef` arguments.

To fix this, change the utimens code to zero out the timestamps when
they aren't in use, to avoid passing uninitialized arguments.
2022-05-24 15:17:44 -07:00
Cheng Shao
ba81b409b0 Implement BULK_MEMORY_THRESHOLD 2022-05-20 13:39:43 -07:00
Cheng Shao
5d0a7558d6 Add TODO pointing to LLVM bug report 2022-05-20 13:39:43 -07:00
Cheng Shao
d3cc92a69e Only apply -mbulk-memory to specific files 2022-05-20 13:39:43 -07:00
Cheng Shao
3b3bde080e Don't use __builtin version of wmem* 2022-05-20 13:39:43 -07:00
Cheng Shao
75fdabe1ff Use bulk memory opcodes when possible 2022-05-20 13:39:43 -07:00
Cheng Shao
1b593725c6 Fix test artifacts 2022-05-20 13:39:43 -07:00
Cheng Shao
c9d6f1b231 -mbulk-memory go brrr 2022-05-20 13:39:43 -07:00
Dan Gohman
9886d3d620 Fix find_relpath to handle large buffers correctly.
As a follow-up to #247, fix `find_relpath` to handle large buffers
correctly.

Co-Authored-by: Yuta Saito <kateinoigakukun@gmail.com>
2022-05-09 18:54:07 -07:00
Dan Gohman
b1196b49f3 Exclude C++ headers from the generated include-all.c program.
The order that things happen in appears to have changed, and the
include-all.c script is now generated at a time when there can be
C++ headers in the sysroot, so adjust the script to exclude C++
headers.
2022-05-05 18:52:14 -07:00
Mike Hommey
202034fd60 Override Make's default for CC and AR. 2022-05-05 16:33:00 -07:00
Harald Hoyer
63e4489d01 feat: add support for accept and accept4
Since the socket address of the accepted socket is unknown,
all bytes are set to zero and the length is truncated to the size
of the generic `struct sockaddr`.

Signed-off-by: Harald Hoyer <harald@profian.com>
2022-05-05 15:12:26 -07:00
Mike Hommey
e9fcbdead8 Adjust the Makefile for LLVM 15 as of 2022-04-20 2022-05-04 14:41:10 -07:00
Roman Volosatovs
7302f33f99 build: update WASI and partially regenerate api.h 2022-04-20 13:39:57 -07:00
Dan Gohman
05cd0af0af Add implementation file. 2022-04-13 13:33:44 -07:00
Dan Gohman
9c58e6c23f Define DTTOIF and IFTODT.
Fixes #268.
2022-04-13 13:33:44 -07:00
Mike Hommey
df006e1202 Adjust the Makefile for LLVM 14 2022-04-13 13:02:21 -07:00
John Ericson
a279514a6e WASM_NM -> NM to use standardized env var
Progress towards #269
2022-04-12 11:17:20 -07:00
John Ericson
9eb4a995ea WASM_AR -> AR to use standardized env var
Progress towards #269
2022-04-12 11:17:20 -07:00
John Ericson
8852e15a34 WASM_CFLAGS -> EXTRA_CFLAGS
Progress towards #269
2022-04-12 11:17:20 -07:00
John Ericson
9e09e02a8f WASM_CC -> CC to use standardized env var
Progress towards #269
2022-04-12 11:17:20 -07:00
John Ericson
18f9e0aa9c Pull out {UN,}DEFINED_SYMBOLS as make vars
If the Apple bug is in make and not bash, maybe this will help.
2022-04-12 11:17:20 -07:00
John Ericson
61786461ed Do more explicit env vars for CI
This gets ready for switching to the standard vars, which sadly were
already mis-initialized in this environment so we have to be extra
careful to override them.
2022-04-12 11:17:20 -07:00
Dan Gohman
3eb02a798b Fix futimens error handling.
Fix a bug introduced in #242 noticed [here]: if `tv_usec` is out of
range, then properly return an error code.

[here]: 079adff840 (r69631767)
2022-03-28 14:59:37 -07:00
Dan Gohman
ae47c68b1d Update the comment at the top of wasi/api.h. 2022-03-28 14:58:07 -07:00
Dan Gohman
2f24a36eea Disable the headerstest test. 2022-03-28 14:58:07 -07:00
Dan Gohman
69af7276a7 Remove the signal constants and proc_raise function.
The WASI signal constants and proc_raise function were removed in the
latest [ephemeral], which had been scheduled to be in the next snapshot,
however WASI itself is now transitioning away from the snapshot system.

WASI libc will also be transitioning to updated wit specs once they're
ready, however until that time, we can make the simple change of
removing these signal constants to avoid confusion.

Fixes #271.
Fixes #272.

[ephemeral]: https://github.com/WebAssembly/WASI/tree/main/phases/ephemeral/witx
2022-03-28 14:58:07 -07:00
John Ericson
4cb4b26f8d Simplify a header check by using the SYSROOT_* variables 2022-03-23 10:51:26 -07:00
John Ericson
111c872930
Add make clean rule, don't have include_dirs nuke other things (#277)
I think this separation of concerns is good, though I don't need it for
Nixpkgs.
2022-03-22 17:25:54 -07:00
John Ericson
fc260f1a48 Use -isystem instead of --sysroot for the installed headers
This is less of a sledgehammer, and prepares the way for #270.
2022-03-21 16:24:46 -07:00
Dan Gohman
079adff840 Enable support for utimes and futimesat.
These can both be implemented in terms of `utimensat`.
2022-03-10 14:14:40 -08:00
Gerd Stolpmann
809e2d36b5 more graphical code 2022-03-10 13:51:09 -08:00
Gerd Stolpmann
0c65fc5e2e chdir: fixing a malloc'ed buffer that was not large enough
(mem corruption)
2022-03-10 13:51:09 -08:00
Mike Hommey
ad5133410f Adjust the Makefile for LLVM 13 2021-09-22 15:36:47 -07:00
Vitali Lovich
90a62361fa
Allow user to provide CC wrapper (#255)
If using a custom toolchain not on the path, explicitly invoking
ccache/sccache is required (also easier to debug that the right compiler
is being invoked). Fixes #253.
2021-09-21 21:52:40 -07:00
Dan Gohman
a78cd329ae Build with -Wno-unknown-warning-option too.
To suppress the warning about older compilers warning about the flag to
suppress the warning that newer compilers are emitting.
2021-08-09 19:19:27 -05:00
Dan Gohman
9cbfeaaac0 Ignore -Wunused-but-set-variable warnings.
This come up when compiling musl with newer clang releases and
appear to be harmless.
2021-08-09 19:19:27 -05:00
Ayke van Laethem
c7465d2209 Add build flag to select malloc implementation
Add a build flag MALLOC_IMPL that can be set to dlmalloc or none
(defaulting to dlmalloc) which controls the malloc implementation to
use. The dlmalloc option is the same as before, but selecting none
removes dlmalloc from the libc build.

This flag replaces the BUILD_DLMALLOC flag, which never worked and thus
can be removed without breaking any builds. By switching to MALLOC_IMPL,
there is a clear path towards a different heap implementation, such as
mimalloc.
2021-07-26 13:42:15 -07:00
Dan Gohman
3c4a3f94d1 Also add a way to read environ without triggering eager init.
Add a `__wasilibc_get_environ` function which returns the value of
`environ` but without performing eager init.
2021-05-25 15:25:05 -07:00
Dan Gohman
82fc2c4f44 Add a function to de-initialize the environment-variable state.
Add a `__wasilibc_deinit_environ` function which clears the current
environment variable state to the state where next time the environment
variable functions are called, they'll reinitialize the environment.

And add a `__wasilibc_maybe_reinitialize_environ_eagerly` function to
reinitialize the environment variable state if `environ` or `_environ`
are needed.

These functions are needed by wizer to be able to suspend and resume
a program and have it read new environment variables from the host
environment; see bytecodealliance/wizer#8 for background.
2021-05-25 15:25:05 -07:00
Dan Gohman
659ff41456 Implement emulated support for getpid.
Add a simple `getpid` emulation function which just returns a fixed
value, for applications that just use it for logging.
2021-04-05 16:58:36 -07:00
Dan Gohman
c82d116de0 Add some more comments. 2021-03-23 10:34:46 -07:00
Dan Gohman
549b32be4b Include libwasi-emulated-*.a symbols in defined-symbols.txt. 2021-03-23 10:34:46 -07:00
Dan Gohman
b9b64a695a Emulate clock, times, and getrusage using the monotonic clock.
Upcoming WASI snapshots omit the `PROCESS_CPUTIME` clock, since WASI has
no inherent concept of processes, and since implementations which don't
use a process for each instance don't have a way to implement it
efficiently.

However, `clock`, `times`, and `getrusage` are useful functions, so
provide optional emulated version of them, using the `MONOTONIC` clock.
This means these implementations will measure not just the program's
own CPU time, but also time spent suspended while other programs are
running.

Due to this difference in behavior, put these implementations behind
a flag. Users must pass `-D_WASI_EMULATED_PROCESS_CLOCK` and link with
`-lwasi-emulated-process-clocks` to enable them.
2021-03-23 10:34:46 -07:00
Dan Gohman
322bd4ff9e Update to musl 1.2.2.
See the WHATSNEW file for details.
2021-03-18 11:18:41 -07:00
Zheng Luo
ca4d2f0cdb Update README.md to include Arch Linux in section title 2021-03-10 07:23:24 -08:00
Zheng Luo
b639007948 Update README to include AUR repo
Just created an AUR repo at https://aur.archlinux.org/packages/wasi-libc-git/ . Add its link to README to help fellow Archlinux users
2021-03-10 07:23:24 -08:00