]> git.proxmox.com Git - wasi-libc.git/log
wasi-libc.git
4 years agoUpdate WASI Libc's README.md.
Dan Gohman [Tue, 10 Mar 2020 23:35:50 +0000 (16:35 -0700)]
Update WASI Libc's README.md.

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.

4 years agoMulti-license wasi-libc under Apache and MIT licenses. (#174)
Dan Gohman [Sat, 29 Feb 2020 09:52:28 +0000 (01:52 -0800)]
Multi-license wasi-libc under Apache and MIT licenses. (#174)

Multi-license wasi-libc under the Apache-2.0 WITH LLVM-exception,
Apache-2.0, and MIT licenses.

4 years agoAdd support for `__main_argc_argv`.
Dan Gohman [Fri, 20 Dec 2019 23:14:02 +0000 (15:14 -0800)]
Add support for `__main_argc_argv`.

This adds support for the `__main_argc_argv` change, while preserving
compatibility with `__original_main`. This is needed by the LTO build
because the `__original_main` hack works in LLVM codegen, which is after
LTO. The `__main_argc_argv` change is implemented in clang, which makes
it properly visible to LTO.

4 years agoUpdate to musl 1.2.0.
Dan Gohman [Wed, 26 Feb 2020 16:56:59 +0000 (08:56 -0800)]
Update to musl 1.2.0.

See the WHATSNEW file for details. The biggest change in musl is the
switch to 64-bit time_t for 32-bit targets, however WASI libc was already
using 64-bit time_t. The main change affecting WASI is an update to
Unicode 12.1.0.

4 years agoUpdate to musl 1.1.24.
Dan Gohman [Mon, 14 Oct 2019 16:00:02 +0000 (09:00 -0700)]
Update to musl 1.1.24.

See the WHATSNEW file for details; this doesn't have any major changes
for wasi-libc; in particular, the new catgets and GLOB_TILDE features
are disabled.

4 years agopoint at WASI with tagged unions merged into master
Pat Hickey [Tue, 18 Feb 2020 20:36:35 +0000 (12:36 -0800)]
point at WASI with tagged unions merged into master

4 years agorebased wasi repo branch
Pat Hickey [Fri, 14 Feb 2020 01:12:43 +0000 (17:12 -0800)]
rebased wasi repo branch

4 years agomain: get more useful help by requiring subcommand
Pat Hickey [Fri, 14 Feb 2020 00:48:33 +0000 (16:48 -0800)]
main: get more useful help by requiring subcommand

fake required arguments are no good

4 years agominor change in union AST in wasi- tag is namedtype
Pat Hickey [Fri, 14 Feb 2020 00:48:17 +0000 (16:48 -0800)]
minor change in union AST in wasi- tag is namedtype

4 years agolibc: change to flattened event struct
Pat Hickey [Wed, 12 Feb 2020 17:55:32 +0000 (09:55 -0800)]
libc: change to flattened event struct

4 years agoupdate to WASI where snashot event_u flattened to struct
Pat Hickey [Wed, 12 Feb 2020 17:49:07 +0000 (09:49 -0800)]
update to WASI where snashot event_u flattened to struct

4 years agocloudlibc & libpreopen: changes for tagged unions
Pat Hickey [Thu, 6 Feb 2020 21:21:11 +0000 (13:21 -0800)]
cloudlibc & libpreopen: changes for tagged unions

we decided to abandon the upstream code guarded by
 #ifdef __wasilibc_unmodified_upstream // non-anonymous unions
because these changes are sprawling and those guards are of diminishing
importance

4 years agowasi/api.h: regenerated with tagged unions
Pat Hickey [Thu, 6 Feb 2020 21:20:57 +0000 (13:20 -0800)]
wasi/api.h: regenerated with tagged unions

4 years agoWASI: tagged unions PR wip
Pat Hickey [Thu, 6 Feb 2020 21:19:58 +0000 (13:19 -0800)]
WASI: tagged unions PR wip

4 years agowasi-headers: unions are tagged now
Pat Hickey [Thu, 6 Feb 2020 21:19:44 +0000 (13:19 -0800)]
wasi-headers: unions are tagged now

4 years agoDefine a_clz_32 for musl so that it doesn't use a software version. (#171)
Dan Gohman [Fri, 21 Feb 2020 19:41:05 +0000 (11:41 -0800)]
Define a_clz_32 for musl so that it doesn't use a software version. (#171)

4 years agoWASI libc supports environment variables; update the README. (#172)
Dan Gohman [Fri, 21 Feb 2020 19:40:41 +0000 (11:40 -0800)]
WASI libc supports environment variables; update the README. (#172)

4 years agoRemove unused cloudlibc headers. (#170)
Dan Gohman [Fri, 21 Feb 2020 19:40:23 +0000 (11:40 -0800)]
Remove unused cloudlibc headers. (#170)

4 years agofix macos filename, use https
Pat Hickey [Wed, 19 Feb 2020 23:24:14 +0000 (15:24 -0800)]
fix macos filename, use https

4 years agoCI: upgrade to llvm 9.0.0
Pat Hickey [Wed, 19 Feb 2020 22:15:48 +0000 (14:15 -0800)]
CI: upgrade to llvm 9.0.0

4 years agoremove no-self-update workaround for windows azure
Pat Hickey [Wed, 19 Feb 2020 22:09:50 +0000 (14:09 -0800)]
remove no-self-update workaround for windows azure

4 years agodeprecate azure pipelines CI, build libc on GH Actions
Pat Hickey [Wed, 19 Feb 2020 01:46:29 +0000 (17:46 -0800)]
deprecate azure pipelines CI, build libc on GH Actions

4 years agoDon't call `free` on paths which are about to call `_Exit`. (#161)
Dan Gohman [Fri, 14 Feb 2020 22:02:59 +0000 (14:02 -0800)]
Don't call `free` on paths which are about to call `_Exit`. (#161)

This is a minor code-size optimization.

4 years agogen-headers: Generate assertions of layout from witx (#149)
Pat Hickey [Fri, 7 Feb 2020 21:21:18 +0000 (13:21 -0800)]
gen-headers: Generate assertions of layout from witx (#149)

* use pch/layout branch for witx; generate assertions of layout

* address review comments, add asserts for handle

* change wasm32 support comment to a preprocessor error

* expose `to_c_header` in wasi-headers crate for use in external test harness

* main.rs: inputs and output arguments are optional

so that generate-libc command works

* regen header

4 years agoCorrect minor typo in c_headers.rs (#166)
Daniel Bevenius [Fri, 7 Feb 2020 13:18:10 +0000 (14:18 +0100)]
Correct minor typo in c_headers.rs (#166)

The header api.h was update using the following command:
$ cd tools/wasi-headers
$ cargo run -- WASI/phases/snapshot/witx/typenames.witx \
  WASI/phases/snapshot/witx/wasi_snapshot_preview1.witx \
  --output ../../libc-bottom-half/headers/public/wasi/api.h

4 years agoConvert more wasi-libc code to `//`-style comments. (#153)
Dan Gohman [Fri, 17 Jan 2020 00:00:37 +0000 (16:00 -0800)]
Convert more wasi-libc code to `//`-style comments. (#153)

This is purely a style change, in accordance with #116.

4 years agoImprovements to wasi-headers tool (#160)
Pat Hickey [Tue, 14 Jan 2020 22:24:12 +0000 (14:24 -0800)]
Improvements to wasi-headers tool (#160)

* wasi-headers: update WASI submodule, handle changes to witx ast

* wasi-headers: restructure lib and exe to be more flexible

just factor out some of the hard-coded stuff

4 years agoFix environment variable init to exit successfully. (#159)
Dan Gohman [Tue, 14 Jan 2020 17:56:58 +0000 (09:56 -0800)]
Fix environment variable init to exit successfully. (#159)

This fixes https://github.com/bytecodealliance/wasmtime/issues/783.

4 years agoMove math source files. (#151)
Dan Gohman [Fri, 20 Dec 2019 23:43:31 +0000 (15:43 -0800)]
Move math source files. (#151)

This is split out from the LTO change. It's needed by the LTO build so
that we can easily build these files in non-LTO mode, since they satisfy
calls emitted by LLVM codegen after LTO.

4 years agoAvoid using cast expressions in WASI API constants. (#148)
Dan Gohman [Mon, 16 Dec 2019 21:29:06 +0000 (13:29 -0800)]
Avoid using cast expressions in WASI API constants. (#148)

Cast expressions aren't valid to use in some preprocessor constants, so
change the constants to use `UINT32_C` etc. instead of casts.

Fixes #146.

4 years agoUpdate signal macros after upgrade to snapshot1 (#144)
Sam Clegg [Tue, 3 Dec 2019 17:23:40 +0000 (11:23 -0600)]
Update signal macros after upgrade to snapshot1 (#144)

This should probably have been part of #140 but we don't actually
support signals so this doesn't get much testing I imagine.

The old names like `__WASI_SIGBUS` no longer exist and the new names
look like `__WASI_SIGNAL_BUS`.

4 years agogithub actions: pin checkout action to v1 (#145)
Sam Clegg [Tue, 3 Dec 2019 17:15:26 +0000 (11:15 -0600)]
github actions: pin checkout action to v1 (#145)

master now contains a new v2 beta version of this action that no longer
supports "submodules".   We can update to v2 later once it stabilizes.

4 years agoUse constructor functions for optional init routines. (#142)
Dan Gohman [Mon, 25 Nov 2019 22:04:45 +0000 (14:04 -0800)]
Use constructor functions for optional init routines. (#142)

* Use constructor functions for optional init routines.

Instead of using weak symbols, use constructor function attributes for the
environment and preopen initialization routines. This is simpler, uses
less code, and is more LTO-friendly.

* Change the constructor priorities to start at 50.

We don't currently have specific plans for other levels in the reserved
range (0-100), so leave room for both lower and higher priorities.

4 years agoc header generation updated for reorganized witx ast (#139)
Pat Hickey [Fri, 22 Nov 2019 18:06:12 +0000 (13:06 -0500)]
c header generation updated for reorganized witx ast (#139)

4 years agoCorrect the version of #136 on master (#141)
Dan Gohman [Fri, 22 Nov 2019 04:55:26 +0000 (20:55 -0800)]
Correct the version of #136 on master (#141)

* Add the WASI repo as a submodule.

Also, add the witx filenames to the generated output, and just have
`cargo run` auto-generate the api.h header, rather than using clap.

* Switch witx to a path dependency.

* Add a test.

* Add a test that the generated file is in sync with the generator.

* Enable CI testing with Github Actions.

* Fix the name of the wasi-headers directory.

* Enable submodules.

* Add a diff mechanism to help explain failures.

* Sort the inputs for display.

* More debugging.

* More debugging.

* Add a .gitattributes file forcing text files to be eol=lf.

Most editors these days can deal with eof=lf files, even on Windows, and
this avoids trouble with headers and other generated files differing in
line endings.

4 years agoWasi snapshot preview1 (#140)
Dan Gohman [Fri, 22 Nov 2019 04:06:00 +0000 (20:06 -0800)]
Wasi snapshot preview1 (#140)

* Make __wasi_linkcount_t a uint64_t (#134)

Refs: https://github.com/WebAssembly/WASI/pull/127

* Generate the WASI interface from witx.

This replaces the hand-maintained <wasi/core.h> header with a
<wasi/api.h> generated from witx.

Most of the churn here is caused by upstream WASI renamings; hopefully
in the future ABI updates will be less noisy.

4 years agoIgnore rights in libpreopen. (#129)
Dan Gohman [Thu, 21 Nov 2019 23:49:51 +0000 (15:49 -0800)]
Ignore rights in libpreopen. (#129)

Don't ignore paths which don't have the required rights. This means
that if the lookup finds a path that doesn't have the required
rights, it'll just proceed to the actual operation which will fail
with `ENOTCAPABLE`.

Intuitively, use cases which would depend on having multiple
overlapping matching paths for a given lookup and intelligently
picking the one with the required rights seems like they should
be uncommon.

This is simpler overall, and requires less code.

4 years agoMake the `__original_main` definition weak, fixing -flto. (#138)
Dan Gohman [Wed, 20 Nov 2019 19:35:47 +0000 (11:35 -0800)]
Make the `__original_main` definition weak, fixing -flto. (#138)

4 years agoOptimize `fmin`, `fmax`, etc. (#120)
Dan Gohman [Wed, 20 Nov 2019 19:13:45 +0000 (11:13 -0800)]
Optimize `fmin`, `fmax`, etc. (#120)

Use wasm's builtin min and max operators to implement libc `fmin`,
`fmax, `fminf`, and `fmaxf`, by handling the NaN cases explicitly.

Credit to https://github.com/emscripten-core/emscripten/pull/9689
for spotting this opportunity!

4 years agoDon't pre-check capabilities in `openat`. (#130)
Dan Gohman [Sun, 10 Nov 2019 14:39:00 +0000 (06:39 -0800)]
Don't pre-check capabilities in `openat`. (#130)

Rely on the WASI implementation to check capabilities flags, rather
than also checking them in the userspace `openat` implementation.

This code is admittedly getting fairly dense with `#ifdef`s, so it
may soon make sense to move this file out of the `cloudlibc`
directory and removing the upstream change markers.

4 years agoUse consistent style for wasi-libc C source files. (#131)
Dan Gohman [Fri, 8 Nov 2019 19:59:57 +0000 (11:59 -0800)]
Use consistent style for wasi-libc C source files. (#131)

For now, this means using `//`-style comments in .c source files (though
not public header files), and spaces rather than tabs. No strong opinion
here; this is just what the majority of the current code is using.

This also synchronizes basics/crt/crt1.c with libc-bottom-half's
version, though this is just a cleanup as the former isn't currently used
by the main wasi-libc build.

4 years agoFix unintended recursion in __wasilibc_register_preopened_fd. (#133)
Dan Gohman [Fri, 8 Nov 2019 19:44:18 +0000 (11:44 -0800)]
Fix unintended recursion in __wasilibc_register_preopened_fd. (#133)

4 years agoAvoid a `strdup` call in `__wasilibc_populate_libpreopen`. (#128)
Dan Gohman [Fri, 8 Nov 2019 19:31:44 +0000 (11:31 -0800)]
Avoid a `strdup` call in `__wasilibc_populate_libpreopen`. (#128)

* Avoid a `strdup` call in `__wasilibc_populate_libpreopen`.

Optimize `__wasilibc_populate_libpreopen` to avoid calling `strdup` in
the common case where it's called from `__wasilibc_populate_libpreopen`.

* Convert an if into a ?:.

4 years agoDon't link in libpreopen initialization code when it isn't needed. (#127)
Dan Gohman [Fri, 8 Nov 2019 19:08:22 +0000 (11:08 -0800)]
Don't link in libpreopen initialization code when it isn't needed. (#127)

* Avoid linking in `populate_libpreopen` when it isn't needed.

* Merge adjacent `if`s using `&&`.

4 years agoTemporarily disable the use of `__heap_base`. (#132)
Dan Gohman [Thu, 7 Nov 2019 21:09:31 +0000 (13:09 -0800)]
Temporarily disable the use of `__heap_base`. (#132)

This temporarily disables the feature in
a214f1c0b167608ab4ec3e63f8144c3430af9372, since it hits LLVM bug
43613, which is fixed on LLVM master and awaiting a backport to
the 9.0 branch.

https://bugs.llvm.org/show_bug.cgi?id=43613

4 years agoUse __heap_base by dlmalloc (#114)
vms [Tue, 5 Nov 2019 20:52:51 +0000 (23:52 +0300)]
Use __heap_base by dlmalloc (#114)

* add explicit allocator initialization

* move init to a better place

* fix warnings

* add __wasilibc_try_init_allocator

* move initialization to dlmalloc()

* fix typos

* fix identations

* follow style guide

* review changes

4 years agoAvoid varargs conventions when calling open (#126)
Dan Gohman [Tue, 5 Nov 2019 00:37:45 +0000 (16:37 -0800)]
Avoid varargs conventions when calling open (#126)

* Add an entrypoint for calling open that bypasses the varargs.

* Add an entrypoint for calling openat that bypasses the varargs.

4 years agoRevamp and simplify the libpreopen code. (#110)
Dan Gohman [Mon, 4 Nov 2019 22:56:35 +0000 (14:56 -0800)]
Revamp and simplify the libpreopen code. (#110)

wasi-libc's copy of libpreopen has evolved so many local changes that
it's no longer worth keeping the upstream code structure and marking
changes with __wasilibc_unmodified_upstream.

This PR merges the source files into a single file, removes all
__wasilibc_unmodified_upstream code, eliminates the ability to
allocate multiple preopen lists, eliminates the need for
__wasilibc_init_preopen, eliminates the non-standard eaccess, and
makes several other cleanups. It also enables NDEBUG so that internal
assertions are disabled in release builds.

4 years agoRemove more unsupported headers. (#123)
Dan Gohman [Mon, 4 Nov 2019 21:17:03 +0000 (13:17 -0800)]
Remove more unsupported headers. (#123)

utime.h, sysmacros.h, and libintl.h are all currently unsupported.
Removing them helps programs that autodetect features based on the
existence of headers.

4 years agoAvoid using user identifiers in function declarations. (#124)
Dan Gohman [Mon, 28 Oct 2019 18:08:12 +0000 (11:08 -0700)]
Avoid using user identifiers in function declarations. (#124)

MultiSource/Benchmarks/McCat in llvm-test-suite has a macro named
`n`, so rename function parameters to avoid colliding.

4 years agoDon't build bind_textdomain_codeset.c (#122)
Dan Gohman [Mon, 28 Oct 2019 17:35:45 +0000 (10:35 -0700)]
Don't build bind_textdomain_codeset.c (#122)

`bind_textdomain_codeset` without the rest of libintl.h isn't useful
without the rest of gettext.

4 years agoEnsure `__environ` is initialized even when it's empty. (#125)
Dan Gohman [Mon, 28 Oct 2019 17:34:57 +0000 (10:34 -0700)]
Ensure `__environ` is initialized even when it's empty. (#125)

POSIX requires `environ` to be a pointer to a NULL-terminated array of
pointers, so it itself can't be NULL.

This fixes a regression in src/functional/env.c in wasi-libc-test.

4 years agoCall `populate_args` only if we actually need command-line arguments (#112)
Dan Gohman [Fri, 25 Oct 2019 00:30:46 +0000 (17:30 -0700)]
Call `populate_args` only if we actually need command-line arguments (#112)

* Link `populate_args` only if we actually need command-line arguments.

This avoids linking in the argv/argc initialization code,
and the __wasi_args_sizes_get and __wasi_args_get imports, in
programs that don't use command-line arguments. The way this works is,
if the user writes `int main(int argc, char *argv[])`, the argument
initialization code is loaded, and if they write `int main(void)`,
it's not loaded.

This promotes the `__original_main` mechanism into an effective contract
between the compiler and libc, which wasn't its original purpose,
however it seems to fit this purpose quite well.

* Document that `__original_main` may be the user's zero-arg `main`.

4 years agoFix corner cases and style in the argv/argc code. (#118)
Dan Gohman [Tue, 22 Oct 2019 18:25:19 +0000 (11:25 -0700)]
Fix corner cases and style in the argv/argc code. (#118)

This fixes some potential memory leaks in pathological situations, and
updates the code to use `//`-style comments.

4 years agoWorkaround a bug causing Windows CI failures. (#119)
Dan Gohman [Tue, 22 Oct 2019 15:00:48 +0000 (08:00 -0700)]
Workaround a bug causing Windows CI failures. (#119)

This works around [this bug], which manifests as

```
error: could not remove 'setup' file: 'C:\Users\VssAdministrator\.cargo\bin/rustup-init.exe'
info: caused by: Access is denied. (os error 5)
```

as suggested by [this comment].

[this bug]: https://github.com/microsoft/azure-pipelines-image-generation/issues/1224
[this comment]: https://github.com/CraneStation/wasi-libc/pull/118#issuecomment-544978683

4 years agoCall `populate_environ` only if we actually need environment variables. (#109)
Dan Gohman [Tue, 22 Oct 2019 13:02:44 +0000 (06:02 -0700)]
Call `populate_environ` only if we actually need environment variables. (#109)

* Link `populate_environ` only if we actually need environment variables.

This avoids linking in the environment variable initialization code,
and the __wasi_environ_sizes_get and __wasi_environ_get imports, in
programs that don't use environment variables.

This also removes the "___environ" (three underscores) alias symbol,
which is only in musl for backwards compatibility.

* Switch to //-style comments.

* If malloc fails, don't leave `__environ` pointing to an uninitialized buffer.

* Fix a memory leak if one malloc succeeds and the other fails.

* Use calloc to handle multiplication overflow.

This also handles the NULL terminator.

* Don't initialize __environ until everything has succeeded.

* Avoid leaking in case __wasi_environ_get fails.

* Handle overflow in the add too.

* Add #include <stdlib.h> for malloc etc.

* If the environment is empty, don't allocate any memory.

4 years agoMake sbrk(0) deterministic (#115)
vms [Mon, 21 Oct 2019 22:44:23 +0000 (01:44 +0300)]
Make sbrk(0) deterministic (#115)

* fix the behavior of sbrk(0)

* review changes

4 years agoMiscellaneous cleanups (#113)
Dan Gohman [Fri, 18 Oct 2019 20:53:13 +0000 (13:53 -0700)]
Miscellaneous cleanups (#113)

* Tidy up some #include names.

* Move non-cloudlibc sources out of the cloudlibc directory.

4 years agofix the typo (#108)
vms [Mon, 14 Oct 2019 21:52:10 +0000 (00:52 +0300)]
fix the typo (#108)

* fix the typo

4 years agoRemove -fno-builtin. (#104)
Dan Gohman [Fri, 11 Oct 2019 12:07:34 +0000 (05:07 -0700)]
Remove -fno-builtin. (#104)

* Remove -fno-builtin.

-fno-builtin suppresses optimizations such as turning calls to `sqrt`
or `fabs` into `f64.sqrt` or `f64.abs` instructions inline. Libc code
itself benefits from these optimizations.

I originally added this flag because historically it was needed when
building libc to avoid the compiler pattern-matching the body of memcpy
into a memcpy call, however clang no longer requires this.

* Expand the comment about why we use USE_DL_PREFIX in dlmalloc.

4 years agoDon't define readdir64_r.
Dan Gohman [Fri, 4 Oct 2019 20:15:38 +0000 (13:15 -0700)]
Don't define readdir64_r.

wasi-libc doesn't define readdir_r, so don't define readdir64_r as an
alias for it.

4 years agoOmit musl's stdarg.h and stddef.h from the sysroot.
Dan Gohman [Mon, 29 Apr 2019 12:52:26 +0000 (05:52 -0700)]
Omit musl's stdarg.h and stddef.h from the sysroot.

We already use the compiler's versions of these; this just moves from
having libc #include_next them to having libc just omit them entirely,
which is simpler.

This removes the special code to define musl's include guard, however
I originally added that when I was still working out how WASI's stddef.h
would interact with other code. I believe it's no longer important.

4 years agoFactor out the include-file exclude list into a variable.
Dan Gohman [Mon, 29 Apr 2019 12:50:54 +0000 (05:50 -0700)]
Factor out the include-file exclude list into a variable.

This also starts categorizing these headers into groups and adding
comments explaining their purpose.

4 years agoAdd a CODE_OF_CONDUCT.md file. (#101)
Dan Gohman [Thu, 3 Oct 2019 12:15:49 +0000 (05:15 -0700)]
Add a CODE_OF_CONDUCT.md file. (#101)

4 years agoSet the MALLOC_ALIGNMENT to 16.
Dan Gohman [Fri, 19 Jul 2019 22:06:57 +0000 (15:06 -0700)]
Set the MALLOC_ALIGNMENT to 16.

This isn't strictly required, as wasm SIMD loads and stores work on
unaligned memory. However, it may provide better performance. That said,
this isn't currently studied by any benchmarking.

4 years agoWhen checking undefined symbol list, ignore certain llvm buildins
Sam Clegg [Fri, 30 Aug 2019 01:05:38 +0000 (18:05 -0700)]
When checking undefined symbol list, ignore certain llvm buildins

These can vary between llvm version.  For example a recent upstream
change recently added __multi3 to the list:
https://reviews.llvm.org/D65143

Fixes #98

4 years agoFix a warning about a spurious redundant static keyword.
Dan Gohman [Thu, 29 Aug 2019 14:01:59 +0000 (07:01 -0700)]
Fix a warning about a spurious redundant static keyword.

4 years agoUpdate docs to say "libc" rather than "sysroot" where applicable.
Dan Gohman [Tue, 4 Jun 2019 03:45:29 +0000 (20:45 -0700)]
Update docs to say "libc" rather than "sysroot" where applicable.

4 years agoWASI libc's dirent does have t_type, so define _DIRENT_HAVE_D_TYPE.
Dan Gohman [Thu, 29 Aug 2019 16:40:40 +0000 (09:40 -0700)]
WASI libc's dirent does have t_type, so define _DIRENT_HAVE_D_TYPE.

Also update predefined-macros.txt.

4 years agoFix _DIRENT_HAVE_D_* macros.
Dan Gohman [Thu, 29 Aug 2019 13:58:56 +0000 (06:58 -0700)]
Fix _DIRENT_HAVE_D_* macros.

Don't define _DIRENT_HAVE_D_RECLEN or _DIRENT_HAVE_D_OFF, as WASI libc's
dirent doesn't have d_reclen or d_off.

4 years agoDisable the lseek optimization in C++.
Dan Gohman [Wed, 10 Jul 2019 00:21:38 +0000 (17:21 -0700)]
Disable the lseek optimization in C++.

The lseek optimization turns lseek calls into __wasilibc_tell calls when
possible, using macros and __builtin_constant_p. However, this isn't
safe in C++ code in the presence of namespaces and `using` declarations,
to just disable it in C++ for now.

4 years agoAdd Azure Pipelines definition (#78)
Till Schneidereit [Mon, 12 Aug 2019 11:50:53 +0000 (13:50 +0200)]
Add Azure Pipelines definition (#78)

4 years agoUpdate to musl 1.1.23.
Dan Gohman [Fri, 19 Jul 2019 19:40:16 +0000 (12:40 -0700)]
Update to musl 1.1.23.

See the WHATSNEW file for details; among other things, this contains new
math library implementation for log/exp/pow.

4 years agoFix predefined macros check after recent clang change
Sam Clegg [Fri, 12 Jul 2019 09:21:15 +0000 (02:21 -0700)]
Fix predefined macros check after recent clang change

This is an alternative to #75.

4 years agoDon't declare `realpath` or pseudo-terminal functions.
Dan Gohman [Thu, 11 Jul 2019 16:32:39 +0000 (09:32 -0700)]
Don't declare `realpath` or pseudo-terminal functions.

These functions are not currently defined, so suppress their declarations
in the headers.

4 years agoUpdate title in README.md
Sam Clegg [Mon, 24 Jun 2019 17:21:36 +0000 (10:21 -0700)]
Update title in README.md

5 years agoEnsure argv is null terminated.
Sam Clegg [Wed, 29 May 2019 23:27:58 +0000 (16:27 -0700)]
Ensure argv is null terminated.

This matches the behavior of populate __environ.

See #27

5 years agoDon't declare popen and pclose.
Dan Gohman [Tue, 14 May 2019 18:43:37 +0000 (11:43 -0700)]
Don't declare popen and pclose.

5 years agoDon't install <sys/xattr.h>, which isn't supported on WASI.
Dan Gohman [Tue, 14 May 2019 15:58:02 +0000 (08:58 -0700)]
Don't install <sys/xattr.h>, which isn't supported on WASI.

5 years agoRemove more declarations for symbols that aren't defined.
Dan Gohman [Tue, 14 May 2019 15:36:35 +0000 (08:36 -0700)]
Remove more declarations for symbols that aren't defined.

5 years agoDon't declare lockfile and timezone functions.
Dan Gohman [Tue, 7 May 2019 16:27:05 +0000 (09:27 -0700)]
Don't declare lockfile and timezone functions.

These aren't defined, so don't declare them either.

5 years agoImplement truncate(2).
Dan Gohman [Tue, 14 May 2019 18:49:22 +0000 (11:49 -0700)]
Implement truncate(2).

This adds a simple implementation of truncate in terms of open and
ftruncate.

5 years agoAdd complex builtins for creal and cimag too.
Dan Gohman [Tue, 14 May 2019 16:53:05 +0000 (09:53 -0700)]
Add complex builtins for creal and cimag too.

5 years agoUse builtin functions rather than portable libm implementations.
Dan Gohman [Fri, 3 May 2019 20:55:41 +0000 (13:55 -0700)]
Use builtin functions rather than portable libm implementations.

For functions like sqrt, fabs, and others, use the builtin functions,
which provide single-instruction implementations, rather than using
musl's portable implementations.

5 years agoDon't create dummy libs for libc++/libc++abi (#68)
Sam Clegg [Wed, 15 May 2019 16:54:54 +0000 (09:54 -0700)]
Don't create dummy libs for libc++/libc++abi (#68)

My understanding is that these dummy libs represent libraries who's
contents, under musl, live in libc itself rather than being split out
into separate libs.

libc++/libc++abi are not provided my musl so doesn't make sense to
pretend that we provide them.

5 years agoImplement more functions, remove more unimplemented headers.
Dan Gohman [Tue, 14 May 2019 18:54:41 +0000 (11:54 -0700)]
Implement more functions, remove more unimplemented headers.

Enable more musl sources for things tested in libc-test, and remove more
headers that aren't implemented on WASI.

5 years agoMove the mode_t macros into their own header.
Dan Gohman [Thu, 9 May 2019 17:31:09 +0000 (10:31 -0700)]
Move the mode_t macros into their own header.

This allows them to be defined by <fcntl.h> as well, as specified by
POSIX.

This fixes a part of src/api/fcntl.c.

5 years agoDefine O_TTY_INIT.
Dan Gohman [Thu, 9 May 2019 17:32:40 +0000 (10:32 -0700)]
Define O_TTY_INIT.

Define it to 0, as several popular operating systems ignore this flag.

This fixes a part of src/api/fcntl.c.

5 years agoUpdate to libpreopen 8835639f27fc42d32096d59d294a0bbb857dc368.
Dan Gohman [Tue, 7 May 2019 23:54:48 +0000 (16:54 -0700)]
Update to libpreopen 8835639f27fc42d32096d59d294a0bbb857dc368.

This replaces our custom `unlink` wrapper with an upstream one. We still
end up replacing the entire body with local changes, but this makes it
easier to see what those changes are.

The other change here is a fix to ignore repeated '/'s in paths.

5 years agoFix fmemopen and friends to use the correct SEEK_* values.
Dan Gohman [Wed, 8 May 2019 22:14:06 +0000 (15:14 -0700)]
Fix fmemopen and friends to use the correct SEEK_* values.

WASI's values for SEEK_CUR, SEEK_SET, and SEEK_END differ from musl's
values, so fix musl code that bakes in knowledge of these values.

This fixes src/functional/memstream.c.

5 years agoUse the compiler's real/imag operators instead of union type punning.
Dan Gohman [Mon, 29 Apr 2019 12:59:36 +0000 (05:59 -0700)]
Use the compiler's real/imag operators instead of union type punning.

This removes the last use of union type punning from WASI libc's
public header files.

5 years agoRemove __fpclassify and __signbit definitions.
Dan Gohman [Mon, 29 Apr 2019 12:10:37 +0000 (05:10 -0700)]
Remove __fpclassify and __signbit definitions.

With fpclassify and signbit now implemented as compiler builtins in a64f6544,
these out-of-line helper functions are no longer needed.

5 years agoUse the compiler builtins for isless etc.
Dan Gohman [Mon, 29 Apr 2019 12:10:37 +0000 (05:10 -0700)]
Use the compiler builtins for isless etc.

Building on a64f6544, use compiler builtins for isless, isgreater,
isunordered, and similar as well.

5 years agoMove the SEEK_* macros into their own header and use it from fcntl.h.
Dan Gohman [Wed, 8 May 2019 16:13:47 +0000 (09:13 -0700)]
Move the SEEK_* macros into their own header and use it from fcntl.h.

POSIX requires fcntl.h to define the SEEK_* macros, so this satisfies
that requirement. Also, this allows <stdio.h> to avoid including as much
unnecessary content.

This fixes one issue with src/api/fcntl.c.

5 years agoSwitch from the cloudlibc inet_pton etc. to the musl versions.
Dan Gohman [Wed, 8 May 2019 18:58:46 +0000 (11:58 -0700)]
Switch from the cloudlibc inet_pton etc. to the musl versions.

These functions aren't specific to the underlying system call interface,
so they don't need to be in the "bottom half".

This also fixes src/functional/inet_pton.c and
src/regression/inet_pton-empty-last-field.c in musl's libc-test.

5 years agoDon't declare dup in unistd.h.
Dan Gohman [Thu, 9 May 2019 06:05:14 +0000 (23:05 -0700)]
Don't declare dup in unistd.h.

Dup isn't defined in libc.a, so don't declare it.

5 years agoRe-enable '%s' in strftime.
Dan Gohman [Thu, 9 May 2019 05:29:34 +0000 (22:29 -0700)]
Re-enable '%s' in strftime.

This was commented out earlier when timezone handling was more in flux,
but it's ok to minimally support this now.

This fixes src/functional/strftime.c in libc-test.

5 years agoRename __wasilibc_rmfileat to __wasilibc_unlinkat.
Dan Gohman [Sat, 4 May 2019 06:36:00 +0000 (23:36 -0700)]
Rename __wasilibc_rmfileat to __wasilibc_unlinkat.

The POSIX terminology is that directories are "removed" while files
are "unlinked".

5 years agoAdd __restrict qualifiers to the fstatat declaration.
Dan Gohman [Sat, 4 May 2019 22:22:16 +0000 (15:22 -0700)]
Add __restrict qualifiers to the fstatat declaration.

This makes it consistent with its definition.

5 years agoEnsure that `environ` is always initialized.
Dan Gohman [Tue, 7 May 2019 16:24:10 +0000 (09:24 -0700)]
Ensure that `environ` is always initialized.

Initialize `environ` even if there are no environment variables, so that
it alwasy points to a NULL-terminated array even if that array just
contains the NULL. This fixes src/functional/env.c.