-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Description
Version of emscripten/emsdk:
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 4.0.15 (09f52557f0d48b65b8c724853ed8f4e8bf80e669)
clang version 22.0.0git (https:/github.com/llvm/llvm-project 3388d40684742e950b3c5d1d2dafe5a40695cfc1)
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: /home/iscle/emsdk/upstream/bin
I was just trying to create a C callback as a JavaScript function, via function pointers, and was hitting a weird error when using the addFunction function.
The error was:
Uncaught TypeError: WebAssembly.Table.set(): Argument 1 is invalid for table: function-typed object must be null (if nullable) or a Wasm function object at setWasmTableEntry (h264.js:1031:17) at Object.addFunction (h264.js:1062:9) at <anonymous>:1:6
I was building with the following arguments:
"-sSTRICT"
"-sWASM=2"
"-sMODULARIZE=1"
"-sALLOW_TABLE_GROWTH=1"
"-sALLOW_MEMORY_GROWTH=1"
"-sEXPORT_NAME=createH264"
"-sEXPORTED_RUNTIME_METHODS=HEAPU8,addFunction"
Following the stack trace I ended up in the following emscripten function, and noticed that it was empty. Weird.
emscripten/src/lib/libaddfunction.js
Line 90 in 3bad024
$convertJsFunctionToWasm: (func, sig) => { |
Upon further inspection, it appears that if 'WASM2JS' is set, the 'convertJsFunctionToWasm' does nothing. However, this should not be the case if running in wasm mode.
After removing the '-sWASM=2' argument, everything compiled and went smooth, loosing pure javascript support, of course.
It would be nice if this issue could be fixed, to build sites with maximum compatibility with older runtimes. Maybe this is also present somewhere else.
Thanks!