Closed alexcrichton closed 4 months ago
This issue is not meant to be used for technical discussion. There is a Zulip stream for that. Use this issue to leave procedural comments, such as volunteering to review, indicating that you second the proposal (or third, etc), or raising a concern that you would like to be addressed.
Concerns or objections to the proposal should be discussed on Zulip and formally registered here by adding a comment with the following syntax:
@rustbot concern reason-for-concern
<description of the concern>
Concerns can be lifted with:
@rustbot resolve reason-for-concern
See documentation at https://forge.rust-lang.org
cc @rust-lang/compiler @rust-lang/compiler-contributors
Edit: Moved to the zulip thread.
A tier 2 target must have value to people other than its maintainers
The response to this question has been broadly generic "The wasm32-wasip2 target and the component model in general in WebAssembly have broad interest from many stakeholders", and I think is not properly aligned with the reality. Mainly, because the members of the Bytecode Alliance are actually the maintainers of WASI Preview 2.
I am personally not aware of a single user of Preview 2 outside of the maintainers of WASI Preview 2 (Fastly, Fermyon, Intel, ...). Not a single standalone runtime (outside of the BA), has adopted Preview 2 (that is: not wazero, not wamr, not stitch, not wizard, ...).
It has also been widely reported (1, 2) that WASI Preview 2 might not aligned with community interests, and maybe that's why is seeing so little adoption outside of the Bytecode Alliance.
Of course, my views can be limited and I might not be seeing the whole picture. Could you point of a maintainer outside of the Bytecode Alliance that maintains WASI Preview 2?
I hope my scepticism is interpreted with the best light. Because I deeply care about the Rust ecosystem, I do want to make sure if we lower the bar to accept targets to be Tier 2, this is done in a transparent fashion, in a way that tradeoffs on the requirements are analyzed and weighted properly.
Thanks!
@syrusakbary issue comments here are reserved for procedural things, for other comments like yours you should use the Zulip stream. I've responded on Zulip
Thanks @alexcrichton.
As I don't know the data retention policy of that Zulip channel and the post linked is already public, I'm reposting here the response in case is useful for readers in the future:
(alexcrichton) [...] I understood the term "maintainers" there to be the maintainers of the Rust target itself
(simulacrum) I'm pretty sure we've intended that to mean it's not just for the humans requesting addition but a broader group, and notably not a closed group. I don't think it's a very high bar to clear, basically it can't be a target that you e.g. can only develop on with a privately available toolchain or privately available hardware. (simulacrum) (and we semi-routinely drop targets if they become disused, so I think if p2 isn't actually stable etc. it's not a big deal from rust's perspective)
I don't currently have more questions on this matter, but if I do I'll ask them on Zulip first
@rustbot second
@rustbot label -final-comment-period +major-change-accepted
Proposal
This is a proposal to upgrade the
wasm32-wasip2
target, (introduced here, and implemented here), to tier 2. Currently this is a tier 3 target that requires-Zbuild-std
to work with.This target is not easy to work with as a tier 3 target for a number of reasons:
wasm-component-ld
, is requiredIt is possible to set everything up such that
-Zbuild-std
works but the lack of tier 2 support additionally makes it significantly harder to adopt this target throughout the ecosystem. For example when addingwasm32-wasip2
support to crates it's difficult to set up CI testing without a tier 2 target in place.Recap of
wasm32-wasip2
and other WebAssembly targetsThe
wasm32-wasip2
target is different from other WebAssembly targets in that the default output of the compiler is a component, not a core WebAssembly module. Support for components is not widespread at this time and is primarily found in Wasmtime for out-of-browser use cases of WebAssembly or jco for running in the browser.The
wasm32-wasip2
target reflects the development of WASI itself and is what the WebAssembly WASI Subgroup is working on these days. Thewasm32-wasip2
Rust target will provide access via the standard library to appropriate WASI interfaces. The best example of this is that thewasm32-wasip1
target had only extremely basic support for networking (TCP/UDP) and it was not widely implemented in runtimes. With WASIp2, however, there are official interfaces for TCP/UDP/DNS/etc which are supported in WASIp2 implementations. This means thatstd::net
works with thewasm32-wasip2
target. (modulo a final PR to get it hooked up to the support in wasi-libc).For general intro-style documentation about components I'd recommend browsing https://component-model.bytecodealliance.org/
A new
wasm-component-ld
linker binary forwasm32-wasip2
This proposal intends to be a little more involved than "just" adding a new precompiled version of the standard library. This proposal is also to add the
wasm-component-ld
binary to the sysroot. This will live within thegcc-ld
folder alongside the preexistingwasm-ld
binary. The source ofwasm-component-ld
is intended to be modest where it's a wrapper around two pieces of functionality: thewasm-ld
linker itself and thewit_component::ComponentEncoder
type. While this could be integrated directly into rustc it's intended to be a separate binary to have a similar toolchain experience with Rust and C (e.g. this isn't getting integrated into Clang so it's a separate binary in thewasi-sdk
).This linker is currently shipping in the latest release of wasi-sdk and is how the Clang target for
wasm32-wasip2
links code.My plan at this time for the integration of this Rust-based binary is to publish
wasm-component-ld
to crates.io with a library crate that containsfn main() { ... }
. This would be pulled in as a dependency as part ofsrc/tools/wasm-component-ld
in the Rust repository and then the build system would build it from there. That will enable vendoring/offline builds/etc to continue to work along with a defined location of where the dependency version is specified.Tier 2 Requirements
From the tier requirements (with some omitted for brevity):
The
wasm32-wasip2
target and the component model in general in WebAssembly have broad interest from many stakeholders. Much of this is embodied by the Bytecode Alliance and its member organizations.Myself and @rylev are signed up as target maintainers. If more interest is required I can ask around if other folks would like to sign up here too.
This target will not have any more significant burden than the preexisting
wasm32-wasip1
target. Thewasm32-wasip1
target is already tested in CI to help weed out WebAssembly-specific issues and this target will mostly be new build configuration in the same builder handling the other wasm targets.I will audit https://doc.rust-lang.org/nightly/rustc/platform-support/wasm32-wasip2.html if this proposal is accepted and implemented. Additionally the numerous tutorials for using Rust with the component model will eventually be updated to use
wasm32-wasip2
. For examplecargo component
will be updated to use this target when it's available.I'll audit https://doc.rust-lang.org/nightly/rustc/platform-support/wasm32-wasip2.html for this as well. This will follow the default set of WebAssembly features as other WebAssembly targets and the OS will be defined as the WASIp2 set of interfaces. The set of interfaces in WASIp2, and their iteration over time, is governed by the WebAssembly WASI Subgroup.
This target will primarily omit the
std::thread
module when it is introduced. Not supportingstd::thread
matcheswasm32-wasip1
and is generally not possible today. Work is happening within the component model and WebAssembly itself to eventually support threads.The
wasm32-wasip2
is intended to interoperate with C code and this is tested in CI forwasm32-wasip1
and will be exercised in community crates.I am not planning at this time to add tests to CI for
wasm32-wasip2
. Instead I plan on only implementing build support and getting it into the ecosystem. Eventually in the long-term I'd like to migrate the testing ofwasm32-wasip1
towasm32-wasip2
as it contains the ability to run networking tests (std::net
). This will take time to implement, however.A modest amount of time will be taken compiling
wasm-component-ld
for all host targets. This is expected to be negligible, however. Otherwise I plan on reusing thedist-various-2
builder for the target itself which as of the latest merge to Rust takes 55m compared to the full run time of 2h14m.I recently migrated testing of WebAssembly on CI from
wasm32-unknown-unknown
towasm32-wasip1
with Wasmtime which provides a better experience with at least being able to print to stdout/stderr. I've not otherwise been alterted to difficulties in testing for WebAssembly. At this timewasm32-wasip2
is not expected to move the needle here much relative to the current state.Given the similarities of the
wasm32-wasip1
andwasm32-wasip2
targets I wasn't planning for this at this time. My hope would be that the testing ofwasm32-wasip1
is sufficient until the point at whichwasm32-wasip2
might be run instead.Mentors or Reviewers
I plan on personally doing the work to ship
wasm-component-ld
and enabling this as a tier 2 target.Process
The main points of the Major Change Process are as follows:
@rustbot second
.-C flag
, then full team check-off is required.@rfcbot fcp merge
on either the MCP or the PR.You can read more about Major Change Proposals on forge.
Comments
This issue is not meant to be used for technical discussion. There is a Zulip stream for that. Use this issue to leave procedural comments, such as volunteering to review, indicating that you second the proposal (or third, etc), or raising a concern that you would like to be addressed.