Skip to content

Commit 77b58c0

Browse files
committed
Add wasi target family
Signed-off-by: Ryan Levick <[email protected]>
1 parent 44f1dd2 commit 77b58c0

File tree

5 files changed

+14
-8
lines changed

5 files changed

+14
-8
lines changed

compiler/rustc_target/src/spec/targets/wasm32_wasi.rs

+2
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,14 @@
7373
//! you know what you're getting in to!
7474
7575
use crate::spec::crt_objects;
76+
use crate::spec::cvs;
7677
use crate::spec::LinkSelfContainedDefault;
7778
use crate::spec::{base, Cc, LinkerFlavor, Target};
7879

7980
pub fn target() -> Target {
8081
let mut options = base::wasm::options();
8182

83+
options.families = cvs!["wasm", "wasi"];
8284
options.os = "wasi".into();
8385
options.add_pre_link_args(LinkerFlavor::WasmLld(Cc::Yes), &["--target=wasm32-wasi"]);
8486

compiler/rustc_target/src/spec/targets/wasm32_wasi_preview1_threads.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,12 @@
7272
//! best we can with this target. Don't start relying on too much here unless
7373
//! you know what you're getting in to!
7474
75-
use crate::spec::{base, crt_objects, Cc, LinkSelfContainedDefault, LinkerFlavor, Target};
75+
use crate::spec::{base, crt_objects, cvs, Cc, LinkSelfContainedDefault, LinkerFlavor, Target};
7676

7777
pub fn target() -> Target {
7878
let mut options = base::wasm::options();
7979

80+
options.families = cvs!["wasm", "wasi"];
8081
options.os = "wasi".into();
8182

8283
options.add_pre_link_args(

compiler/rustc_target/src/spec/targets/wasm32_wasi_preview2.rs

+2
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,14 @@
1717
//! <https://github.com/WebAssembly/component-model>.
1818
1919
use crate::spec::crt_objects;
20+
use crate::spec::cvs;
2021
use crate::spec::LinkSelfContainedDefault;
2122
use crate::spec::{base, Target};
2223

2324
pub fn target() -> Target {
2425
let mut options = base::wasm::options();
2526

27+
options.families = cvs!["wasm", "wasi"];
2628
options.os = "wasi-preview2".into();
2729
options.linker = Some("wasm-component-ld".into());
2830

library/std/src/os/mod.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ pub mod raw;
1818
#[cfg(all(
1919
doc,
2020
any(
21-
all(target_arch = "wasm32", not(target_os = "wasi"), not(target_os = "wasi-preview2")),
21+
all(target_arch = "wasm32", not(target_family = "wasi")),
2222
all(target_vendor = "fortanix", target_env = "sgx")
2323
)
2424
))]
@@ -27,7 +27,7 @@ pub mod unix {}
2727
#[cfg(all(
2828
doc,
2929
any(
30-
all(target_arch = "wasm32", not(target_os = "wasi"), not(target_os = "wasi-preview2")),
30+
all(target_arch = "wasm32", not(target_family = "wasi")),
3131
all(target_vendor = "fortanix", target_env = "sgx")
3232
)
3333
))]
@@ -36,7 +36,7 @@ pub mod linux {}
3636
#[cfg(all(
3737
doc,
3838
any(
39-
all(target_arch = "wasm32", not(target_os = "wasi"), not(target_os = "wasi-preview2")),
39+
all(target_arch = "wasm32", not(target_family = "wasi")),
4040
all(target_vendor = "fortanix", target_env = "sgx")
4141
)
4242
))]
@@ -45,7 +45,7 @@ pub mod wasi {}
4545
#[cfg(all(
4646
doc,
4747
any(
48-
all(target_arch = "wasm32", not(target_os = "wasi"), not(target_os = "wasi-preview2")),
48+
all(target_arch = "wasm32", not(target_family = "wasi")),
4949
all(target_vendor = "fortanix", target_env = "sgx")
5050
)
5151
))]
@@ -56,7 +56,7 @@ pub mod windows {}
5656
#[cfg(not(all(
5757
doc,
5858
any(
59-
all(target_arch = "wasm32", not(target_os = "wasi"), not(target_os = "wasi-preview2")),
59+
all(target_arch = "wasm32", not(target_family = "wasi")),
6060
all(target_vendor = "fortanix", target_env = "sgx")
6161
)
6262
)))]
@@ -78,7 +78,7 @@ pub mod linux;
7878
#[cfg(not(all(
7979
doc,
8080
any(
81-
all(target_arch = "wasm32", not(target_os = "wasi"), not(target_os = "wasi-preview2")),
81+
all(target_arch = "wasm32", not(target_family = "wasi")),
8282
all(target_vendor = "fortanix", target_env = "sgx")
8383
)
8484
)))]
@@ -89,7 +89,7 @@ pub mod wasi;
8989
#[cfg(not(all(
9090
doc,
9191
any(
92-
all(target_arch = "wasm32", not(target_os = "wasi"), not(target_os = "wasi-preview2")),
92+
all(target_arch = "wasm32", not(target_family = "wasi")),
9393
all(target_vendor = "fortanix", target_env = "sgx")
9494
)
9595
)))]

src/bootstrap/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ const EXTRA_CHECK_CFGS: &[(Option<Mode>, &str, Option<&[&'static str]>)] = &[
9090
/* Extra values not defined in the built-in targets yet, but used in std */
9191
(Some(Mode::Std), "target_env", Some(&["libnx"])),
9292
(Some(Mode::Std), "target_os", Some(&["wasi-preview2"])),
93+
(Some(Mode::Std), "target_family", Some(&["wasi"])),
9394
(Some(Mode::Std), "target_arch", Some(&["spirv", "nvptx", "xtensa"])),
9495
/* Extra names used by dependencies */
9596
// FIXME: Used by serde_json, but we should not be triggering on external dependencies.

0 commit comments

Comments
 (0)