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

Promote wasm32-wasip2 to a Tier 2 target #760

Closed
1 of 3 tasks
alexcrichton opened this issue Jun 13, 2024 · 7 comments
Closed
1 of 3 tasks

Promote wasm32-wasip2 to a Tier 2 target #760

alexcrichton opened this issue Jun 13, 2024 · 7 comments
Labels
major-change A proposal to make a major change to rustc major-change-accepted A major change proposal that was accepted T-compiler Add this label so rfcbot knows to poll the compiler team

Comments

@alexcrichton
Copy link
Member

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:

  • A custom linker, wasm-component-ld, is required
  • A sysroot of wasi-libc is required

It 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 adding wasm32-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 targets

The 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. The wasm32-wasip2 Rust target will provide access via the standard library to appropriate WASI interfaces. The best example of this is that the wasm32-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 that std::net works with the wasm32-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 for wasm32-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 the gcc-ld folder alongside the preexisting wasm-ld binary. The source of wasm-component-ld is intended to be modest where it's a wrapper around two pieces of functionality: the wasm-ld linker itself and the wit_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 the wasi-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 contains fn main() { ... }. This would be pulled in as a dependency as part of src/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):

A tier 2 target must have value to people other than its maintainers

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.

A tier 2 target must have a designated team of developers

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.

The target must not place undue burden on Rust developers not specifically concerned with that target.

This target will not have any more significant burden than the preexisting wasm32-wasip1 target. The wasm32-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.

The target must provide documentation for the Rust community explaining how to build for the target using cross-compilation, and explaining how to run tests for the target

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 example cargo component will be updated to use this target when it's available.

The target must document its baseline expectations for the features or versions of CPUs, operating systems, libraries, runtime environments, and similar.

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.

Tier 2 targets must not leave any significant portions of core or the standard library unimplemented or stubbed out, unless they cannot possibly be supported on the target.

This target will primarily omit the std::thread module when it is introduced. Not supporting std::thread matches wasm32-wasip1 and is generally not possible today. Work is happening within the component model and WebAssembly itself to eventually support threads.

If the target supports C code, and the target has an interoperable calling convention for C code

The wasm32-wasip2 is intended to interoperate with C code and this is tested in CI for wasm32-wasip1 and will be exercised in community crates.

The approving teams may additionally require that a subset of tests pass in CI, such as enough to build a functional "hello world" program

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 of wasm32-wasip1 to wasm32-wasip2 as it contains the ability to run networking tests (std::net). This will take time to implement, however.

Building the target in CI must not take substantially longer than the current slowest target in CI, and should not substantially raise the maintenance burden of the CI infrastructure

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 the dist-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.

Tier 2 targets must not impose burden on the authors of pull requests, or other developers in the community, to ensure that tests pass for the target

I recently migrated testing of WebAssembly on CI from wasm32-unknown-unknown to wasm32-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 time wasm32-wasip2 is not expected to move the needle here much relative to the current state.

The target maintainers should regularly run the testsuite for the target, and should fix any test failures in a reasonably timely fashion.

Given the similarities of the wasm32-wasip1 and wasm32-wasip2 targets I wasn't planning for this at this time. My hope would be that the testing of wasm32-wasip1 is sufficient until the point at which wasm32-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:

  • File an issue describing the proposal.
  • A compiler team member or contributor who is knowledgeable in the area can second by writing @rustbot second.
    • Finding a "second" suffices for internal changes. If however, you are proposing a new public-facing feature, such as a -C flag, then full team check-off is required.
    • Compiler team members can initiate a check-off via @rfcbot fcp merge on either the MCP or the PR.
  • Once an MCP is seconded, the Final Comment Period begins. If no objections are raised after 10 days, the MCP is considered approved.

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.

@alexcrichton alexcrichton added major-change A proposal to make a major change to rustc T-compiler Add this label so rfcbot knows to poll the compiler team labels Jun 13, 2024
@rustbot
Copy link
Collaborator

rustbot commented Jun 13, 2024

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

@rustbot rustbot added the to-announce Announce this issue on triage meeting label Jun 13, 2024
@apiraino apiraino removed the to-announce Announce this issue on triage meeting label Jun 14, 2024
@sunfishcode
Copy link
Member

