-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #122170 - alexcrichton:rename-wasi-threads, r=petrochenkov
Rename `wasm32-wasi-preview1-threads` to `wasm32-wasip1-threads` This commit renames the current `wasm32-wasi-preview1-threads` target to `wasm32-wasip1-threads`. The need for this rename is a bit unfortunate as the previous name was chosen in an attempt to be future-compatible with other WASI targets. Originally this target was proposed to be `wasm32-wasi-threads`, and that's what was originally implemented in wasi-sdk as well. After discussion though and with the plans for the upcoming component-model target (now named `wasm32-wasip2`) the "preview1" naming was chosen for the threads-based target. The WASI subgroup later decided that it was time to drop the "preview" terminology and recommends "pX" instead, hence previous PRs to add `wasm32-wasip2` and rename `wasm32-wasi` to `wasm32-wasip1`. So, with all that history, the "proper name" for this target is different than its current name, so one way or another a rename is required. This PR proposes renaming this target cold-turkey, unlike `wasm32-wasi` which is having a long transition period to change its name. The threads-based target is predicted to see only a fraction of the traffic of `wasm32-wasi` due to the unstable nature of the WASI threads proposal itself. While I was here I updated the in-tree documentation in the target spec file itself as most of the documentation was copied from the original WASI target and wasn't as applicable to this target. Also, as an aside, I can at least try to apologize for all the naming confusion here, but this is hopefully the last WASI-related rename.
- Loading branch information
Showing
12 changed files
with
107 additions
and
169 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
139 changes: 0 additions & 139 deletions
139
compiler/rustc_target/src/spec/targets/wasm32_wasi_preview1_threads.rs
This file was deleted.
Oops, something went wrong.
74 changes: 74 additions & 0 deletions
74
compiler/rustc_target/src/spec/targets/wasm32_wasip1_threads.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
//! The `wasm32-wasip1-threads` target is an extension of the `wasm32-wasip1` | ||
//! target where threads are enabled by default for all crates. This target | ||
//! should be considered "in flux" as WASI itself has moved on from "p1" to "p2" | ||
//! now and threads in "p2" are still under heavy design. | ||
//! | ||
//! This target inherits most of the other aspects of `wasm32-wasip1`. | ||
//! | ||
//! Historically this target was known as `wasm32-wasi-preview1-threads`. | ||
use crate::spec::{base, crt_objects, Cc, LinkSelfContainedDefault, LinkerFlavor, Target}; | ||
|
||
pub fn target() -> Target { | ||
let mut options = base::wasm::options(); | ||
|
||
options.os = "wasi".into(); | ||
|
||
options.add_pre_link_args( | ||
LinkerFlavor::WasmLld(Cc::No), | ||
&["--import-memory", "--export-memory", "--shared-memory"], | ||
); | ||
options.add_pre_link_args( | ||
LinkerFlavor::WasmLld(Cc::Yes), | ||
&[ | ||
"--target=wasm32-wasip1-threads", | ||
"-Wl,--import-memory", | ||
"-Wl,--export-memory,", | ||
"-Wl,--shared-memory", | ||
], | ||
); | ||
|
||
options.pre_link_objects_self_contained = crt_objects::pre_wasi_self_contained(); | ||
options.post_link_objects_self_contained = crt_objects::post_wasi_self_contained(); | ||
|
||
// FIXME: Figure out cases in which WASM needs to link with a native toolchain. | ||
options.link_self_contained = LinkSelfContainedDefault::True; | ||
|
||
// Right now this is a bit of a workaround but we're currently saying that | ||
// the target by default has a static crt which we're taking as a signal | ||
// for "use the bundled crt". If that's turned off then the system's crt | ||
// will be used, but this means that default usage of this target doesn't | ||
// need an external compiler but it's still interoperable with an external | ||
// compiler if configured correctly. | ||
options.crt_static_default = true; | ||
options.crt_static_respected = true; | ||
|
||
// Allow `+crt-static` to create a "cdylib" output which is just a wasm file | ||
// without a main function. | ||
options.crt_static_allows_dylibs = true; | ||
|
||
// WASI's `sys::args::init` function ignores its arguments; instead, | ||
// `args::args()` makes the WASI API calls itself. | ||
options.main_needs_argc_argv = false; | ||
|
||
// And, WASI mangles the name of "main" to distinguish between different | ||
// signatures. | ||
options.entry_name = "__main_void".into(); | ||
|
||
options.singlethread = false; | ||
options.features = "+atomics,+bulk-memory,+mutable-globals".into(); | ||
|
||
Target { | ||
llvm_target: "wasm32-wasi".into(), | ||
metadata: crate::spec::TargetMetadata { | ||
description: None, | ||
tier: None, | ||
host_tools: None, | ||
std: None, | ||
}, | ||
pointer_width: 32, | ||
data_layout: "e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-n32:64-S128-ni:1:10:20".into(), | ||
arch: "wasm32".into(), | ||
options, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.