wasip2: Improve "command" startup flow #710
Open
+133
−77
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This commit is an improvement to the WASIp2 target which changes how the interface
wasi:cli/runis defined and exported. Previously thewasm32-wasip2target would define a_startwasm export which required the use of the WASIp1-to-WASIp2 adapter to hook it up towasi:cli/run. This meant that despite libc not actually using any WASIp2 APIs the adapter was still used. The purpose of this commit is to change this.The changes made here are:
_startsymbol now has a wasm-level export name ofwasi:cli/run@0.2.0#run. This means that_startisn't a wasm-level export any more, meaning there's nothing for the adapter to import._startfunction is now different based on WASI version (returns anintin WASIp2, nothing on WASIp1)crt1-command.oobject file now contains type information forwasi:cli/run(which previously wasn't present anywhere in wasi-libc). This means that when this object is linked inwit-componentwill know what to do after linking.The end result is that binaries are now produced entirely without the WASIp1-to-WASIp2 adapter and linking with
-Wl,--wasi-adapter=none, for example, produces a working binary.Another minor change made in this commit is that the
crt1-*.cfiles are now included inclang-formatlike all other source files.Build-wise this requires the usage of
wasm-toolsat build-time to embed type information in the clang-produced object file forcrt1-command.o.