sunfishcode commented Jun 14, 2024

Edit: Moved to the zulip thread.

@syrusakbary
Copy link

syrusakbary commented Jun 18, 2024

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!

@alexcrichton
Copy link
Member Author

alexcrichton commented Jun 18, 2024

@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

@syrusakbary
Copy link

syrusakbary commented Jun 19, 2024

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

@davidtwco
Copy link
Member

@rustbot second

@rustbot rustbot added the final-comment-period The FCP has started, most (if not all) team members are in agreement label Jun 24, 2024
alexcrichton added a commit to alexcrichton/rust that referenced this issue Jun 25, 2024
This commit promotes the `wasm32-wasip2` Rust target to tier 2 as
proposed in rust-lang/compiler-team#760. There are two major changes in
this PR:

1. The `dist-various-2` container, which already produces the other WASI
   targets, now has an extra target added for `wasm32-wasip2`.
2. A new `wasm-component-ld` binary is added to all host toolchains when
   LLD is enabled. This is the linker used for the `wasm32-wasip2` target.

This new linker is added for all host toolchains to ensure that all host
toolchains can produce the `wasm32-wasip2` target. This is similar to
how `rust-lld` was originally included for all host toolchains to be
able to produce WebAssembly output when the targets were first added.
The new linker is developed [here][wasm-component-ld] and is pulled in
via a crates.io-based dependency to the tree here.

[wasm-component-ld]: https://github.com/bytecodealliance/wasm-component-ld
@apiraino
Copy link
Contributor

apiraino commented Jul 8, 2024

@rustbot label -final-comment-period +major-change-accepted

@apiraino apiraino closed this as completed Jul 8, 2024
@rustbot rustbot added major-change-accepted A major change proposal that was accepted to-announce Announce this issue on triage meeting and removed final-comment-period The FCP has started, most (if not all) team members are in agreement labels Jul 8, 2024
alexcrichton added a commit to alexcrichton/rust that referenced this issue Jul 9, 2024
This commit promotes the `wasm32-wasip2` Rust target to tier 2 as
proposed in rust-lang/compiler-team#760. There are two major changes in
this PR:

1. The `dist-various-2` container, which already produces the other WASI
   targets, now has an extra target added for `wasm32-wasip2`.
2. A new `wasm-component-ld` binary is added to all host toolchains when
   LLD is enabled. This is the linker used for the `wasm32-wasip2` target.

This new linker is added for all host toolchains to ensure that all host
toolchains can produce the `wasm32-wasip2` target. This is similar to
how `rust-lld` was originally included for all host toolchains to be
able to produce WebAssembly output when the targets were first added.
The new linker is developed [here][wasm-component-ld] and is pulled in
via a crates.io-based dependency to the tree here.

[wasm-component-ld]: https://github.com/bytecodealliance/wasm-component-ld
@apiraino apiraino removed the to-announce Announce this issue on triage meeting label Jul 11, 2024
workingjubilee added a commit to workingjubilee/rustc that referenced this issue Jul 13, 2024
… r=Mark-Simulacrum

Promote the `wasm32-wasip2` target to Tier 2

This commit promotes the `wasm32-wasip2` Rust target to tier 2 as proposed in rust-lang/compiler-team#760. There are two major changes in this PR:

1. The `dist-various-2` container, which already produces the other WASI targets, now has an extra target added for `wasm32-wasip2`.
2. A new `wasm-component-ld` binary is added to all host toolchains when LLD is enabled. This is the linker used for the `wasm32-wasip2` target.

This new linker is added for all host toolchains to ensure that all host toolchains can produce the `wasm32-wasip2` target. This is similar to how `rust-lld` was originally included for all host toolchains to be able to produce WebAssembly output when the targets were first added. The new linker is developed [here][wasm-component-ld] and is pulled in via a crates.io-based dependency to the tree here.

[wasm-component-ld]: https://github.com/bytecodealliance/wasm-component-ld
workingjubilee added a commit to workingjubilee/rustc that referenced this issue Jul 13, 2024
… r=Mark-Simulacrum

