Skip to content

Commit 577c642

Browse files
committed
threads: add feature flags
This adds both the Cargo-level and CLI-level flags for the shared-everything-threads proposal.
1 parent 62fa364 commit 577c642

File tree

7 files changed

+28
-0
lines changed

7 files changed

+28
-0
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,7 @@ coredump = ["wasmtime-cli-flags/coredump"]
493493
addr2line = ["wasmtime/addr2line"]
494494
debug-builtins = ["wasmtime/debug-builtins"]
495495
threads = ["wasmtime-cli-flags/threads"]
496+
shared-everything-threads = ["wasmtime-cli-flags/shared-everything-threads"]
496497
gc = ["wasmtime-cli-flags/gc", "wasmtime/gc"]
497498
gc-drc = ["gc", "wasmtime/gc-drc", "wasmtime-cli-flags/gc-drc"]
498499
gc-null = ["gc", "wasmtime/gc-null", "wasmtime-cli-flags/gc-null"]

crates/cli-flags/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,6 @@ gc = ["wasmtime/gc"]
3737
gc-drc = ["gc", "wasmtime/gc-drc"]
3838
gc-null = ["gc", "wasmtime/gc-null"]
3939
threads = ["wasmtime/threads"]
40+
shared-everything-threads = ["wasmtime/shared-everything-threads"]
4041
memory-protection-keys = ["wasmtime/memory-protection-keys"]
4142
pulley = ["wasmtime/pulley"]

crates/cli-flags/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,8 @@ wasmtime_option_group! {
358358
pub tail_call: Option<bool>,
359359
/// Configure support for the threads proposal.
360360
pub threads: Option<bool>,
361+
/// Configure support for the shared-everything-threads proposal.
362+
pub shared_everything_threads: Option<bool>,
361363
/// Configure support for the memory64 proposal.
362364
pub memory64: Option<bool>,
363365
/// Configure support for the component-model proposal.
@@ -1014,6 +1016,7 @@ impl CommonOptions {
10141016
("component-model-async", component_model_async_builtins, wasm_component_model_async_builtins)
10151017
("component-model-async", component_model_async_stackful, wasm_component_model_async_stackful)
10161018
("threads", threads, wasm_threads)
1019+
("shared-everything-threads", shared_everything_threads, wasm_shared_everything_threads)
10171020
("gc", gc, wasm_gc)
10181021
("gc", reference_types, wasm_reference_types)
10191022
("gc", function_references, wasm_function_references)

crates/cranelift/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,4 @@ gc = ["wasmtime-environ/gc"]
4646
gc-drc = ["gc", "wasmtime-environ/gc-drc"]
4747
gc-null = ["gc", "wasmtime-environ/gc-null"]
4848
threads = ["wasmtime-environ/threads"]
49+
shared-everything-threads = ["wasmtime-environ/shared-everything-threads"]

crates/environ/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ compile = [
7070
"dep:wasmprinter",
7171
]
7272
threads = ['std']
73+
shared-everything-threads = ['std']
7374
wmemcheck = ['std']
7475
std = [
7576
'anyhow/std',

crates/wasmtime/Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,12 @@ threads = [
309309
"std",
310310
]
311311

312+
# Enable runtime support for the WebAssembly shared-everything-threads proposal.
313+
shared-everything-threads = [
314+
"wasmtime-cranelift?/shared-everything-threads",
315+
"std",
316+
]
317+
312318
# Controls whether backtraces will attempt to parse DWARF information in
313319
# WebAssembly modules and components to provide filenames and line numbers in
314320
# stack traces.

crates/wasmtime/src/config.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -848,6 +848,21 @@ impl Config {
848848
self
849849
}
850850

851+
/// Configures whether the WebAssembly [shared-everything-threads] proposal
852+
/// will be enabled for compilation.
853+
///
854+
/// This feature gates extended use of the `shared` attribute on items other
855+
/// than memories, extra atomic instructions, and new component model
856+
/// intrinsics for spawning threads. It depends on the
857+
/// [`wasm_threads`][Self::wasm_threads] being enabled.
858+
///
859+
/// [shared-everything-threads]:
860+
/// https://github.com/webassembly/shared-everything-threads
861+
pub fn wasm_shared_everything_threads(&mut self, enable: bool) -> &mut Self {
862+
self.wasm_feature(WasmFeatures::SHARED_EVERYTHING_THREADS, enable);
863+
self
864+
}
865+
851866
/// Configures whether the [WebAssembly reference types proposal][proposal]
852867
/// will be enabled for compilation.
853868
///

0 commit comments

Comments
 (0)