stage2: Add limited WASI support for selfExePath and globalCacheDir - #11024
Merged
Conversation
Contributor
|
The other nice thing about WASI is it's not too hard to emulate a subset of it in browsers |
topolarity
force-pushed
the
wasi-stage2
branch
2 times, most recently
from
March 5, 2022 20:38
fec1f3b to
b60f2bb
Compare
Contributor
Author
|
I've hit what seems to be an instability in the CI tests a couple times now, related to the test "POSIX file locking with fcntl". Maybe the 1ms wait in that test is too low? Is this a known problem? |
matu3ba
reviewed
Mar 7, 2022
matu3ba
left a comment
Contributor
There was a problem hiding this comment.
nit to reorder sentence and question on tests with recommended preopen
Contributor
Author
|
Chose to make this dependent on #11053 - Let's try to get that one merged first |
kubkon
requested changes
Apr 16, 2022
This change adds support for locating the Zig executable and the library and global cache directories, based on looking in the fixed "/zig" and "/cache" directories. Since our argv[0] on WASI is just the basename (any absolute/relative path information is deleted by the runtime), there's very limited introspection we can do on WASI, so we rely on these fixed directories. These can be provided on the command-line using `--mapdir`, as follows: ``` wasmtime --mapdir=/cwd::. --mapdir=/cache::"$HOME/.cache/zig" --mapdir=/zig::./zig-out/ ./zig-out/bin/zig.wasm ```
kubkon
approved these changes
Apr 18, 2022
andrewrk
reviewed
Apr 18, 2022
andrewrk
reviewed
Apr 18, 2022
Contributor
|
I tried making a build, but it seems to be broken now. |
Member
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.
Dependent on #11053. Resolves #10716.
This PR adds support for locating the Zig executable and the library and global cache directories, based on looking in the fixed "/zig" and "/cache" directories. It also bypasses the file-locking in "src/Cache.zig" and initializes the WASI preopens on startup.
The expected directories can be provided on the command-line using
--mapdir, as follows:The reason for the fixed directories is that argv[0] on WASI is just the basename (any absolute/relative path information is deleted by the runtime) and there is no WASI-equivalent to procfs.
This is enough to get stage2 running without LLVM on WASI:
This should be considered highly experimental - I haven't even checked the behavior tests or anything.