This repository was archived by the owner on Jan 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
This repository was archived by the owner on Jan 28, 2023. It is now read-only.
Clarify what should be the first value of the result of args.get #7
Copy link
Copy link
Closed
Description
As long as I referred to the latest and old documents (listed below), they have never clarified the first value of the result array of wasi_ephemeral_args.get. Both wasmtime and wasmer actually put the wasm file's basename there, but that isn't documented yet. Due to the vagueness, Node.js's WASI implementation doesn't pass the basename unless the user explicitly pass as the args option.
For example:
Source file of the WASI executable (args.rs):
use std::env;
fn main() {
println!("{:?}", env::args().collect::<Vec<String>>())
}Node.js script to run the WASI file (run-wasi.mjs):
import fs from 'fs';
import { WASI } from 'wasi';
const [_node, _thisScript, wasmFile, ... args] = process.argv;
const wasi = new WASI({ args });
const importObject = { wasi_snapshot_preview1: wasi.wasiImport };
const wasm = await WebAssembly.compile(fs.readFileSync(wasmFile));
const instance = await WebAssembly.instantiate(wasm, importObject);
wasi.start(instance);Example result by Node.js:
> node -v
v16.3.0
> node --experimental-wasi-unstable-preview1 run-wasi.mjs path/to/args.wasm aaa bbb
(node:7950) ExperimentalWarning: WASI is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
["aaa", "bbb"]Example result by wasmtime:
> wasmtime --version
wasmtime 0.28.0
> wasmtime path/to/args.wasm aaa bbb
["args.wasm", "aaa", "bbb"]So I think we should specify the current behavior of wasmtime and wasmer in the document for consistency.
Ref.
- https://github.com/WebAssembly/wasi-classic-command/blob/5bacb3845eb16c37f036ce4a330201c8dc0defe9/phases/ephemeral/docs.md#-getargv-pointerpointeru8-argv_buf-pointeru8---result-errno
- https://github.com/WebAssembly/WASI/blob/main/phases/ephemeral/docs.md#-getargv-pointerpointeru8-argv_buf-pointeru8---result-errno
- https://github.com/WebAssembly/WASI/blob/main/phases/snapshot/docs.md#-args_getargv-pointerpointeru8-argv_buf-pointeru8---result-errno
- https://github.com/WebAssembly/WASI/blob/main/phases/old/snapshot_0/docs.md#-args_getargv-pointerpointeru8-argv_buf-pointeru8---result-errno
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels