Add target_env = "p1" to the wasm32-wasip1 target

This commit sets the `target_env` key for the
`wasm32-wasi{,p1,p1-threads}` targets to the string `"p1"`. This mirrors
how the `wasm32-wasip2` target has `target_env = "p2"`. The intention of
this is to more easily detect each target in downstream crates to enable
adding custom code per-target.

cc #125803
This commit is contained in:
Alex Crichton 2024-06-01 13:03:07 -07:00
parent a94483a5f2
commit 87ad80a638
5 changed files with 33 additions and 0 deletions

View File

@ -18,6 +18,7 @@ pub fn target() -> Target {
let mut options = base::wasm::options();
options.os = "wasi".into();
options.env = "p1".into();
options.add_pre_link_args(LinkerFlavor::WasmLld(Cc::Yes), &["--target=wasm32-wasi"]);
options.pre_link_objects_self_contained = crt_objects::pre_wasi_self_contained();

View File

@ -13,6 +13,7 @@ pub fn target() -> Target {
let mut options = base::wasm::options();
options.os = "wasi".into();
options.env = "p1".into();
options.add_pre_link_args(
LinkerFlavor::WasmLld(Cc::No),

View File

@ -150,3 +150,15 @@ or another engine that supports `wasi-threads` is installed and can be found in
5. Apply such [a change](https://github.com/g0djan/rust/compare/godjan/wasi-threads...g0djan:rust:godjan/wasi-run-ui-tests?expand=1) with an engine from the step 1.
6. Run `./x.py test --target wasm32-wasip1-threads tests/ui` and save the list of failed tests.
7. For both lists of failed tests run `cat list | sort > sorted_list` and compare it with `diff sorted_list1 sorted_list2`.
## Conditionally compiling code
It's recommended to conditionally compile code for this target with:
```
#[cfg(all(target_os = "wasi", target_env = "p1", target_feature = "atomics"))]
```
Prior to Rust 1.80 the `target_env = "p1"` key was not set. Currently the
`target_feature = "atomics"` is Nightly-only. Note that the precise `#[cfg]`
necessary to detect this target may change as the target becomes more stable.

View File

@ -121,3 +121,14 @@ can be tested locally, for example, with:
```text
./x.py test --target wasm32-wasip1 tests/ui
```
## Conditionally compiling code
It's recommended to conditionally compile code for this target with:
```
#[cfg(all(target_os = "wasi", target_env = "p1"))]
```
Note that the `target_env = "p1"` condition first appeared in Rust 1.80. Prior
to Rust 1.80 the `target_env` condition was not set.

View File

@ -53,3 +53,11 @@ This target is not tested in CI at this time. Locally it can be tested with a
```text
./x.py test --target wasm32-wasip2 tests/ui
```
## Conditionally compiling code
It's recommended to conditionally compile code for this target with:
```
#[cfg(all(target_os = "wasi", target_env = "p2"))]
```