Published this today on the Rust blog: https://blog.rust-lang.org/2024/04/09/updates-to-rusts-wasi-targets.html - FYI for people here tracking Rust toolchain work
Purely out of curiosity, do you know if anybody is blogging/Tweeting/Tooting about the implementation details of Rust toolchain work as they go? I'm particularly interested in how much y'all expect to build upon wasi-libc
vs. implement directly against the WASI ABI, and how the nascent async work is likely to interact with this — e.g. everything stays on forks for now, a separate wasm32-wasip3
target ASAP, or somehow allowing tinkering with async on the wasip2 target?
:pray::man_bowing:
FWIW, I very much expect Rust's std
will continue to build upon wasi-libc
. It can't use the WASI ABI directly without sacrificing interoperability with C code, since wasi-libc
is the one responsible for mapping POSIX-style file descriptors to WASI resource handles. If Rust's std
tried to do that itself, it would end up with a mapping that's incompatible with wasi-libc
's , preventing Rust and C code from passing descriptors back and forth.
Oh, someone on Reddit asked a really good question about how to migrate existing cfg
's targeting target_os = "wasi"
to continue working on the new target: https://www.reddit.com/r/rust/comments/1f9qbpv/comment/llqyh9i/
I responded, but I'm wondering if perhaps we should file a PR to the announcement post to include this info?
This seems something other folks will start running into as well
if backwards compat is needed then target_os = "wasi", not(target_env = "p2")
will suffice
that's, however, not necessarily future-compatible with a p3, so there's a tradeoff
Alex Crichton said:
if backwards compat is needed then
target_os = "wasi", not(target_env = "p2")
will suffice
wait, can you explain why that's better than passing target_env = "p1"
?
I assume there's a reason, but not sure I get it?
oh the difference is that target_env = "p1"
was added recently, something like 1.80.0 IIRC
oh like that!
so if a crate wants to support rustc 1.79.0 and prior with p1 you can't rely on target_env = "p1"
the "official" way to select p1, however, is target_env = "p1"
for sure
wait, can't we just tell people to do
target_os = "wasi", not(target_env = "p2"), not(target_env = "p3")
for like, Ultimate Backwards Compat
(at the cost of readability I guess)
(updated the comment to include the line about backwards-compat)
oh I wouldn't recommend that
mostly b/c target_env = "p3"
doesn't actually exist yet
and it also doesn't include a theoretical target_env = "p4"
Last updated: Nov 22 2024 at 17:03 UTC