Commit Graph

187 Commits

Author SHA1 Message Date
vms
d2482b786a
activate the use of __heap_base (#215) 2020-09-23 18:14:32 -07:00
Dan Gohman
215adc8ac9
Redefine the access bits to be compatible with other systems (#210)
Normally bits like this would be considered implementation details, but
in this case, `X_OK`, `W_OK`, and `R_OK` line up with `S_IXOTH`,
`S_IWOTH`, and `S_IROTH` on other systems, and those bits do have
well-known values.
2020-07-31 13:44:58 -07:00
Dan Gohman
00cc5944df
Comment a use of __attribute__((visibility("protected"))). (#204)
This comments out a use of "protected" visibility, since
[WebAssembly doesn't support it].

[WebAssembly doesn't support it]: https://reviews.llvm.org/D81688
2020-06-12 20:21:12 -07:00
Dan Gohman
4e45d2b5ad
Rename __prepare_for_exit to __wasm_call_dtors. (#201)
This emphasizes the relationship with `__wasm_call_ctors`. Note however
that while `__wasm_call_ctors` is synthesized by the linker,
`__wasm_call_dtors` is still defined by libc.

Static constructors are registered statically, but static destructors
need to be registered dynamically so that they only run if their
corresponding static constructors have run, and so that they're
ordered with respect to interleaved `atexit` calls.
2020-06-08 15:21:18 -07:00
Dan Gohman
5a7ba74c19
Avoid calling poll_oneoff with zero subscriptions. (#162)
* Avoid calling `poll_oneoff` with zero subscriptions.

With https://github.com/WebAssembly/WASI/pull/193 merged, WASI is moving
to make `poll_oneoff` with no arguments an error. Even though that's in
ephemeral and not yet in a snapshot, we can start to anticipate it in
libc:
 - Remove the `pause` function, since WASI has no signals and thus no
   way to ever wake it up short of having the host terminate it.
 - Make `poll` and `pselect` return `ENOTSUP` in the case of having no
   events to wait for.

* Remove `pause` from the defined-symbols.txt list.

* Fix __wasilibc_unmodified_upstream markers.

* Check for zero subscriptions, rather than zero events.

Make `poll` and `pselect` return `ENOTSUP` when asked to poll on zero
subscriptions, rather than when the systerm returns zero events.

While here, drop the `__wasilibc_unmodified_upstream` markers, which
were already pretty noisy here, and would be significantly worse with
this change.

* Add comments about the subtle relationship between nfds and nsubscriptions.

* Rewrite the comment.

* Fix code quotes.
2020-06-01 19:00:30 -07:00
Dan Gohman
753cc4344d
Merge the basics component into libc-bottom-half. (#199)
We no longer have a need to maintain basics as a separate component.
Folding it into libc-bottom-half eliminates a fair amount of redundancy.
2020-06-01 16:44:05 -07:00
Dan Gohman
84c0778bff
Rewrite the preopen functionality. (#173)
* Rewrite the preopen functionality.

Rewrite the preopen functionality to be simpler, better organized,
and better integrated into WASI libc. Preopen support has diverged so
much from libpreopen that it no longer makes sense to track libpreopen
as an explicit upstream. And add more documentation.

* Fix missing #include.

* Fix a compilation error.
2020-06-01 14:32:24 -07:00
Dan Gohman
d1cd4f4836
Replace old <signal.h> support with emulated <signal.h> support. (#183)
wasm doesn't support signals, so provide an emulation layer, enabled
with -D_WASI_EMULATED_SIGNAL and -lwasi-emulated-signal.
2020-05-29 13:07:52 -07:00
Dan Gohman
a6d0b4c74b
Reactor support. (#74)
* Add support for the Reactor model.

* Mark _activate and _start as wasm exports.

* Rename _activate to _initialize.

* Don't define `_fini`.

* Rename reactor-crt1.c to crt1-reactor.c.
2020-05-29 09:09:58 -07:00
whitequark
3e9892fc41
Make mmap() possible to use in a conformant way. (#197) 2020-05-26 12:49:13 -07:00
whitequark
9b9d243bea
Make munmap() actually work. (#198)
Before this commit, he header of a mapped area, `struct map`, was
defined as follows:

    struct map {
        int prot;
        int flags;
        off_t offset;
        size_t length;
        char body[];
    };

Because the size and alignment of an `off_t` is 8 bytes, the entire
structure was padded to 24 bytes. However, the offset of `body` into
`struct map` was only 20 bytes. Therefore the code in mmap() and
munmap() did not agree on the offset from header to body.

This commit changes mmap() to skip the entire header, which is what
munmap() expects and what the size calculation uses.
2020-05-26 12:14:52 -07:00
Pat Hickey
86550c37ab
CI: use llvm 10.0.0 release (#194)
* CI: use llvm 10.0.0 release

* ci: download mac over https, add -L flag to curl

* llvm 10 is shipping for ubuntu 18.04, which is reasonable

* llvm releases are now served from github! 🎉

* oops

* one of these days ill get it right

* love too program in yml

* missed the other spot to convert to 18.04

* mac ci: fix clang_dir
2020-04-06 16:53:56 -07:00
Pat Hickey
1792d02ac9 debug 2020-04-06 15:06:01 -07:00
Pat Hickey
ee2726700c github ci: download llvm over https, add -L flag to curl
L means follow redirects
2020-04-06 15:06:01 -07:00
Olaf Tomalka
7b92f334e6
Added utime.h (#188)
* Added utime.h

* Changes after code review

* Auto-generated expected files instead of manually editing
* Fix libpreopoen stat and utime not following symlinks correctly
2020-04-03 15:39:43 -07:00
Pat Hickey
156fdc476a regenerate api.h 2020-04-02 15:54:40 -07:00
Pat Hickey
e2bdce89ea gen-headers: make handle output consistient with prior 2020-04-02 15:54:40 -07:00
Pat Hickey
fcbf8f40ea wasi submodule: point to latest (witx 0.8.5 release) 2020-04-02 15:54:40 -07:00
Pat Hickey
4b41c5d5ec Update libc-top-half/musl/README
Co-Authored-By: Gabor Greif <ggreif@gmail.com>
2020-04-01 11:25:51 -07:00
Gabor Greif
718dcbb50e Update URL 2020-04-01 11:25:51 -07:00
Gabor Greif
2408ea94aa Fix references to musl version 2020-04-01 11:25:51 -07:00
Dan Gohman
41af0db30f
Makefile refactoring; NFC (#186)
* Use ?= for variables intended to be overridable.

* Use `override` consistently for variables not meant to be overridden.

* Omit miscellaneous comments from the build output.

* Tidy up some comments.

* Use `addprefix` to factor out a common prefix.

* Add a comment.

* Reorganize.

* Adjust indentation.

* Simplify the logic for the `check` rule.

* Remove the `override` keywords.

They theoretically protect what the Makefile considers to be
implementation details from being overridden on the command-line,
but in practice this isn't super important, and they add a lot of
clutter.

* Put source file names on their own lines.
2020-03-20 15:45:37 -07:00
Dan Gohman
9efc2f4283
Lazy-initialize the environment variables. (#184)
* Lazy-initialize the environment variables.

This is the first in a series of PRs to make it easier to use WASI libc
in Wasm modules that don't have a `main` function. By initializing the
environment on demand, we avoid depending on having `__wasm_call_ctors`
run.

This uses weak symbols strategically to ensure that if `environ` is
used, it is initialized eagerly, but if only `getenv` and friends
are used, the environment is initialized lazily.

Eventually, I expect we'll have a convention for wasm modules without
main functions which will allow the `__wasm_call_ctors` function to be
called automatically, but this helps in simple cases for now.

Fixes #180.

* Add comments explaining the libc-environ-compat.h header usage.
2020-03-19 09:32:41 -07:00
Sam Clegg
38b930a26b
Fix -std=gnu17 when generating predefined_macros.txt (#187)
* Fix -std=gnu11 when generating predefined_macros.txt

The default recently changed in upstream clang:
https://reviews.llvm.org/D75383

We want to be immune to such things when generating this list so that
we can build wasi-libc with any recent clang version.

* 17
2020-03-18 04:26:57 -07:00
Dan Gohman
42e6901e58 Mention libcxx and libcxxabi too. 2020-03-17 17:44:08 -07:00
Dan Gohman
c33ea73e0e 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.
2020-03-17 17:44:08 -07:00
Dan Gohman
0cc57ac7b4
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.
2020-02-29 10:52:28 +01:00
Dan Gohman
d9066a87c0 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.
2020-02-27 13:09:38 -08:00
Dan Gohman
575e1579a4 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.
2020-02-26 10:23:05 -08:00
Dan Gohman
79a9b40837 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.
2020-02-26 10:23:05 -08:00
Pat Hickey
e1149ab067 point at WASI with tagged unions merged into master 2020-02-24 11:36:05 -08:00
Pat Hickey
ec63fd5e9c rebased wasi repo branch 2020-02-24 11:36:05 -08:00
Pat Hickey
b3c57f19a3 main: get more useful help by requiring subcommand
fake required arguments are no good
2020-02-24 11:36:05 -08:00
Pat Hickey
d415ae65e1 minor change in union AST in wasi- tag is namedtype 2020-02-24 11:36:05 -08:00
Pat Hickey
3de8c71d06 libc: change to flattened event struct 2020-02-24 11:36:05 -08:00
Pat Hickey
7f8930168f update to WASI where snashot event_u flattened to struct 2020-02-24 11:36:05 -08:00
Pat Hickey
c2ae180dee 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
2020-02-24 11:36:05 -08:00
Pat Hickey
852d093a3c wasi/api.h: regenerated with tagged unions 2020-02-24 11:36:05 -08:00
Pat Hickey
4f03c9bbe7 WASI: tagged unions PR wip 2020-02-24 11:36:05 -08:00
Pat Hickey
71d279a4b0 wasi-headers: unions are tagged now 2020-02-24 11:36:05 -08:00
Dan Gohman
3af77075aa
Define a_clz_32 for musl so that it doesn't use a software version. (#171) 2020-02-21 11:41:05 -08:00
Dan Gohman
af92c5f9b3
WASI libc supports environment variables; update the README. (#172) 2020-02-21 11:40:41 -08:00
Dan Gohman
870a25121b
Remove unused cloudlibc headers. (#170) 2020-02-21 11:40:23 -08:00
Pat Hickey
5933c205df fix macos filename, use https 2020-02-20 09:23:32 -08:00
Pat Hickey
7c39519ec4 CI: upgrade to llvm 9.0.0 2020-02-20 09:23:32 -08:00
Pat Hickey
9ca5187170 remove no-self-update workaround for windows azure 2020-02-19 14:12:43 -08:00
Pat Hickey
9580a25927 deprecate azure pipelines CI, build libc on GH Actions 2020-02-19 14:12:43 -08:00
Dan Gohman
2c2fc9a2fd
Don't call free on paths which are about to call _Exit. (#161)
This is a minor code-size optimization.
2020-02-14 14:02:59 -08:00
Pat Hickey
c6f2c0517f
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
2020-02-07 13:21:18 -08:00
Daniel Bevenius
37c663f2f0
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
2020-02-07 05:18:10 -08:00