diff options
| author | Jakub Konka <kubkon@jakubkonka.com> | 2022-04-18 23:53:41 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-04-18 23:53:41 +0200 |
| commit | b03345f32a5ba2849ddbeeae0e31e0e77ca01b01 (patch) | |
| tree | 4100326d0b400a38525d980739214feaf48508b8 /src/main.zig | |
| parent | 5195b87639a1dc56b90751d0aecc4fcf4f2a1bb0 (diff) | |
| parent | 3a63fa6b7f56a2f384ebd460e80c00e6bbd2efee (diff) | |
| download | zig-b03345f32a5ba2849ddbeeae0e31e0e77ca01b01.tar.gz zig-b03345f32a5ba2849ddbeeae0e31e0e77ca01b01.zip | |
Merge pull request #11024 from topolarity/wasi-stage2
stage2: Add limited WASI support for selfExePath and globalCacheDir
Diffstat (limited to 'src/main.zig')
| -rw-r--r-- | src/main.zig | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/main.zig b/src/main.zig index e341a10f99..823eb91f33 100644 --- a/src/main.zig +++ b/src/main.zig @@ -162,6 +162,16 @@ pub fn main() anyerror!void { return mainArgs(gpa_tracy.allocator(), arena, args); } + // WASI: `--dir` instructs the WASM runtime to "preopen" a directory, making + // it available to the us, the guest program. This is the only way for us to + // access files/dirs on the host filesystem + if (builtin.os.tag == .wasi) { + // This sets our CWD to "/preopens/cwd" + // Dot-prefixed preopens like `--dir=.` are "mounted" at "/preopens/cwd" + // Other preopens like `--dir=lib` are "mounted" at "/" + try std.os.initPreopensWasi(std.heap.page_allocator, "/preopens/cwd"); + } + return mainArgs(gpa, arena, args); } |
