Skip to content

Commit 5701dd0

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 48fe3bb commit 5701dd0

File tree

7 files changed

+28
-0
lines changed

7 files changed

+28
-0
lines changed

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,7 @@ coredump = ["wasmtime-cli-flags/coredump"]
479479
addr2line = ["wasmtime/addr2line"]
480480
debug-builtins = ["wasmtime/debug-builtins"]
481481
threads = ["wasmtime-cli-flags/threads"]
482+
shared-everything-threads = ["wasmtime-cli-flags/shared-everything-threads"]
482483
gc = ["wasmtime-cli-flags/gc", "wasmtime/gc"]
483484
gc-drc = ["gc", "wasmtime/gc-drc", "wasmtime-cli-flags/gc-drc"]
484485
gc-null = ["gc", "wasmtime/gc-null", "wasmtime-cli-flags/gc-null"]

crates/cli-flags/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,6 @@ gc = ["wasmtime/gc"]
3838
gc-drc = ["gc", "wasmtime/gc-drc"]
3939
gc-null = ["gc", "wasmtime/gc-null"]
4040
threads = ["wasmtime/threads"]
41+
shared-everything-threads = ["wasmtime/shared-everything-threads"]
4142
memory-protection-keys = ["wasmtime/memory-protection-keys"]
4243
pulley = ["wasmtime/pulley"]

crates/cli-flags/src/lib.rs

+3
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.
@@ -995,6 +997,7 @@ impl CommonOptions {
995997
("component-model", component_model_multiple_returns, wasm_component_model_multiple_returns)
996998
("component-model-async", component_model_async, wasm_component_model_async)
997999
("threads", threads, wasm_threads)
1000+
("shared-everything-threads", shared_everything_threads, wasm_shared_everything_threads)
9981001
("gc", gc, wasm_gc)
9991002
("gc", reference_types, wasm_reference_types)
10001003
("gc", function_references, wasm_function_references)

crates/cranelift/Cargo.toml

+1
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

+1
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ compile = [
6565
"dep:wasmprinter",
6666
]
6767
threads = ['std']
68+
shared-everything-threads = ['std']
6869
wmemcheck = ['std']
6970
std = [
7071
'anyhow/std',

crates/wasmtime/Cargo.toml

+6
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

+15
Original file line numberDiff line numberDiff line change
@@ -849,6 +849,21 @@ impl Config {
849849
self
850850
}
851851

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

0 commit comments

Comments
 (0)