Allow building when targeting WASI#1509
Conversation
| // NaCL __native_client__ | ||
| // AsmJS __asmjs__ | ||
| // WebAssembly __wasm__ | ||
| // WebAssembly (Emscripten) __EMSCRIPTEN__ |
There was a problem hiding this comment.
WebAssembly is an architecture, such as x86, not an operating system, which is a syscall layer so in its case, either Emscripten or WASI currently. I have changed this to clarify, as Emscripten is a WebAssembly "OS" which supports mmap while WASI does not.
I can add wasi to this list if it makes sense, but I suspect that would be a bigger decision on whether the project officially supports the OS now or not. But it would be great if we can at least add smaller fixes like this PR on a best-effort basis to allow compilation to pass to encourage the use of abseil within the server-side WebAssembly community
| #include "absl/debugging/stacktrace.h" | ||
|
|
||
| #ifndef _WIN32 | ||
| #if !defined(_WIN32) && !defined(__wasi__) |
There was a problem hiding this comment.
It seems that Emscripten does support this codepath while wasi doesn't so I added a wasi-specific option here
|
To build, I did
|
|
/cc @sbc100 @abrown in case any questions about wasi-sdk come up I'm not familiar with Also, just in case it helps to have a use case in mind, I compile RE2 to WASI for loading in Go apps. https://github.com/wasilibs/go-re2 But RE2 has migrated to using |
|
In ec9fa08 I went ahead and added a wasi guard for the signal header file in thread_identity to at least allow that file to compile without the stubbed header file enabled via |
|
I'm testing this now. WASI won't receive official support, but this PR is simple enough that if it works, we can take it. |
Imported from GitHub PR abseil#1509 WASI is similar to emscripten, providing a syscall layer to WebAssembly focused on server side applications. There are some config knobs that are in place to allow building the repo for emscripten which also need to support wasi (as built with LLVM). Aside from that, there are still some features it supports less than escripten, for example related to signals, causing the build to be even more limited for it. Merge ec9fa08 into 861e53c Merging this change closes abseil#1509 COPYBARA_INTEGRATE_REVIEW=abseil#1509 from anuraaga:wasi-sdk-build ec9fa08 PiperOrigin-RevId: 557166498 Change-Id: Ic51149d8b092fd888c9a5c383275257fc8ff4232
Imported from GitHub PR abseil/abseil-cpp#1509 WASI is similar to emscripten, providing a syscall layer to WebAssembly focused on server side applications. There are some config knobs that are in place to allow building the repo for emscripten which also need to support wasi (as built with LLVM). Aside from that, there are still some features it supports less than escripten, for example related to signals, causing the build to be even more limited for it. Merge ec9fa081609687035005dfdafd312754f31c3fbb into 861e53c Merging this change closes #1509 COPYBARA_INTEGRATE_REVIEW=abseil/abseil-cpp#1509 from anuraaga:wasi-sdk-build ec9fa081609687035005dfdafd312754f31c3fbb PiperOrigin-RevId: 557166498 Change-Id: Ic51149d8b092fd888c9a5c383275257fc8ff4232
Imported from GitHub PR #1922 #1509 completely removed the mmap support when targeting WASI. wasi-libc supports an optional emulated mmap implementation if [`_WASI_EMULATED_MMAN`](https://github.com/WebAssembly/wasi-libc/blob/main/libc-top-half/musl/include/sys/mman.h) is set. Emulated mmap calls in wasi-libc come with a few restrictions, but users are aware of them as the feature is opt-in. This PR enables mmap support for WASI if `_WASI_EMULATED_MMAN` is defined. Merge e2519a6 into c5e0072 Merging this change closes #1922 COPYBARA_INTEGRATE_REVIEW=#1922 from zebreus:master e2519a6 PiperOrigin-RevId: 796418883 Change-Id: I5b7db767fa79269e191d7d7abcffd679d71d3ecc
Imported from GitHub PR abseil/abseil-cpp#1509 WASI is similar to emscripten, providing a syscall layer to WebAssembly focused on server side applications. There are some config knobs that are in place to allow building the repo for emscripten which also need to support wasi (as built with LLVM). Aside from that, there are still some features it supports less than escripten, for example related to signals, causing the build to be even more limited for it. Merge ec9fa081609687035005dfdafd312754f31c3fbb into 861e53c Merging this change closes #1509 COPYBARA_INTEGRATE_REVIEW=abseil/abseil-cpp#1509 from anuraaga:wasi-sdk-build ec9fa081609687035005dfdafd312754f31c3fbb PiperOrigin-RevId: 557166498 Change-Id: Ic51149d8b092fd888c9a5c383275257fc8ff4232
WASI is similar to emscripten, providing a syscall layer to WebAssembly focused on server side applications. There are some config knobs that are in place to allow building the repo for emscripten which also need to support wasi (as built with LLVM). Aside from that, there are still some features it supports less than escripten, for example related to signals, causing the build to be even more limited for it.