Stream: general

Topic: Arguments to wasm modules in wasmtime


view this post on Zulip James Sturtevant (Jun 16 2023 at 20:56):

I've been working on some changes for runwasi and I've noticed that modules get passed the program name in the wasmtime cli as the first argument. In my PR to runwasi, I found that I didn't need to pass the module name and everything worked properly. It feels strange to me to have applications that skip the first argument to do work.

What is the reason for the first argument being the module name? Is the approach I took valid?

A fast and secure runtime for WebAssembly. Contribute to bytecodealliance/wasmtime development by creating an account on GitHub.
When working on adding OCI artifact support, I found two bugs: the args to the program wasm program included the module.wasm artifact. This means the demo app was parsing the second arguement even...
Facilitates running Wasm / WASI workloads managed by containerd - runwasi/crates/wasi-demo-app/src/main.rs at aeb48cd053f0b1049ae59f8ce4de8a8505fde85d · containerd/runwasi

view this post on Zulip bjorn3 (Jun 16 2023 at 21:19):

This matches unix and windows where thw first arg is also what the user wrote as program to run. This for example allow customizing help messages based on the actual executable name or to have an executable which contains multiple programs and dispatches based on the name used to execute it. For example busybox is a single executable with all coreutils. If you create a symlink or hardlink from ls to the busybox executable, running ls will make busybox list all files in a directory, but if say the symlink or hardlink is called echo it would echo it's arguments back.

view this post on Zulip James Sturtevant (Jun 16 2023 at 21:36):

oh gosh, I feel like I should have known that :flushed: thank you (my c# background is showing up where args to the main entry point don't include the program name thought you can get it elsewhere)

Learn about Main() and command-line arguments. The 'Main' method is the entry point of an executable program.

Last updated: Nov 22 2024 at 17:03 UTC