Skip to content
This repository was archived by the owner on Jan 28, 2023. It is now read-only.
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

@igrep

Description

@igrep

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions