Repository navigation
[wasi] Combine main function for the default and single file bundle - #85617
Conversation
.. case. This was prompted by dotnet#85616 where running `Invariant.Tests` breaks with: ``` Running /root/helix/work/correlation/wasmtime/wasmtime --dir=. --env=DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=true dotnet.wasm WasmTestRunner managed/Invariant.Tests.dll -notrait category=IgnoreForCI -notrait category=OuterLoop -notrait category=failing Unhandled Exception: System.ArgumentException: Invalid argument 'managed/Invariant.Tests.dll'. at SimpleWasmTestRunner.Main(String[] args) at SimpleWasmTestRunner.<Main>(String[] args) ``` - This broke because of a recent change due to which setting `InvariantGlobalization=true` meant `WasmBuildNative=true` - But this did not trigger single file bundle - And the build ended up relinking a dotnet.wasm but using the single-file bundle `main` function. Instead, we combine the two main functions and switch between the behavior depending on compile time defines. Fixes dotnet#85616
|
Tagging subscribers to 'arch-wasm': @lewing Issue Details.. case. This was prompted by #85616 where running
Instead, we combine the two main functions and switch between the behavior depending on compile time defines. Fixes #85616
|
| /* | ||
| * For default case which uses dotnet.wasm, running with wasmtime: | ||
| * | ||
| * $ wasmtime run --dir . dotnet.wasm MainAssembly [args] |
There was a problem hiding this comment.
Shouldn't we have a unified way to run the application? For example, could we rename the dotnet.wasm to MainAssembly.wasm even for non-single file bundle?
There was a problem hiding this comment.
I think that for non-single application, the interesting feature is that dotnet.wasm is always the same content. Full set of features, with which you could run any managed assembly.
There was a problem hiding this comment.
Does renaming it harm the premise you mentioned? Do we plan to distribute it separately? Isn't it confusing to run the app differently based on build time bundling?
There was a problem hiding this comment.
dotnet host should be able to run any assembly on wasi
| mono_wasm_load_runtime("", 0); | ||
|
|
||
| int arg_ofs = 0; | ||
| #ifdef WASM_SINGLE_FILE |
There was a problem hiding this comment.
this is the same problem we have with shell on emscripten.
I would prefer to separate the "runtime options" from "application arguments" by --.
In this case there are no "runtime options" because we know which assembly to load.
it would be wasmtime run --dir . -- --run MainAssembly.wasm -- [application args]
In the single file the syntax would be
it would be wasmtime run --dir . -- -- [application args]
Note, that wasmtime also has -- it's own, to solve the same problem.
This would allow us in the future to add other runtime options, without counting positions of the arguments.
For example single-file
wasmtime run --dir . -- --soft-breakpoints -- [args]
where --soft-breakpoints is example of Mono option
There was a problem hiding this comment.
Cleanly delineating arguments sounds like a good idea. I can explore that in a follow up PR. This PR fixes a regression and gets it passing on CI.
.. case.
This was prompted by #85616 where running
Invariant.Testsbreaks with:InvariantGlobalization=truemeantWasmBuildNative=truemainfunction.mainfunctions expect different set of command line arguments, and the mismatch causes the failureInstead, we combine the two main functions and switch between the behavior depending on compile time defines.
Fixes #85616