rustc_target/spec/targets/wasm32_wasip3.rs
1//! The `wasm32-wasip3` target is the next in the chain of `wasm32-wasip1`, then
2//! `wasm32-wasip2`, then WASIp3. The main feature of WASIp3 is native async
3//! support in the component model itself.
4//!
5//! Like `wasm32-wasip2` this target produces a component by default. Support
6//! for `wasm32-wasip3` is very early as of the time of this writing so
7//! components produced will still import WASIp2 APIs, but that's ok since it's
8//! all component-model-level imports anyway. Over time the imports of the
9//! standard library will change to WASIp3.
10
11use crate::spec::{Cc, Env, LinkerFlavor, Target, add_link_args};
12
13pub(crate) fn target() -> Target {
14 // As of now WASIp3 is a lightly edited wasip2 target, so start with that
15 // and this may grow over time as more features are supported.
16 let mut target = super::wasm32_wasip2::target();
17 target.llvm_target = "wasm32-wasip3".into();
18 target.metadata = crate::spec::TargetMetadata {
19 description: Some("WebAssembly".into()),
20 tier: Some(3),
21 host_tools: Some(false),
22 std: Some(true),
23 };
24 target.options.env = Env::P3;
25
26 // The `--cooperative-threading` flag to the linker dictates the ABI that's
27 // being used on this target which is to store the stack pointer in a
28 // component model intrinsic location, for example, rather than a wasm
29 // global.
30 //
31 // Note that this is only specified for `Cc::No`, because when `clang` is
32 // being used as a linker it'll already pass this.
33 add_link_args(
34 &mut target.pre_link_args,
35 LinkerFlavor::WasmLld(Cc::No),
36 &["--cooperative-threading"],
37 );
38
39 target
40}