Promote the `wasm32-wasip2` target to Tier 2

This commit promotes the `wasm32-wasip2` Rust target to tier 2 as proposed in rust-lang/compiler-team#760. There are two major changes in this PR:

1. The `dist-various-2` container, which already produces the other WASI targets, now has an extra target added for `wasm32-wasip2`.
2. A new `wasm-component-ld` binary is added to all host toolchains when LLD is enabled. This is the linker used for the `wasm32-wasip2` target.

This new linker is added for all host toolchains to ensure that all host toolchains can produce the `wasm32-wasip2` target. This is similar to how `rust-lld` was originally included for all host toolchains to be able to produce WebAssembly output when the targets were first added. The new linker is developed [here][wasm-component-ld] and is pulled in via a crates.io-based dependency to the tree here.

[wasm-component-ld]: https://github.com/bytecodealliance/wasm-component-ld
bors added a commit to rust-lang-ci/rust that referenced this issue Jul 14, 2024
…=Mark-Simulacrum

Promote the `wasm32-wasip2` target to Tier 2

This commit promotes the `wasm32-wasip2` Rust target to tier 2 as proposed in rust-lang/compiler-team#760. There are two major changes in this PR:

1. The `dist-various-2` container, which already produces the other WASI targets, now has an extra target added for `wasm32-wasip2`.
2. A new `wasm-component-ld` binary is added to all host toolchains when LLD is enabled. This is the linker used for the `wasm32-wasip2` target.

This new linker is added for all host toolchains to ensure that all host toolchains can produce the `wasm32-wasip2` target. This is similar to how `rust-lld` was originally included for all host toolchains to be able to produce WebAssembly output when the targets were first added. The new linker is developed [here][wasm-component-ld] and is pulled in via a crates.io-based dependency to the tree here.

[wasm-component-ld]: https://github.com/bytecodealliance/wasm-component-ld
tgross35 added a commit to tgross35/rust that referenced this issue Jul 16, 2024
… r=Mark-Simulacrum

Promote the `wasm32-wasip2` target to Tier 2

This commit promotes the `wasm32-wasip2` Rust target to tier 2 as proposed in rust-lang/compiler-team#760. There are two major changes in this PR:

1. The `dist-various-2` container, which already produces the other WASI targets, now has an extra target added for `wasm32-wasip2`.
2. A new `wasm-component-ld` binary is added to all host toolchains when LLD is enabled. This is the linker used for the `wasm32-wasip2` target.

This new linker is added for all host toolchains to ensure that all host toolchains can produce the `wasm32-wasip2` target. This is similar to how `rust-lld` was originally included for all host toolchains to be able to produce WebAssembly output when the targets were first added. The new linker is developed [here][wasm-component-ld] and is pulled in via a crates.io-based dependency to the tree here.

[wasm-component-ld]: https://github.com/bytecodealliance/wasm-component-ld
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Jul 17, 2024
Rollup merge of rust-lang#126967 - alexcrichton:wasm32-wasip2-tier-2, r=Mark-Simulacrum

Promote the `wasm32-wasip2` target to Tier 2

This commit promotes the `wasm32-wasip2` Rust target to tier 2 as proposed in rust-lang/compiler-team#760. There are two major changes in this PR:

1. The `dist-various-2` container, which already produces the other WASI targets, now has an extra target added for `wasm32-wasip2`.
2. A new `wasm-component-ld` binary is added to all host toolchains when LLD is enabled. This is the linker used for the `wasm32-wasip2` target.

This new linker is added for all host toolchains to ensure that all host toolchains can produce the `wasm32-wasip2` target. This is similar to how `rust-lld` was originally included for all host toolchains to be able to produce WebAssembly output when the targets were first added. The new linker is developed [here][wasm-component-ld] and is pulled in via a crates.io-based dependency to the tree here.

[wasm-component-ld]: https://github.com/bytecodealliance/wasm-component-ld
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
major-change A proposal to make a major change to rustc major-change-accepted A major change proposal that was accepted T-compiler Add this label so rfcbot knows to poll the compiler team
Projects
None yet
Development

No branches or pull requests

6 participants