cc,wasi: support WASI reactors via -mexec-model flag#8978
Closed
mathetake wants to merge 11 commits intoziglang:cc-wasm32-wasi-emulationsfrom
Closed
cc,wasi: support WASI reactors via -mexec-model flag#8978mathetake wants to merge 11 commits intoziglang:cc-wasm32-wasi-emulationsfrom
mathetake wants to merge 11 commits intoziglang:cc-wasm32-wasi-emulationsfrom
Conversation
Closed
a3b05d4 to
de2875e
Compare
kubkon
requested changes
Jun 7, 2021
Member
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.
Author
|
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>
e32a1a0 to
7d37709
Compare
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
Author
kubkon
requested changes
Jun 8, 2021
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
kubkon
approved these changes
Jun 8, 2021
Member
kubkon
left a comment
There was a problem hiding this comment.
Looks great! Thanks for working on this @mathetake!
Member
|
BTW once #8992 lands, I'll merge this one next. |
Author
|
@kubkon Thanks for the review! Much appreciated, and I learned a lot from your suggestions:) |
910b6f4 to
2ee1f78
Compare
Member
|
OK Github, why the heck did you close this PR?! |
Member
|
@mathetake would you mind reopening the PR? |
Member
|
Or I can try merging your branch manually on the command line, let's see... |
Author
|
OK, let me reopen! |
Member
Don't worry about conflicts, I'll take care of them while merging. |
Author
|
#9052 here you go! |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Based on this patch to LLVM (https://reviews.llvm.org/D62922). This partially resolves (only for zig cc) #6757