Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Add support for the official Wasm C-API #1009

Merged
merged 116 commits into from
Jul 24, 2024
Merged

Add support for the official Wasm C-API #1009

merged 116 commits into from
Jul 24, 2024

Conversation

Robbepop
Copy link
Member

@Robbepop Robbepop commented May 1, 2024

Closes #922

This is going to be a larger effort and low-priority so I will be working on it from time to time.
Inspired by: https://github.com/bytecodealliance/wasmtime/tree/main/crates/c-api/

TODO

Chores

  • Doxygen Docs
  • Cmake Installation
  • CI Integration
    • Build & Install via CMake
    • Generate Doxygen Docs via CMake
    • Format C Headers via CMake
  • README

Implementation

  • wasm_config_t
  • wasm_engine_t
  • wasm_store_t
  • wasm_module_t
  • wasm_instance_t
  • wasm_trap_t
  • wasm_byte_vec_t
  • wasm_func_t
  • wasm_functype_t
  • wasm_functype_vec_t
  • wasm_table_t
  • wasm_tabletype_t
  • wasm_tabletype_vec_t
  • wasm_memory_t
  • wasm_memorytype_t
  • wasm_memorytype_vec_t
  • wasm_global_t
  • wasm_globaltype_t
  • wasm_globaltype_vec_t
  • wasm_byte_vec_t
  • wasm_extern_t
  • wasm_externtype_t
  • wasm_externtype_vec_t
  • wasm_importtype_t
  • wasm_importtype_vec_t
  • wasm_exporttype_t
  • wasm_exporttype_vec_t
  • wasm_frame_t
  • wasm_frame_vec_t
  • wasm_val_t
  • wasm_val_vec_t
  • wasm_valtype_t
  • wasm_valtype_vec_t
  • wasm_ref_t
  • wasmi_error_t

Follow-up PRs

  • wasmi_linker_t
  • wasmi_caller_t

Copy link

codecov bot commented May 1, 2024

Codecov Report

Attention: Patch coverage is 0% with 196 lines in your changes missing coverage. Please review.

Project coverage is 80.10%. Comparing base (3d7f8be) to head (a9f2524).

Files Patch % Lines
crates/c_api/src/val.rs 0.00% 34 Missing ⚠️
crates/c_api/src/types/func.rs 0.00% 18 Missing ⚠️
crates/c_api/src/types/memory.rs 0.00% 17 Missing ⚠️
crates/c_api/src/types/table.rs 0.00% 16 Missing ⚠️
crates/c_api/src/types/global.rs 0.00% 15 Missing ⚠️
crates/c_api/src/ref.rs 0.00% 14 Missing ⚠️
crates/c_api/src/func.rs 0.00% 11 Missing ⚠️
crates/c_api/src/global.rs 0.00% 11 Missing ⚠️
crates/c_api/src/memory.rs 0.00% 11 Missing ⚠️
crates/c_api/src/table.rs 0.00% 11 Missing ⚠️
... and 11 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1009      +/-   ##
==========================================
- Coverage   80.72%   80.10%   -0.63%     
==========================================
  Files         274      295      +21     
  Lines       25173    25369     +196     
==========================================
  Hits        20322    20322              
- Misses       4851     5047     +196     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Robbepop
Copy link
Member Author

We probably need to do something similar here to enable LTO builds for the artifacts later: bytecodealliance/wasmtime#7341

However, I'd put the implementation into an impl folder and use root for the wrapper crate instead of the reversed approach as taken by Wasmtime.

@Robbepop
Copy link
Member Author

This is currently blocked by Wasmi having no built-in support for Instance::new instance creation as in Wasmtime: https://docs.rs/wasmtime/23.0.1/wasmtime/struct.Instance.html#method.new

This API is mandated by the Wasm C-API.

This will fail to compile until Wasmi supports the Instance::new API as mandated by the C-API.
@Robbepop Robbepop changed the title WIP: Implement C bindings for Wasmi Implement C bindings for Wasmi Jul 23, 2024
@Robbepop Robbepop marked this pull request as ready for review July 23, 2024 15:26
@Robbepop Robbepop changed the title Implement C bindings for Wasmi Add support for the official Wasm C-API Jul 23, 2024
@Robbepop Robbepop merged commit bf4e9d0 into main Jul 24, 2024
16 of 18 checks passed
@Robbepop Robbepop deleted the rf-wasmi-capi branch July 24, 2024 10:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create C bindings for Wasmi
1 participant