-
Notifications
You must be signed in to change notification settings - Fork 12.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Conditionalize use of POSIX features missing on WASI/WebAssembly.
This patch is the first in a series that makes it possible to build LLVM, Clang, and LLD for WASI/WebAssembly. This patch does not introduce conditionals of the form `defined(__wasi__)` or `defined(__wasm__)`; instead it detects these APIs like any other platform features. While some features are never present in WASI and the feature check is functionally identical to a platform check, some may be conditionally present if emulation is turned on, e.g. `getpid`. The complete list of feature tests introduced is: * `HAVE_ALARM`: WebAssembly does not support delivery of asynchronous signals. * `HAVE_GETHOSTNAME`: WASI does not provide `gethostname`. * `HAVE_GETPID`: WASI does not have process IDs. However, it ships with a polyfill (`-D_WASI_EMULATED_GETPID`). The final behavior is the same either way. * `HAVE_FCHOWN`: WASI likely will never support UNIX ownership model. * `HAVE_FLOCK`: WASI likely will never support POSIX advisory locking. * `HAVE_PWD_H`: WASI likely will never support UNIX password databases. * `HAVE_RAISE`: WASI does not support delivery of asynchronous signals. However, it ships with a polyfill (`-D_WASI_EMULATED_SIGNAL`). This polyfill implements `raise` but not `sigaction` (only `signal`) and as a result it is not currently useful for LLVM. If `sigaction` is implemented in wasi-libc then `raise(SIGABRT);` would be able to invoke the handler. * `HAVE_SETJMP`: WebAssembly implements SjLj using exception handling. Exception handling has not been stabilized in Wasm yet. In addition, it significantly increases deployment complexity. Building with `-mllvm -wasm-enable-sjlj` enables the use of SjLj. * `HAVE_SOCKET`: WASIp1 does not provide the Berkeley socket API. WASIp2 does provide it. It will likely remain desirable to target WASIp1 for a long time. * `HAVE_SYS_WAIT_H`: WASI does not have subprocess management. * `HAVE_UMASK`: WASI likely will never support UNIX permission model, but `umask` might eventually be added in a polyfill. Of these, only `HAVE_FLOCK` requires a custom compile test: #include <sys/file.h> struct flock lk; int main(void) { return 0; }
- Loading branch information
1 parent
577785c
commit 0a86da8
Showing
11 changed files
with
116 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.