-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Provide cabi_realloc on wasm32-wasip2 by default #122411
Provide cabi_realloc on wasm32-wasip2 by default #122411
Conversation
cc @sunfishcode and @rylev I've tested this locally where the wit-bindgen test suite passes with the |
This commit adds some initial support for `wasm32-wasip2` in `wit-bindgen`. Everything works as-is but one of the benefits of a new target is that we can move runtime bits such as `cabi_realloc` into the standard library rather than in this crate. This PR sets up infrastructure to test the `wasm32-wasip2` target and additionally assumes rust-lang/rust#122411 for providing the implementation of `cabi_realloc`.
} else if #[cfg(all(target_os = "wasi", target_env = "p2"))] { | ||
mod wasip2; | ||
pub use self::wasip2::*; | ||
} else if #[cfg(target_os = "wasi")] { | ||
mod wasi; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make sense to rename this module to wasip1
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point! I'll do that as a follow-up
☔ The latest upstream changes (presumably #122423) made this pull request unmergeable. Please resolve the merge conflicts. |
The ordering of targets in `pal/mod.rs` did not end up using the wasip2 implementation, so after reordering that I've edited the implementation to compile correctly.
This commit provides a component model intrinsic in the standard library by default on the `wasm32-wasip2` target. This intrinsic is not required by the component model itself but is quite common to use, for example it's needed if a wasm module receives a string or a list. The intention of this commit is to provide an overridable definition in the standard library through a weak definition of this function. That means that downstream crates can provide their own customized and more specific versions if they'd like, but the standard library's version should suffice for general-purpose use.
47db843
to
5af8187
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I mentioned above, it's inconvenient that this cabi_realloc
isn't available for no_std
builds, however there are alternatives if we use Nightly Rust, so we can revisit this later if needed.
This commit adds some initial support for `wasm32-wasip2` in `wit-bindgen`. Everything works as-is but one of the benefits of a new target is that we can move runtime bits such as `cabi_realloc` into the standard library rather than in this crate. This PR sets up infrastructure to test the `wasm32-wasip2` target and additionally assumes rust-lang/rust#122411 for providing the implementation of `cabi_realloc`.
Is this stuck? Might it need a "bors r+" to get it into the queue or is Bors meant to pick up review approvals now? |
Ah while @rylev and @sunfishcode and I are all stakeholders on the wasm32-wasip2 target I'm not sure any of us have r+ permissions, so we'll need someone else to tell bors this is ready I think. |
Looks like we might need @m-ou-se to reroll the review. |
@bors r+ |
…kingjubilee Rollup of 4 pull requests Successful merges: - rust-lang#122411 ( Provide cabi_realloc on wasm32-wasip2 by default ) - rust-lang#123349 (Fix capture analysis for by-move closure bodies) - rust-lang#123359 (Link against libc++abi and libunwind as well when building LLVM wrappers on AIX) - rust-lang#123388 (use a consistent style for links) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#122411 - alexcrichton:wasm32-wasip2-cabi-realloc, r=m-ou-se Provide cabi_realloc on wasm32-wasip2 by default This commit provides a component model intrinsic in the standard library by default on the `wasm32-wasip2` target. This intrinsic is not required by the component model itself but is quite common to use, for example it's needed if a wasm module receives a string or a list. The intention of this commit is to provide an overridable definition in the standard library through a weak definition of this function. That means that downstream crates can provide their own customized and more specific versions if they'd like, but the standard library's version should suffice for general-purpose use.
This commit adds some initial support for `wasm32-wasip2` in `wit-bindgen`. Everything works as-is but one of the benefits of a new target is that we can move runtime bits such as `cabi_realloc` into the standard library rather than in this crate. This PR sets up infrastructure to test the `wasm32-wasip2` target and additionally assumes rust-lang/rust#122411 for providing the implementation of `cabi_realloc`.
This commit provides a component model intrinsic in the standard library
by default on the
wasm32-wasip2
target. This intrinsic is notrequired by the component model itself but is quite common to use, for
example it's needed if a wasm module receives a string or a list.
The intention of this commit is to provide an overridable definition in
the standard library through a weak definition of this function. That
means that downstream crates can provide their own customized and more
specific versions if they'd like, but the standard library's version
should suffice for general-purpose use.