Uh oh!
There was an error while loading. Please reload this page.
cc,wasi: support WASI reactors via -mexec-model flag - #8978
Conversation
kubkon
left a comment
There was a problem hiding this comment.
Thanks for the PR! I've got a couple of suggestions that when we address, I'm sure we'll be able to merge this change no problem.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
mathetake
commented
Jun 7, 2021
OK so I verified this works as expected locally. |
This commit includes emulated libc sublibs that were not included in the compilation and caching of WASI libc that ships with Zig. The libs include (emulated): process clocks, getpid, mman, and signal. With this change, it is now possible to successfully cross-compile `wasm3` engine to WASI with `zig cc`. For the future though, it might be worth considering splitting WASI libc into libc-proper and modularised emulated libs as it is done in upstream, and then have them included only if the user specifically requests emulation/parts of it.
This replicates the expected behavior when using `clang` with upstream `wasi-libc` sysroot: linking emulated subcomponents such as process clocks or signals requires an explicit link flag in the compiler invocation, for example: ``` zig cc -target wasm32-wasi -lwasi-emulated-process-clocks main.c -o main.wasm ```
Move parsing of system libs into `main.zig` next to where we decide if we should link libC, and, if targeting WASI, if the specified libname equals one of the emulated components, save it on the side and remove it from the system libs. Then, build *only* those parts of WASI libc that were preserved in the previous step. This also fixes building of different crt1 bits needed to support reactors and commands.
Do not try to link WASI libc or emulated subcomponents when not targeting WASI; e.g., when targeting `wasm32-freestanding`.
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
mathetake
commented
Jun 8, 2021
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
kubkon
left a comment
There was a problem hiding this comment.
Looks great! Thanks for working on this @mathetake!
kubkon
commented
Jun 8, 2021
BTW once #8992 lands, I'll merge this one next. |
mathetake
commented
Jun 8, 2021
@kubkon Thanks for the review! Much appreciated, and I learned a lot from your suggestions:) |
910b6f4 to
2ee1f78Comparekubkon
commented
Jun 9, 2021
OK Github, why the heck did you close this PR?! |
kubkon
commented
Jun 9, 2021
@mathetake would you mind reopening the PR? |
kubkon
commented
Jun 9, 2021
Or I can try merging your branch manually on the command line, let's see... |
mathetake
commented
Jun 9, 2021
OK, let me reopen! |
kubkon
commented
Jun 9, 2021
Don't worry about conflicts, I'll take care of them while merging. |
mathetake
commented
Jun 9, 2021
#9052 here you go! |
Based on this patch to LLVM (https://reviews.llvm.org/D62922). This partially resolves (only for zig cc) #6757