Replies: 20 comments
-
Hello! Could you give us a minimal reproducible example and info about the tools you're using to build the module? |
Beta Was this translation helpful? Give feedback.
-
git clone https://github.com/Cloudef/zig-aio
cd zig-aio
# zig version 0.14.0-dev.3267+59dc15fa0
# ignore the errors you see
zig build install -Dtarget=wasm32-wasi-none
# from the project directory
wasmer --dir . ./zig-out/example/aio_immediate.was the result with wasmer is:
wasmtime prints the contents of |
Beta Was this translation helpful? Give feedback.
-
I can reproduce the error when using
We will look into the problem with |
Beta Was this translation helpful? Give feedback.
-
Seems the |
Beta Was this translation helpful? Give feedback.
-
Note: |
Beta Was this translation helpful? Give feedback.
-
Oh, I'm asking the wrong question. Zig only supports WASI, not WASIX. As WASI doesn't support the concept of host-side CWD, there's no way this can work correctly. @xdoardo I believe the correct fix would be to mount |
Beta Was this translation helpful? Give feedback.
-
Here is problem with the tests: git clone -b wasix https://github.com/Cloudef/zig-aio
cd zig-aio
zig build test:aio -Dtarget=wasm32-wasi-none -Daio:wasi=wasix It fails to open the .zig-cache directory.
I want to be able to use some wasix functions such as |
Beta Was this translation helpful? Give feedback.
-
To be honest, I have no idea what will happen if you add a few wasix imports to a module built against the wasi-libc... See, by default, when you build for WASI, you're building against wasi-libc. When you build for WASIX, on the other hand, you're building against wasix-libc. While the two are similar, they're not the same; WASIX provides many features that are missing from WASI, and some of those have cross-cutting implications across the entire application. As an example, CWD is one such case; with WASIX, the host can provide a CWD to the module (which wasmer does when you run with Furthermore, when a module includes any The correct solution to this would be for zig to add support for the WASIX target. This is not super-complicated, but the zig maintainers appear to not be in favor of accepting it (it was already proposed before, and rejected); so that option does not exist at this time. |
Beta Was this translation helpful? Give feedback.
-
I'm not linking to any libc |
Beta Was this translation helpful? Give feedback.
-
When you build any code for a specific target, you're ultimately linking against that target's libc, which is where all the most basic of functionality is implemented on top of OS syscalls. For non-C languages, the compiler usually does this for you automatically. For example, on linux, you have |
Beta Was this translation helpful? Give feedback.
-
No, I'm not linking to any libc. |
Beta Was this translation helpful? Give feedback.
-
Zig is doing it for you automatically. |
Beta Was this translation helpful? Give feedback.
-
It's not. Zig does not link to libc unless asked. Linux target is libcless. Zig exposes wasi functions like this: https://github.com/ziglang/zig/blob/master/lib/std/os/wasi.zig and zig implements "posix like" api in std.posix, it's completely libcless |
Beta Was this translation helpful? Give feedback.
-
There appears to be a wasi-libc in the zig source, though? I'm not super-familiar with zig tbh, but I don't suppose you can bootstrap a module without wasi-libc (or recreating its functionality in zig). |
Beta Was this translation helpful? Give feedback.
-
That one isn't used unless you ask to link against libc.
The thing is that zig doesn't call libc functions, it calls the wasi functions directly, it implements posix like api with std.posix. If you link to libc, then std.posix will instead call the libc implementations. |
Beta Was this translation helpful? Give feedback.
-
Interesting... However, regardless of whether zig uses wasi-libc or not, and my general lack of understanding of zig, what I can tell you is that |
Beta Was this translation helpful? Give feedback.
-
So what this means in practice (by reading wasix-libc) that all relative paths should be joined with |
Beta Was this translation helpful? Give feedback.
-
It seems even without any wasix symbols being compiled into the program, it still fails to open (or create) the .zig_cache directory
Curious is that it's returning notdir rather than noent which is the reason zig's test runner won't try creating the directory |
Beta Was this translation helpful? Give feedback.
-
Are you running with |
Beta Was this translation helpful? Give feedback.
-
These steps should reproduce:
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm trying to add wasix support to one of my projects, but I can't figure out how to give wasmer access to
cwd
.I've tried
--dir .
,--mapdir /:.
, nothing seems to work. Does wasmer reserve some fds to itself, what's thecwd
fd?With
wasmtime
,--dir .
works as expected.Beta Was this translation helpful? Give feedback.
All reactions