Repository navigation
std: Add initial support for the wasm32-webp2 target - #165932
alexcrichton wants to merge 1 commit into
Conversation
|
These commits modify compiler targets. |
|
r? @joboet rustbot has assigned @joboet. Use Why was this reviewer chosen?The reviewer was selected based on:
|
This comment has been minimized.
This comment has been minimized.
58ad693 to
62a9399
Compare
This comment has been minimized.
This comment has been minimized.
62a9399 to
9a8a7d6
Compare
This comment has been minimized.
This comment has been minimized.
9a8a7d6 to
f6813d4
Compare
This comment has been minimized.
This comment has been minimized.
f6813d4 to
dcadc12
Compare
This comment has been minimized.
This comment has been minimized.
This commit is intended to be the initial work in adding a `wasm32-webp2` target to the Rust compiler. This has been previously approved in an [MCP/1037][mcp] and discussed on Zulip as well. This is a tier 3 target meaning that there will be no precompiled artifacts nor any testing in CI. I've locally verified that the target builds without warnings and produces components of the expected shape. In general this target is intended to be pretty similar to `target_os = "wasi"` targets. Most of the adjustments in the standard library area accounting for `target_os = "web"` next to `target_os = "wasi"`. Some minor locations differ such as randomness. Otherwise this means that the web target inherits the same general strategy of the WASI targets, which is to use `unix.rs`-style implementations in most places. This places much of the portability burden on wasi-libc which internally has `#define`s and such to use the appropriate implementation. An example of this is `clock_gettime` is used on Web and WASI targets to implement `SystemTime` and `Instant`, and internally wasi-libc implements this with either Web or WASI interfaces depending on the target. This support all requires [a minor change in the `libc` crate][libc] to support the "web" target a well, effectively turning on definitions for all wasi-libc based targets. Locally this was tested with `[patch]`, but this PR does not include that so the `wasm32-webp2` target will not be buildable as-is in-tree until the `libc` crate has a published release and rust-lang/rust updates. [mcp]: rust-lang/compiler-team#1037 [libc]: rust-lang/libc#5733
dcadc12 to
df5fdc4
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
| target_os = "web" => { | ||
| mod web; | ||
| pub use self::web::*; | ||
| } |
There was a problem hiding this comment.
I think we could just share the WASI module here...
| } | ||
| } | ||
|
|
||
| // Use the `insecure_see` import specifically for wasip2/wasip3 |
There was a problem hiding this comment.
| // Use the `insecure_see` import specifically for wasip2/wasip3 | |
| // Use the `insecure_seed` import specifically for wasip2/wasip3 |
| pub fn fill_bytes(bytes: &mut [u8]) { | ||
| bytes.copy_from_slice(&get_random_bytes(u64::try_from(bytes.len()).unwrap())); | ||
| unsafe { | ||
| __wasilibc_random(bytes.as_mut_ptr(), bytes.len()); |
There was a problem hiding this comment.
I don't really like ignoring return values in security-critical code like this, even though it certainly looks like this will never fail.
This commit is intended to be the initial work in adding a
wasm32-webp2target to the Rust compiler. This has been previously approved in an MCP/1037 and discussed on Zulip as well. This is a tier 3 target meaning that there will be no precompiled artifacts nor any testing in CI. I've locally verified that the target builds without warnings and produces components of the expected shape.In general this target is intended to be pretty similar to
target_os = "wasi"targets. Most of the adjustments in the standard library area accounting fortarget_os = "web"next totarget_os = "wasi". Some minor locations differ such as randomness. Otherwise this means that the web target inherits the same general strategy of the WASI targets, which is to useunix.rs-style implementations in most places. This places much of the portability burden on wasi-libc which internally has#defines and such to use the appropriate implementation. An example of this isclock_gettimeis used on Web and WASI targets to implementSystemTimeandInstant, and internally wasi-libc implements this with either Web or WASI interfaces depending on the target.This support all requires a minor change in the
libccrate to support the "web" target a well, effectively turning on definitions for all wasi-libc based targets. Locally this was tested with[patch], but this PR does not include that so thewasm32-webp2target will not be buildable as-is in-tree until thelibccrate has a published release and rust-lang/rust updates.