Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Expose Engine::clone to c-api #8907

Merged
merged 1 commit into from
Jul 8, 2024
Merged

Conversation

CGamesPlay
Copy link
Contributor

This creates an API to allow cloning references to wasm_engine_t in the C API. This is simple in the Rust API which implements Clone, however it is not exposed to the C API.

Use case: in tree-sitter's wasm support, we create a store object and want to instantiate modules into it over the course of the object's lifetime. This requires a handle to the underlying engine, which means our store must be kept alongside a reference to the engine (since tree-sitter is a library, it doesn't want to assume a global wasm engine). This currently requires transferring ownership of the engine to the tree sitter store container, which means we can't reuse engine objects between multiple stores.

This pertains to tree-sitter/tree-sitter#3454.

@CGamesPlay CGamesPlay requested a review from a team as a code owner July 7, 2024 02:24
@CGamesPlay CGamesPlay requested review from fitzgen and removed request for a team July 7, 2024 02:24
@github-actions github-actions bot added the wasmtime:c-api Issues pertaining to the C API. label Jul 7, 2024
@@ -8,7 +8,7 @@ For more information you can find the documentation for this library
To use Wasmtime from a C or C++ project, you can use Cargo to build the Wasmtime C bindings. From the root of the Wasmtime repository, run the following command:

```
cargo build --release wasmtime-c-api
cargo build --release -p wasmtime-c-api
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! We'll need to update this documentation further nowadays because some headers are generated as part of the build now so CMake is primarily needed to get the headers right.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alexcrichton alexcrichton added this pull request to the merge queue Jul 8, 2024
Merged via the queue into bytecodealliance:main with commit 9e22c4e Jul 8, 2024
38 checks passed
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
wasmtime:c-api Issues pertaining to the C API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants