Skip to main content

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.
6
7use crate::spec::{Cc, Env, LinkerFlavor, Target, add_link_args};
8
9pub(crate) fn target() -> Target {
10    // For now wasip3 is a lightly-edited wasip2 target.
11    let mut target = super::wasm32_wasip2::target();
12    target.llvm_target = "wasm32-wasip3".into();
13    target.metadata = crate::spec::TargetMetadata {
14        description: Some("WebAssembly".into()),
15        tier: Some(2),
16        host_tools: Some(false),
17        std: Some(true),
18    };
19    target.options.env = Env::P3;
20
21    add_link_args(
22        &mut target.pre_link_args,
23        LinkerFlavor::WasmLld(Cc::No),
24        &[
25            // The `--cooperative-threading` flag to the linker dictates the ABI
26            // that's being used on this target which is to store the stack
27            // pointer in a component model intrinsic location, for example,
28            // rather than a wasm global.
29            //
30            // Note that this is only specified for `Cc::No`, because when
31            // `clang` is being used as a linker it'll already pass this.
32            "--cooperative-threading",
33            // This is used as the wasi-libc-defined symbol here is required for
34            // this target to function. The Rust compiler's symbol exports
35            // otherwise don't know about this symbol so it's manually exported
36            // here.
37            //
38            // Note that this additionally is only specified for `Cc::No`
39            // because when `clang` is used the symbol exports happen naturally
40            // and this isn't needed.
41            "--export-if-defined=__wasm_task_hook",
42        ],
43    );
44
45    target
46}