# stage2: Add limited WASI support for selfExePath and globalCacheDir · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/922d8378e724063063e709223e90e3a577e4566a)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: 922d8378e724063063e709223e90e3a577e4566a

Requested commit: 922d8378e724063063e709223e90e3a577e4566a

Commit: 922d8378e724063063e709223e90e3a577e4566a

Tree: 5f9dc11661b8a954c41e59ad9a286bda899c6f3c

Author: Cody Tapscott

Committer: Cody Tapscott

## Message

````
stage2: Add limited WASI support for selfExePath and globalCacheDir

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
```

````

## Parents

- [f8d2b87fa122a948e2c8e1056e2ec4cfd4cf01bf](https://git.cafe/gitcafe/zig/commit/f8d2b87fa122a948e2c8e1056e2ec4cfd4cf01bf?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/922d8378e724063063e709223e90e3a577e4566a?format=markdown)
