Repository: bytecodealliance/wasmtime
Pull request #5298 (2022-11-18 19:52:11)

c-api: add wasm_config_parallel_compilation_set
This has not been discussed in issues and I do not believe there are tests cases for the config C API. Nevertheless, could we add this flag in the C API with this small changeset?

github-actions[bot]: #### Subscribe to Label Action

cc @peterhuene

<details>
This issue or pull request has been labeled: "wasmtime:c-api"

Thus the following users have been cc'd because of the following labels:

* peterhuene: wasmtime:c-api

To subscribe or unsubscribe from this label, edit the <code>.github/subscribe-to-label.json</code> configuration file.

[Learn more.](https://github.com/bytecodealliance/subscribe-to-label-action)
</details>
github-actions[bot]: #### Subscribe to Label Action

cc @peterhuene

<details>
This issue or pull request has been labeled: "wasmtime:api", "wasmtime:config"

Thus the following users have been cc'd because of the following labels:

* peterhuene: wasmtime:api

To subscribe or unsubscribe from this label, edit the <code>.github/subscribe-to-label.json</code> configuration file.

[Learn more.](https://github.com/bytecodealliance/subscribe-to-label-action)
</details>
github-actions[bot]: #### Label Messager: wasmtime:config

It looks like you are changing Wasmtime's configuration options. Make sure to
complete this check list:

* [ ] If you added a new `Config` method, you wrote extensive documentation for
      it.

  <details>

  Our documentation should be of the following form:

  ```text
  Short, simple summary sentence.

  More details. These details can be multiple paragraphs. There should be
  information about not just the method, but its parameters and results as
  well.

  Is this method fallible? If so, when can it return an error?

  Can this method panic? If so, when does it panic?

  # Example

  Optional example here.
  ```

  </details>

* [ ] If you added a new `Config` method, or modified an existing one, you
  ensured that this configuration is exercised by the fuzz targets.

  <details>

  For example, if you expose a new strategy for allocating the next instance
  slot inside the pooling allocator, you should ensure that at least one of our
  fuzz targets exercises that new strategy.

  Often, all that is required of you is to ensure that there is a knob for this
  configuration option in [`wasmtime_fuzzing::Config`][fuzzing-config] (or one
  of its nested `struct`s).

  Rarely, this may require authoring a new fuzz target to specifically test this
  configuration. See [our docs on fuzzing][fuzzing-docs] for more details.

  </details>

* [ ] If you are enabling a configuration option by default, make sure that it
  has been fuzzed for at least two weeks before turning it on by default.

[fuzzing-config]: https://github.com/bytecodealliance/wasmtime/blob/ca0e8d0a1d8cefc0496dba2f77a670571d8fdcab/crates/fuzzing/src/generators.rs#L182-L194
[fuzzing-docs]: https://docs.wasmtime.dev/contributing-fuzzing.html


--------------------------------------------------------------------------------

<details>

To modify this label's message, edit the <code>.github/label-messager/wasmtime-config.md</code> file.

To add new label messages or remove existing label messages, edit the
<code>.github/label-messager.json</code> configuration file.

[Learn more.](https://github.com/bytecodealliance/label-messager-action)

</details>
thibaultcha: Can we restart the CI on this one? I don't think the failures are related; and we'd really like this being part of the next release if possible so that we don't lag too far behind the latest Wasmtime version...
alexcrichton: Oh sorry missed the updates here, could you try rebasing? That known flaky test has been fixed on `main`
thibaultcha: Ah, excellent, done!

Patch:
diff --git a/Cargo.toml b/Cargo.toml
index e42e094ae..c3cbe1ef9 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -56,7 +56,7 @@ wast = { workspace = true }
 criterion = "0.3.4"
 num_cpus = "1.13.0"
 memchr = "2.4"
-async-trait = "0.1"
+async-trait = { workspace = true }
 wat = { workspace = true }
 rayon = "1.5.0"
 wasmtime-wast = { workspace = true, features = ['component-model'] }
@@ -171,8 +171,14 @@ gimli = { version = "0.26.0", default-features = false, features = ['read', 'std
 clap = { version = "3.2.0", features = ["color", "suggestions", "derive"] }
 hashbrown = "0.12"
 cap-std = "1.0.0"
+cap-rand = "1.0.0"
 once_cell = "1.12.0"
 smallvec = { version = "1.6.1", features = ["union"] }
+io-lifetimes = { version = "1.0.0", default-features = false }
+tracing = "0.1.26"
+bitflags = "1.2"
+thiserror = "1.0.15"
+async-trait = "0.1.42"
 
 [features]
 default = [
diff --git a/cranelift/Cargo.toml b/cranelift/Cargo.toml
index 9f8b1d880..5f7db1b71 100644
--- a/cranelift/Cargo.toml
+++ b/cranelift/Cargo.toml
@@ -42,7 +42,7 @@ target-lexicon = { workspace = true, features = ["std"] }
 pretty_env_logger = "0.4.0"
 rayon = { version = "1", optional = true }
 indicatif = "0.13.0"
-thiserror = "1.0.15"
+thiserror = { workspace = true }
 walkdir = "2.2"
 anyhow = { workspace = true }
 clap = { workspace = true }
diff --git a/cranelift/interpreter/Cargo.toml b/cranelift/interpreter/Cargo.toml
index a90e09852..e74ce5c37 100644
--- a/cranelift/interpreter/Cargo.toml
+++ b/cranelift/interpreter/Cargo.toml
@@ -15,7 +15,7 @@ cranelift-codegen = { workspace = true }
 cranelift-entity = { workspace = true }
 log = { workspace = true }
 smallvec = { workspace = true }
-thiserror = "1.0.15"
+thiserror = { workspace = true }
 
 [target.x86_64-pc-windows-gnu.dependencies]
 libm = "0.2.4"
diff --git a/crates/c-api/include/wasmtime/config.h b/crates/c-api/include/wasmtime/config.h
index 77c119363..951004e96 100644
--- a/crates/c-api/include/wasmtime/config.h
+++ b/crates/c-api/include/wasmtime/config.h
@@ -200,6 +200,14 @@ WASMTIME_CONFIG_PROP(void, wasm_memory64, bool)
  */
 WASMTIME_CONFIG_PROP(void, strategy, wasmtime_strategy_t)
 
+/**
+ * \brief Configure wether wasmtime should compile a module using multiple threads.
+ *
+ * For more information see the Rust documentation at
+ * https://docs.wasmtime.dev/api/wasmtime/struct.Config.html#method.parallel_compilation.
+ */
+WASMTIME_CONFIG_PROP(void, parallel_compilation, bool)
+
 /**
  * \brief Configures whether Cranelift's debug verifier is enabled.
  *
diff --git a/crates/c-api/src/config.rs b/crates/c-api/src/config.rs
index ec7b86a8a..275730f23 100644
--- a/crates/c-api/src/config.rs
+++ b/crates/c-api/src/config.rs
@@ -112,6 +112,12 @@ pub extern "C" fn wasmtime_config_strategy_set(
     });
 }
 
+#[no_mangle]
+#[cfg(feature = "parallel-compilation")]
+pub extern "C" fn wasmtime_config_parallel_compilation_set(c: &mut wasm_config_t, enable: bool) {
+    c.config.parallel_compilation(enable);
+}
+
 #[no_mangle]
 pub extern "C" fn wasmtime_config_cranelift_debug_verifier_set(
     c: &mut wasm_config_t,
diff --git a/crates/cranelift/Cargo.toml b/crates/cranelift/Cargo.toml
index 94e278fcf..10455b4b5 100644
--- a/crates/cranelift/Cargo.toml
+++ b/crates/cranelift/Cargo.toml
@@ -23,7 +23,7 @@ wasmparser = { workspace = true }
 target-lexicon = { workspace = true }
 gimli = { workspace = true }
 object = { workspace = true, features = ['write'] }
-thiserror = "1.0.4"
+thiserror = { workspace = true }
 
 [features]
 all-arch = ["cranelift-codegen/all-arch"]
diff --git a/crates/environ/Cargo.toml b/crates/environ/Cargo.toml
index f615b99ae..0a15d8279 100644
--- a/crates/environ/Cargo.toml
+++ b/crates/environ/Cargo.toml
@@ -16,7 +16,7 @@ cranelift-entity = { workspace = true }
 wasmtime-types = { workspace = true }
 wasmparser = { workspace = true }
 indexmap = { version = "1.0.2", features = ["serde-1"] }
-thiserror = "1.0.4"
+thiserror = { workspace = true }
 serde = { version = "1.0.94", features = ["derive"] }
 log = { workspace = true }
 gimli = { workspace = true }
diff --git a/crates/jit/Cargo.toml b/crates/jit/Cargo.toml
index fef5bdd62..ee392be6d 100644
--- a/crates/jit/Cargo.toml
+++ b/crates/jit/Cargo.toml
@@ -14,7 +14,7 @@ edition.workspace = true
 wasmtime-environ = { workspace = true }
 wasmtime-jit-debug = { workspace = true, features = ["perf_jitdump"], optional = true }
 wasmtime-runtime = { workspace = true }
-thiserror = "1.0.4"
+thiserror = { workspace = true }
 target-lexicon = { workspace = true }
 anyhow = { workspace = true }
 cfg-if = "1.0"
diff --git a/crates/runtime/Cargo.toml b/crates/runtime/Cargo.toml
index 09084c6fe..c832707f6 100644
--- a/crates/runtime/Cargo.toml
+++ b/crates/runtime/Cargo.toml
@@ -19,7 +19,7 @@ libc = { version = "0.2.112", default-features = false }
 log = { workspace = true }
 memoffset = "0.6.0"
 indexmap = "1.0.2"
-thiserror = "1.0.4"
+thiserror = { workspace = true }
 cfg-if = "1.0"
 rand = { version = "0.8.3", features = ['small_rng'] }
 anyhow = { workspace = true }
diff --git a/crates/types/Cargo.toml b/crates/types/Cargo.toml
index 032e7017d..a94f0e22d 100644
--- a/crates/types/Cargo.toml
+++ b/crates/types/Cargo.toml
@@ -11,5 +11,5 @@ edition.workspace = true
 [dependencies]
 cranelift-entity = { workspace = true, features = ['enable-serde'] }
 serde = { version = "1.0.94", features = ["derive"] }
-thiserror = "1.0.4"
+thiserror = { workspace = true }
 wasmparser = { workspace = true }
diff --git a/crates/wasi-common/Cargo.toml b/crates/wasi-common/Cargo.toml
index e3c999922..065a03b52 100644
--- a/crates/wasi-common/Cargo.toml
+++ b/crates/wasi-common/Cargo.toml
@@ -19,13 +19,13 @@ links = "wasi-common-19"
 
 [dependencies]
 anyhow = { workspace = true }
-thiserror = "1.0"
+thiserror = { workspace = true }
 wiggle = { workspace = true }
 wasmtime = { workspace = true }
-tracing = "0.1.19"
+tracing = { workspace = true }
 cap-std = { workspace = true }
-cap-rand = "1.0.0"
-bitflags = "1.2"
+cap-rand = { workspace = true }
+bitflags = { workspace = true }
 
 [target.'cfg(unix)'.dependencies]
 rustix = { workspace = true, features = ["fs"] }
diff --git a/crates/wasi-common/cap-std-sync/Cargo.toml b/crates/wasi-common/cap-std-sync/Cargo.toml
index ceb1a8197..c2508d940 100644
--- a/crates/wasi-common/cap-std-sync/Cargo.toml
+++ b/crates/wasi-common/cap-std-sync/Cargo.toml
@@ -13,16 +13,16 @@ include = ["src/**/*", "README.md", "LICENSE" ]
 
 [dependencies]
 wasi-common = { workspace = true }
-async-trait = "0.1"
+async-trait = { workspace = true }
 anyhow = { workspace = true }
 cap-std = { workspace = true }
 cap-fs-ext = "1.0.0"
 cap-time-ext = "1.0.0"
-cap-rand = "1.0.0"
+cap-rand = { workspace = true }
 fs-set-times = "0.18.0"
 system-interface = { version = "0.25.0", features = ["cap_std_impls"] }
-tracing = "0.1.19"
-io-lifetimes = { version = "1.0.0", default-features = false }
+tracing = { workspace = true }
+io-lifetimes = { workspace = true }
 is-terminal = "0.4.0"
 
 [target.'cfg(unix)'.dependencies]
diff --git a/crates/wasi-common/tokio/Cargo.toml b/crates/wasi-common/tokio/Cargo.toml
index 5472dd02e..77130b9b8 100644
--- a/crates/wasi-common/tokio/Cargo.toml
+++ b/crates/wasi-common/tokio/Cargo.toml
@@ -17,7 +17,7 @@ wiggle = { workspace = true }
 tokio = { version = "1.8.0", features = [ "rt", "fs", "time", "io-util", "net", "io-std", "rt-multi-thread"] }
 cap-std = { workspace = true }
 anyhow = { workspace = true }
-io-lifetimes = { version = "1.0.0", default-features = false }
+io-lifetimes = { workspace = true }
 
 [target.'cfg(unix)'.dependencies]
 rustix = { workspace = true, features = ["fs"] }
diff --git a/crates/wasi-nn/Cargo.toml b/crates/wasi-nn/Cargo.toml
index c581b20a8..a778a4bf6 100644
--- a/crates/wasi-nn/Cargo.toml
+++ b/crates/wasi-nn/Cargo.toml
@@ -18,7 +18,7 @@ wiggle = { workspace = true }
 
 # These dependencies are necessary for the wasi-nn implementation:
 openvino = { version = "0.4.2", features = ["runtime-linking"] }
-thiserror = "1.0"
+thiserror = { workspace = true }
 
 [build-dependencies]
 walkdir = "2.3"
diff --git a/crates/wasmtime/Cargo.toml b/crates/wasmtime/Cargo.toml
index 74cfa8bd4..c59a17f2e 100644
--- a/crates/wasmtime/Cargo.toml
+++ b/crates/wasmtime/Cargo.toml
@@ -36,7 +36,7 @@ psm = "0.1.11"
 once_cell = { workspace = true }
 rayon = { version = "1.0", optional = true }
 object = { workspace = true }
-async-trait = { version = "0.1.51", optional = true }
+async-trait = { workspace = true, optional = true }
 encoding_rs = { version = "0.8.31", optional = true }
 
 [target.'cfg(target_os = "windows")'.dependencies.windows-sys]
diff --git a/crates/wasmtime/src/config.rs b/crates/wasmtime/src/config.rs
index 60f297cba..cc345bc7f 100644
--- a/crates/wasmtime/src/config.rs
+++ b/crates/wasmtime/src/config.rs
@@ -1275,9 +1275,11 @@ impl Config {
         Ok(self)
     }
 
-    /// Configure wether wasmtime should compile a module using multiple threads.
+    /// Configure wether wasmtime should compile a module using multiple
+    /// threads.
     ///
-    /// Disabling this will result in a single thread being used to compile the wasm bytecode.
+    /// Disabling this will result in a single thread being used to compile
+    /// the wasm bytecode.
     ///
     /// By default parallel compilation is enabled.
     #[cfg(feature = "parallel-compilation")]
diff --git a/crates/wiggle/Cargo.toml b/crates/wiggle/Cargo.toml
index db276a776..b16949e46 100644
--- a/crates/wiggle/Cargo.toml
+++ b/crates/wiggle/Cargo.toml
@@ -11,12 +11,12 @@ repository = "https://github.com/bytecodealliance/wasmtime"
 include = ["src/**/*", "README.md", "LICENSE"]
 
 [dependencies]
-thiserror = "1"
+thiserror = { workspace = true }
 witx = { path = "../wasi-common/WASI/tools/witx", version = "0.9.1", optional = true }
 wiggle-macro = { workspace = true }
-tracing = "0.1.26"
-bitflags = "1.2"
-async-trait = "0.1.42"
+tracing = { workspace = true }
+bitflags = { workspace = true }
+async-trait = { workspace = true }
 wasmtime = { workspace = true }
 anyhow = { workspace = true }
 


Test patch:
diff --git a/cranelift/filetests/Cargo.toml b/cranelift/filetests/Cargo.toml
index 7b8ce9b1d..c770d1d46 100644
--- a/cranelift/filetests/Cargo.toml
+++ b/cranelift/filetests/Cargo.toml
@@ -24,6 +24,6 @@ gimli = { workspace = true }
 log = { workspace = true }
 num_cpus = "1.8.0"
 target-lexicon = { workspace = true }
-thiserror = "1.0.15"
+thiserror = { workspace = true }
 anyhow = { workspace = true }
 similar = "2.1.0"
diff --git a/crates/wiggle/test-helpers/Cargo.toml b/crates/wiggle/test-helpers/Cargo.toml
index a09a7a510..600ac9905 100644
--- a/crates/wiggle/test-helpers/Cargo.toml
+++ b/crates/wiggle/test-helpers/Cargo.toml
@@ -17,8 +17,8 @@ wiggle = { path = "..", features = ["tracing_log"] }
 
 [dev-dependencies]
 anyhow = { workspace = true }
-thiserror = "1.0"
-tracing = "0.1.26"
+thiserror = { workspace = true }
+tracing = { workspace = true }
 tracing-subscriber = { version = "0.3.1", default-features = false, features = ['fmt'] }
 env_logger = "0.9"