sunfishcode opened PR #1565 from reactor
to master
:
This implements the new WASI ABI described here:
https://github.com/WebAssembly/WASI/blob/master/design/application-abi.md
It adds APIs to
Instance
andLinker
with support for running
WASI programs, and also simplifies the process of instantiating
WASI API modules.This currently only includes Rust API support.
<!--
Please ensure that the following steps are all taken care of before submitting
the PR.
[ ] This has been discussed in issue #..., or if not, please tell us why
here.[ ] A short description of what this does, why it is needed; if the
description becomes long, the matter should probably be discussed in an issue
first.[ ] This PR contains test cases, if meaningful.
- [ ] A reviewer from the core maintainer team has been assigned for this PR.
If you don't know who could review this, please indicate so. The list of
suggested reviewers on the right can help you.Please ensure all communication adheres to the code of conduct.
-->
alexcrichton submitted PR Review.
alexcrichton created PR Review Comment:
Duplicated sections?
alexcrichton submitted PR Review.
alexcrichton created PR Review Comment:
I think this API makes sense given WASI today, but this feels sort of uncomfortable. This means that we're splitting the world between "instantiate this module" and "instantiate this wasi module". These constructor semantics need to be bubbled to all callers and such.
Would it be possible to avoid splitting into two worlds? One option might be to have this instead of a constructor:
impl Instance { fn initialize_wasi(self) -> Result<Option<Instance>, Error> { // ... } }That way you'd always create the
Instance
the same way and it's up to you what to do with it after that.
alexcrichton created PR Review Comment:
Could you add a test for this new behavior too?
Also, perhaps for some ergonomic, could this be something like:
foo.wasm
- parses as module namefoo
and pathfoo.wasm
foo/bar.wasm
- parses as module namebar
and path namefoo/bar.wasm
foo=bar.wasm
- parses as module namefoo
and path namebar.wasm
(the
=
vs::
is certainly a bikeshed, but I personally would lean towards=
, not that it matters too too much)
sunfishcode updated PR #1565 from reactor
to master
:
This implements the new WASI ABI described here:
https://github.com/WebAssembly/WASI/blob/master/design/application-abi.md
It adds APIs to
Instance
andLinker
with support for running
WASI programs, and also simplifies the process of instantiating
WASI API modules.This currently only includes Rust API support.
<!--
Please ensure that the following steps are all taken care of before submitting
the PR.
[ ] This has been discussed in issue #..., or if not, please tell us why
here.[ ] A short description of what this does, why it is needed; if the
description becomes long, the matter should probably be discussed in an issue
first.[ ] This PR contains test cases, if meaningful.
- [ ] A reviewer from the core maintainer team has been assigned for this PR.
If you don't know who could review this, please indicate so. The list of
suggested reviewers on the right can help you.Please ensure all communication adheres to the code of conduct.
-->
sunfishcode submitted PR Review.
sunfishcode created PR Review Comment:
I'm imagining
new_wasi_abi
will be a common case. The name is perhaps confusing because this doesn't mean "run with all the WASI APIs available", but just "run the WASI startup functions if present". I actually wonder if we should rename this tonew
and rename the currentnew
tonew_raw
or something, to emphasize that it's not automatically running the WASI startup functions (though it does still run the wasm start function).
sunfishcode submitted PR Review.
sunfishcode created PR Review Comment:
I've renamed "::" to "=", and added a few tests that use it. I haven't done
foo.wasm
orfoo/bar.wasm
yet; I need to think about those a little more first.
abrown submitted PR Review.
abrown created PR Review Comment:
At first glance this looks like it should be
if instance.is_none() ...
(it looks like error-checking) but now I see that an Instance shouldn't be returned for commands--an explanatory comment might help?
abrown submitted PR Review.
abrown created PR Review Comment:
Why do we preopen dirs twice?
abrown submitted PR Review.
abrown created PR Review Comment:
Instanciate -> Instantiate
sunfishcode updated PR #1565 from reactor
to master
:
This implements the new WASI ABI described here:
https://github.com/WebAssembly/WASI/blob/master/design/application-abi.md
It adds APIs to
Instance
andLinker
with support for running
WASI programs, and also simplifies the process of instantiating
WASI API modules.This currently only includes Rust API support.
<!--
Please ensure that the following steps are all taken care of before submitting
the PR.
[ ] This has been discussed in issue #..., or if not, please tell us why
here.[ ] A short description of what this does, why it is needed; if the
description becomes long, the matter should probably be discussed in an issue
first.[ ] This PR contains test cases, if meaningful.
- [ ] A reviewer from the core maintainer team has been assigned for this PR.
If you don't know who could review this, please indicate so. The list of
suggested reviewers on the right can help you.Please ensure all communication adheres to the code of conduct.
-->
sunfishcode submitted PR Review.
sunfishcode created PR Review Comment:
Once for snapshot1 and once for snapshot0. I've now added a comment about this.
sunfishcode submitted PR Review.
sunfishcode created PR Review Comment:
Comment added.
sunfishcode updated PR #1565 from reactor
to master
:
This implements the new WASI ABI described here:
https://github.com/WebAssembly/WASI/blob/master/design/application-abi.md
It adds APIs to
Instance
andLinker
with support for running
WASI programs, and also simplifies the process of instantiating
WASI API modules.This currently only includes Rust API support.
<!--
Please ensure that the following steps are all taken care of before submitting
the PR.
[ ] This has been discussed in issue #..., or if not, please tell us why
here.[ ] A short description of what this does, why it is needed; if the
description becomes long, the matter should probably be discussed in an issue
first.[ ] This PR contains test cases, if meaningful.
- [ ] A reviewer from the core maintainer team has been assigned for this PR.
If you don't know who could review this, please indicate so. The list of
suggested reviewers on the right can help you.Please ensure all communication adheres to the code of conduct.
-->
alexcrichton submitted PR Review.
alexcrichton created PR Review Comment:
I personally still feel that this is not the API we want. Adding a new constructor for instances which "does the wasi thing" is infectious and will continue to force us to duplicate API surface area into the future. I feel remembering to call
new_wasi_abi
is basically equivalent to remembering to callinitialize_wasi
, and in terms of composability I feel that an explicit function to initialize is more convenient.
sunfishcode updated PR #1565 from reactor
to master
:
This implements the new WASI ABI described here:
https://github.com/WebAssembly/WASI/blob/master/design/application-abi.md
It adds APIs to
Instance
andLinker
with support for running
WASI programs, and also simplifies the process of instantiating
WASI API modules.This currently only includes Rust API support.
<!--
Please ensure that the following steps are all taken care of before submitting
the PR.
[ ] This has been discussed in issue #..., or if not, please tell us why
here.[ ] A short description of what this does, why it is needed; if the
description becomes long, the matter should probably be discussed in an issue
first.[ ] This PR contains test cases, if meaningful.
- [ ] A reviewer from the core maintainer team has been assigned for this PR.
If you don't know who could review this, please indicate so. The list of
suggested reviewers on the right can help you.Please ensure all communication adheres to the code of conduct.
-->
sunfishcode updated PR #1565 from reactor
to master
:
This implements the new WASI ABI described here:
https://github.com/WebAssembly/WASI/blob/master/design/application-abi.md
It adds APIs to
Instance
andLinker
with support for running
WASI programs, and also simplifies the process of instantiating
WASI API modules.This currently only includes Rust API support.
<!--
Please ensure that the following steps are all taken care of before submitting
the PR.
[ ] This has been discussed in issue #..., or if not, please tell us why
here.[ ] A short description of what this does, why it is needed; if the
description becomes long, the matter should probably be discussed in an issue
first.[ ] This PR contains test cases, if meaningful.
- [ ] A reviewer from the core maintainer team has been assigned for this PR.
If you don't know who could review this, please indicate so. The list of
suggested reviewers on the right can help you.Please ensure all communication adheres to the code of conduct.
-->
sunfishcode submitted PR Review.
sunfishcode created PR Review Comment:
A lucet change to disconnect initialization from instantiation also points in this direction.
I experimented with a few different API approaches to this, and came up with the patch that's now pushed here. With this, the Rust API's
Instance::new
andLinker::instantiate
return aNewInstance
, which is a wrapper aroundInstance
where the programmer has to initialize it before getting theInstance
out. We may need to do something different for the C API though.
sunfishcode updated PR #1565 from reactor
to master
:
This implements the new WASI ABI described here:
https://github.com/WebAssembly/WASI/blob/master/design/application-abi.md
It adds APIs to
Instance
andLinker
with support for running
WASI programs, and also simplifies the process of instantiating
WASI API modules.This currently only includes Rust API support.
<!--
Please ensure that the following steps are all taken care of before submitting
the PR.
[ ] This has been discussed in issue #..., or if not, please tell us why
here.[ ] A short description of what this does, why it is needed; if the
description becomes long, the matter should probably be discussed in an issue
first.[ ] This PR contains test cases, if meaningful.
- [ ] A reviewer from the core maintainer team has been assigned for this PR.
If you don't know who could review this, please indicate so. The list of
suggested reviewers on the right can help you.Please ensure all communication adheres to the code of conduct.
-->
sunfishcode updated PR #1565 from reactor
to master
:
This implements the new WASI ABI described here:
https://github.com/WebAssembly/WASI/blob/master/design/application-abi.md
It adds APIs to
Instance
andLinker
with support for running
WASI programs, and also simplifies the process of instantiating
WASI API modules.This currently only includes Rust API support.
<!--
Please ensure that the following steps are all taken care of before submitting
the PR.
[ ] This has been discussed in issue #..., or if not, please tell us why
here.[ ] A short description of what this does, why it is needed; if the
description becomes long, the matter should probably be discussed in an issue
first.[ ] This PR contains test cases, if meaningful.
- [ ] A reviewer from the core maintainer team has been assigned for this PR.
If you don't know who could review this, please indicate so. The list of
suggested reviewers on the right can help you.Please ensure all communication adheres to the code of conduct.
-->
sunfishcode updated PR #1565 from reactor
to master
:
This implements the new WASI ABI described here:
https://github.com/WebAssembly/WASI/blob/master/design/application-abi.md
It adds APIs to
Instance
andLinker
with support for running
WASI programs, and also simplifies the process of instantiating
WASI API modules.This currently only includes Rust API support.
<!--
Please ensure that the following steps are all taken care of before submitting
the PR.
[ ] This has been discussed in issue #..., or if not, please tell us why
here.[ ] A short description of what this does, why it is needed; if the
description becomes long, the matter should probably be discussed in an issue
first.[ ] This PR contains test cases, if meaningful.
- [ ] A reviewer from the core maintainer team has been assigned for this PR.
If you don't know who could review this, please indicate so. The list of
suggested reviewers on the right can help you.Please ensure all communication adheres to the code of conduct.
-->
sunfishcode updated PR #1565 from reactor
to master
:
This implements the new WASI ABI described here:
https://github.com/WebAssembly/WASI/blob/master/design/application-abi.md
It adds APIs to
Instance
andLinker
with support for running
WASI programs, and also simplifies the process of instantiating
WASI API modules.This currently only includes Rust API support.
<!--
Please ensure that the following steps are all taken care of before submitting
the PR.
[ ] This has been discussed in issue #..., or if not, please tell us why
here.[ ] A short description of what this does, why it is needed; if the
description becomes long, the matter should probably be discussed in an issue
first.[ ] This PR contains test cases, if meaningful.
- [ ] A reviewer from the core maintainer team has been assigned for this PR.
If you don't know who could review this, please indicate so. The list of
suggested reviewers on the right can help you.Please ensure all communication adheres to the code of conduct.
-->
alexcrichton submitted PR Review.
alexcrichton submitted PR Review.
alexcrichton created PR Review Comment:
I think this
::
should be=
now?
alexcrichton created PR Review Comment:
Is
NewInstance
still necessary here? I'd imagine that 95% of invocations ofInstance::new
will immediately want to.start()?
aftewards (and seems like 100% in this PR?). Do we have a use case for eventually getting anInstance
but not running thestart
function?
alexcrichton created PR Review Comment:
The terms "reactor" and "command" I think are pretty new to the documentation here. Would it be possible to link to somewhere else that has more details? This could also clarify that non-WASI-specific modules are handled here too, and they're treated similarly as to reactors.
alexcrichton created PR Review Comment:
I think this section may want to also get expanded with information about how the
Linker
needs to already contain all items necessary to instantiate the module when this function is called, even if this is a command.
alexcrichton created PR Review Comment:
I think in general though these two paragraphs about what happens for reactor/commands could be expanded to describe in a bit more detail what's happening under the hood.
alexcrichton created PR Review Comment:
These and below are definitely a bummer, but I guess there's not much we can do about it?
How come though we validate that only functions and a few whitelisted things are exported?
alexcrichton created PR Review Comment:
Would it be possible to include an inline example of a command and how it's a new instance each time?
alexcrichton created PR Review Comment:
This I think may want to use the debug formatter instead of
Display
to capture the full context of theanyhow::Error
alexcrichton created PR Review Comment:
Could a small inline comment be added above this whole statement indicating why all these
.unwrap()
s aren't expected to fail?
alexcrichton created PR Review Comment:
Also since this is WASI-specific would it make sense to do something like
get_wasi_default()
?
alexcrichton created PR Review Comment:
This function feels a bit odd to me because the notion of a "default" export doesn't seems super well defined. Is there WASI documentation this could link to?
In isolation it seems like this API should be on an
Instance
as well, but I understand why it's here instead of instances at this time. Perhaps they could share an implementation of sorts?
alexcrichton created PR Review Comment:
I think this should highlight very clearly that that the major purpose of this method is to transparently handle WASI conventions as well, e.g. "WASI" should be somewhere in this heading.
alexcrichton created PR Review Comment:
Anyway, not something to handle in this PR, just a thought.
alexcrichton created PR Review Comment:
While probably not a huge issue it's a bit odd that we have to assign a name to the instance here, since ideally we'd pull out an instance and "do the wasi thing" on it.
alexcrichton created PR Review Comment:
This is a "preexisting" bug but we should probably at some point spawn this thread before we start instantiating anything to account for
start
functions and_initialize
and such.(although ideally still discounting compile times of
Module
)
sunfishcode submitted PR Review.
sunfishcode created PR Review Comment:
I guess you're right. I was initially thinking of https://github.com/bytecodealliance/lucet/pull/506, but on reflection, I think this will become less important over time. If we ever do need this, we can always add a separate
Instance
constructor to construct a partially-initializedInstance
.
sunfishcode updated PR #1565 from reactor
to master
:
This implements the new WASI ABI described here:
https://github.com/WebAssembly/WASI/blob/master/design/application-abi.md
It adds APIs to
Instance
andLinker
with support for running
WASI programs, and also simplifies the process of instantiating
WASI API modules.This currently only includes Rust API support.
<!--
Please ensure that the following steps are all taken care of before submitting
the PR.
[ ] This has been discussed in issue #..., or if not, please tell us why
here.[ ] A short description of what this does, why it is needed; if the
description becomes long, the matter should probably be discussed in an issue
first.[ ] This PR contains test cases, if meaningful.
- [ ] A reviewer from the core maintainer team has been assigned for this PR.
If you don't know who could review this, please indicate so. The list of
suggested reviewers on the right can help you.Please ensure all communication adheres to the code of conduct.
-->
sunfishcode submitted PR Review.
sunfishcode created PR Review Comment:
I've now expanded this comment accordingly.
sunfishcode submitted PR Review.
sunfishcode created PR Review Comment:
I'm actually trying to de-emphasize "WASI" here. Commands and Reactors are currently defined in a WASI-repository page, but they're not related to WASI APIs, and I expect they'll eventually move out into the linking and/or interface-types specs.
sunfishcode submitted PR Review.
sunfishcode created PR Review Comment:
Good point. Perhaps, if caching is enabled and a timeout is requested, we can prime the cache with module compilations, and then start the timer before we start the
Linker
. If caching is disabled, then we just count compilation time toward the timeout, perhaps.
sunfishcode updated PR #1565 from reactor
to master
:
This implements the new WASI ABI described here:
https://github.com/WebAssembly/WASI/blob/master/design/application-abi.md
It adds APIs to
Instance
andLinker
with support for running
WASI programs, and also simplifies the process of instantiating
WASI API modules.This currently only includes Rust API support.
<!--
Please ensure that the following steps are all taken care of before submitting
the PR.
[ ] This has been discussed in issue #..., or if not, please tell us why
here.[ ] A short description of what this does, why it is needed; if the
description becomes long, the matter should probably be discussed in an issue
first.[ ] This PR contains test cases, if meaningful.
- [ ] A reviewer from the core maintainer team has been assigned for this PR.
If you don't know who could review this, please indicate so. The list of
suggested reviewers on the right can help you.Please ensure all communication adheres to the code of conduct.
-->
sunfishcode submitted PR Review.
sunfishcode created PR Review Comment:
I used a name here because I think src/commands/run.rs shouldn't be pulling out the instance and doing the initialization manually. The
Linker
handles that for it, which is good because then the functionality is available to API users as well as command-line users.
sunfishcode submitted PR Review.
sunfishcode created PR Review Comment:
Rust is one of the toolchains using
--export-dynamic
and I'd ideally like to remove that, but I need to figure out exactly how Rust use cases are depending on that before we can remove it. I've heard of other toolchains using it as well, as it sort of gives people what they want -- "just export my stuff". Except that--export-dynamic
was implemented in wasm-ld to handle the Emscripten-specific dynamic linking scheme used in Emscripten, so it also does some additional things that Emscripten needs like exporting__heap_base
and__data_end
, even when we aren't using Emscripten. So we have a multi-project backwards compatibility knot to untie before we can fix this.In general, it doesn't make sense for Commands to export globals, tables, or memories, because those are all about state, and Commands don't have any state, except when one of their exported functions is being called.
sunfishcode updated PR #1565 from reactor
to master
:
This implements the new WASI ABI described here:
https://github.com/WebAssembly/WASI/blob/master/design/application-abi.md
It adds APIs to
Instance
andLinker
with support for running
WASI programs, and also simplifies the process of instantiating
WASI API modules.This currently only includes Rust API support.
<!--
Please ensure that the following steps are all taken care of before submitting
the PR.
[ ] This has been discussed in issue #..., or if not, please tell us why
here.[ ] A short description of what this does, why it is needed; if the
description becomes long, the matter should probably be discussed in an issue
first.[ ] This PR contains test cases, if meaningful.
- [ ] A reviewer from the core maintainer team has been assigned for this PR.
If you don't know who could review this, please indicate so. The list of
suggested reviewers on the right can help you.Please ensure all communication adheres to the code of conduct.
-->
sunfishcode updated PR #1565 from reactor
to master
:
This implements the new WASI ABI described here:
https://github.com/WebAssembly/WASI/blob/master/design/application-abi.md
It adds APIs to
Instance
andLinker
with support for running
WASI programs, and also simplifies the process of instantiating
WASI API modules.This currently only includes Rust API support.
<!--
Please ensure that the following steps are all taken care of before submitting
the PR.
[ ] This has been discussed in issue #..., or if not, please tell us why
here.[ ] A short description of what this does, why it is needed; if the
description becomes long, the matter should probably be discussed in an issue
first.[ ] This PR contains test cases, if meaningful.
- [ ] A reviewer from the core maintainer team has been assigned for this PR.
If you don't know who could review this, please indicate so. The list of
suggested reviewers on the right can help you.Please ensure all communication adheres to the code of conduct.
-->
alexcrichton submitted PR Review.
alexcrichton created PR Review Comment:
Ah yeah our usage of LLD is very dated at this point in rustc. At least for rustc it probably won't be too too hard to fix this I think.
alexcrichton merged PR #1565.
Last updated: Dec 23 2024 at 12:05 UTC