Skip to content
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

add wasm32-wasi-preview2 target #457

Merged
merged 1 commit into from
Dec 22, 2023
Merged

Conversation

dicej
Copy link
Contributor

@dicej dicej commented Dec 20, 2023

Currently, this is identical to the wasm32-wasi in all but name. See #449 for the next step, which is to incrementally add Preview 2 features, e.g. wasi-sockets. Per the discussion in that PR, I've split the wasi-sysroot/include directory into per-target directories. Eventually, we'll want to build a separate sysroot for each target, but there's currently uncertainty about how to configure the default sysroot for e.g. clang, so we're not tackling that yet.

See also #447 for further details.

Currently, this is identical to the `wasm32-wasi` in all but name.  See WebAssembly#449 for
the next step, which is to incrementally add Preview 2 features,
e.g. `wasi-sockets`.  Per the discussion in that PR, I've split the
`wasi-sysroot/include` directory into per-target directories.  Eventually, we'll
want to build a separate sysroot for each target, but there's currently
uncertainty about how to configure the default sysroot for e.g. clang, so we're
not tackling that yet.

See also WebAssembly#447 for further details.

Signed-off-by: Joel Dice <[email protected]>
@sbc100
Copy link
Member

sbc100 commented Dec 20, 2023

Is the plan the binaries built with wasm32-wasi-preview2 can/will also contain preview1 imports? i.e. that they will be kind of a hybrid of the two?

@dicej
Copy link
Contributor Author

dicej commented Dec 20, 2023

Is the plan the binaries built with wasm32-wasi-preview2 can/will also contain preview1 imports? i.e. that they will be kind of a hybrid of the two?

Yes, initially. See the Proposal section of #447 for details. Eventually, we'll remove all preview1 imports, at which point the preview1->preview2 adapter will no longer be needed.

@sbc100
Copy link
Member

sbc100 commented Dec 20, 2023

Great.

Off-topic-followup: I'm curious how wit-component and the adapter work exactly. Is it possible for the end result to be a single core wasm with preview1 + preview2 imports? i.e. will we be able to run the results on engines that don't directly support the component model?

@dicej
Copy link
Contributor Author

dicej commented Dec 20, 2023

Off-topic-followup: I'm curious how wit-component and the adapter work exactly. Is it possible for the end result to be a single core wasm with preview1 + preview2 imports? i.e. will we be able to run the results on engines that don't directly support the component model?

Yes, you could use the module directly without any adapter or wit-component if you had a host that could satisfy both the preview1 and preview2 imports at the module level.

Also I believe @cpetig has experimented with building the adapter as a .a file and linking it using wasm-ld, which would give you a module that only imports preview2 functions (but is still a module, not a component).

@sbc100
Copy link
Member

sbc100 commented Dec 20, 2023

Yes, you could use the module directly without any adapter or wit-component if you had a host that could satisfy both the preview1 and preview2 imports at the module level.

Awesome!

(It sounds like we will be able to use emcc --post-link <module.wasm> with such modules and that emcc will be able to supply both preview1 and preview2 imports to allow such modules to run on the web).

@dicej
Copy link
Contributor Author

dicej commented Dec 20, 2023

(It sounds like we will be able to use emcc --post-link <module.wasm> with such modules and that emcc will be able to supply both preview1 and preview2 imports to allow such modules to run on the web).

Sounds great. Note that you can also use jco to run Preview 2 components on the web.

@dicej
Copy link
Contributor Author

dicej commented Dec 21, 2023

Any feedback on the PR itself? I was thinking I'd add the generated WIT bindings and Makefile support for regenerating them in a separate PR, but I could add them to this one if desired.

@sbc100
Copy link
Member

sbc100 commented Dec 21, 2023

Any feedback on the PR itself? I was thinking I'd add the generated WIT bindings and Makefile support for regenerating them in a separate PR, but I could add them to this one if desired.

I love small PRs so if you can separate them like this I'd appreciate it.

@sbc100
Copy link
Member

sbc100 commented Dec 21, 2023

lgtm but I've added @sunfishcode as a reviewer, since I don't know the wit-component + adapter stuff in the test directory works.

Also, want to make sure @sunfishcode is OK with the separate multi-arch include directory approach?

@sunfishcode
Copy link
Member

Looks good to me. I expect the adapter logic there will evolve, but this looks like a good starting point.

The separate multi-arch include setup seems good to me.

@sunfishcode sunfishcode merged commit 5a69318 into WebAssembly:main Dec 22, 2023
8 checks passed
dicej added a commit to dicej/wasi-sdk that referenced this pull request Jan 3, 2024
This updates `wasi-libc` to include
WebAssembly/wasi-libc#457, which adds preliminary
support for the new `wasm32-wasi-preview2` target.

It also adds support for testing the new target using Wasmtime 16.0.0 and
`wit-component`.

Signed-off-by: Joel Dice <[email protected]>
dicej added a commit to dicej/wasi-sdk that referenced this pull request Jan 3, 2024
This updates `wasi-libc` to include
WebAssembly/wasi-libc#457, which adds preliminary
support for the new `wasm32-wasi-preview2` target.

It also adds support for testing the new target using Wasmtime 16.0.0 and
`wit-component`.  Note that Wasmtime produces different output when reporting
errors for Preview 2 components than it does for Preview 1 modules, so I've
added a few .expected files specific to Preview 2.

Signed-off-by: Joel Dice <[email protected]>
sunfishcode pushed a commit to WebAssembly/wasi-sdk that referenced this pull request Jan 10, 2024
* build and test `wasm32-wasi-preview2` target

This updates `wasi-libc` to include
WebAssembly/wasi-libc#457, which adds preliminary
support for the new `wasm32-wasi-preview2` target.

It also adds support for testing the new target using Wasmtime 16.0.0 and
`wit-component`.  Note that Wasmtime produces different output when reporting
errors for Preview 2 components than it does for Preview 1 modules, so I've
added a few .expected files specific to Preview 2.

Signed-off-by: Joel Dice <[email protected]>

* test all three targets

Signed-off-by: Joel Dice <[email protected]>

---------

Signed-off-by: Joel Dice <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants