-
Notifications
You must be signed in to change notification settings - Fork 947
tinygo: revise and simplify wasmtime argument handling #4555
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Use wasmtime run subcommand instead of bare wasmtime. This enables use of wasmtime serve or other subcommands. - Simplify buildAndRun, condensing wasmtime handling into a single section handling env vars and dir args. - Only set PWD to the package dir if running tests, but not with tinygo run.
@@ -925,7 +927,7 @@ func buildAndRun(pkgName string, config *compileopts.Config, stdout io.Writer, c | |||
|
|||
// Run binary. | |||
if config.Options.PrintCommands != nil { | |||
config.Options.PrintCommands(cmd.Path, cmd.Args...) | |||
config.Options.PrintCommands(cmd.Path, cmd.Args[1:]...) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Running tinygo run -x ...
repeated the full path to wasmtime
and wasmtime
.
The |
Yes that still works. The equivalent |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
* wasihttp: remove func optionZero * examples/basic: basic debug logging * wasihttp: rename functions, add TODO * wasihttp: implement basic response handling for server * internal/go/http/proxy: chmod * wasip2-http.json: change emulator to wasmtime serve Depends on tinygo-org/tinygo#4555 * wasihttp: reorganize and streamline wasi:http to net/http API translation * examples/basic: TinyGo does not support net/http@go1.22 with new mux features like 'GET /' * wasihttp: implement http.ResponseWriter writes * wasihttp: implement streamWriter * wasihttp: OK initialism * wasihttp: refine interface to streamWriter * wasihttp: clean up transport * wasihttp: embed fewer fields * wasihttp: remove Close method from streamWriter * wasihttp: rename incomingReader to bodyReader * wasihttp: rename streamWriter to bodyWriter * wasihttp: make trailer callback naming consistent * wasihttp: add trailers callback to newBodyWriter * wasihttp: centralize sending trailers and OutgoingBodyFinish * wasihttp: allow nil trailer callback * examples/basic: add goroutine-driven counter wasmtime serve does not reuse instances, so this does not work * .github: add .github directory for initial CI and Dependabot config
This PR implements 3 related changes to how TinyGo processes arguments for the
wasmtime
emulator. I ran across the issue related to trying to usewasmtime serve
in a custom target file for my WasmCon talk next month.It adds support for alternative
wasmtime
subcommands likeserve
, simplifies the Wasmtime-specific code paths, and fixes PWD handling fortinygo run
when not running tests. I recommend reviewing by commit to see the individual changes.Detailed changes:
buildAndRun
, condensingwasmtime
handling into a single section handling--env
and--dir
args.wasmtime run
subcommand instead of barewasmtime
. This enables use ofwasmtime serve
or other subcommands. The key change is that emulator arguments are inserted after the subcommand, e.g.run
.PWD
to the package dir only when running tests, which allowstinygo run --target wasip1
to run withPWD=.
.-x
(PrintCommands
) where it repeated the full path and name of the command.