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

Emscripten bindings do not work with -sWASM_BIGINT and -sASYNCIFY #22928

Closed
sachit-wp opened this issue Nov 14, 2024 · 0 comments · Fixed by #22930
Closed

Emscripten bindings do not work with -sWASM_BIGINT and -sASYNCIFY #22928

sachit-wp opened this issue Nov 14, 2024 · 0 comments · Fixed by #22930
Assignees

Comments

@sachit-wp
Copy link

sachit-wp commented Nov 14, 2024

I am unable to successfully run emscripten bindings with WASM_BIGINT and ASYNCIFY
When asyncify is not used, everything works as expected.
For convenience purposes, here's a repo I created for trying this out: https://github.com/sachit-wp/asyncify-repro but I have also provided details below:

Version of emscripten/emsdk:

emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.71 (4171ae200b77a6c266b0e1ebb507d61d1ade3501)
clang version 20.0.0git (https:/github.com/llvm/llvm-project d6344c1cd0d099f8d99ee320f33fc9254dbe8288)
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: /workspaces/asyncify-repro/emsdk/upstream/bin

I have a simple program like this:

#include <cstdint>
#include <emscripten.h>
#include <emscripten/bind.h>

int64_t getBigInt() {
    return 1000000000000;
}

EMSCRIPTEN_BINDINGS(my_module) {
    emscripten::function("getBigInt", &getBigInt);
}

I built it with the following options:

-sMODULARIZE -sWASM_BIGINT=1 -lembind -sEXPORT_ES6=1 -sASYNCIFY=1

When I attempt to run the following code from nodejs:

import module from "./build/asyncify_bigint.js"
const mymod = await module();
console.log(mymod.getBigInt());

I get the error:

RuntimeError: null function or function signature mismatch
    at wasm://wasm/0001c73a:wasm-function[98]:0x57be
    at ret.<computed> (file:///workspaces/asyncify-repro/build/asyncify_bigint.js:1679:24)
    at file:///workspaces/asyncify-repro/build/asyncify_bigint.js:649:12
    at dynCallLegacy (file:///workspaces/asyncify-repro/build/asyncify_bigint.js:2028:14)
    at dynCall (file:///workspaces/asyncify-repro/build/asyncify_bigint.js:2045:17)
    at file:///workspaces/asyncify-repro/build/asyncify_bigint.js:2049:27
    at Object.getBigInt (eval at newFunc (file:///workspaces/asyncify-repro/build/asyncify_bigint.js:1447:27), <anonymous>:6:10)
    at file:///workspaces/asyncify-repro/test.js:5:19

Node.js v23.2.0
brendandahl added a commit to brendandahl/emscripten that referenced this issue Nov 15, 2024
Long longs were incorrectly being mapped to int for the signature.

Fixes emscripten-core#22928
brendandahl added a commit that referenced this issue Nov 15, 2024
Long longs were incorrectly being mapped to int for the signature.

Fixes #22928
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.

2 participants