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

Wasm value kind enum WASM_ANYREF doesn't align with Wasm C API #5082

Closed
ashtonmeuser opened this issue Sep 12, 2024 · 1 comment · Fixed by #5092
Closed

Wasm value kind enum WASM_ANYREF doesn't align with Wasm C API #5082

ashtonmeuser opened this issue Sep 12, 2024 · 1 comment · Fixed by #5092
Assignees

Comments

@ashtonmeuser
Copy link
Contributor

Describe the bug

Wasmer does not use Wasm value types as defined by the Wasm C API.

The Wasm C API defines value types as follows (source):

typedef uint8_t wasm_valkind_t;
enum wasm_valkind_enum {
  WASM_I32,
  WASM_I64,
  WASM_F32,
  WASM_F64,
  WASM_EXTERNREF = 128,
  WASM_FUNCREF,
};

Wasmer uses enum WASM_ANYREF instead of WASM_EXTERNREF as follows:

typedef uint8_t wasm_valkind_t;
enum wasm_valkind_enum {
  WASM_I32,
  WASM_I64,
  WASM_F32,
  WASM_F64,
  WASM_ANYREF = 128,
  WASM_FUNCREF,
};

This means that Wasmer can not be swapped in in place of other libraries adhering to the Wasm C API (e.g. Wasmtime). The following error is produced when compiling:

error: use of undeclared identifier 'WASM_EXTERNREF'; did you mean 'WASM_ANYREF'?
          if (results->data[i].kind == WASM_EXTERNREF) return ERR_INVALID_DATA;
                                       ^~~~~~~~~~~
                                       WASM_ANYREF

Steps to reproduce

Compile using Wasmer via the Wasm C API. Make use of WASM_EXTERNREF.

Expected behavior

Program compiles using WASM_EXTERNREF.

Actual behavior

The WASM_EXTERNREF enum is undefined.

error: use of undeclared identifier 'WASM_EXTERNREF'; did you mean 'WASM_ANYREF'?
          if (results->data[i].kind == WASM_EXTERNREF) return ERR_INVALID_DATA;
                                       ^~~~~~~~~~~
                                       WASM_ANYREF
@syrusakbary
Copy link
Member

This is indeed something to fix. Thanks for reporting @ashtonmeuser

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 a pull request may close this issue.

3 participants