nbind
nbind copied to clipboard
ccall and Pointer_stringify no longer exported by default
When building with --asmjs=1
, we also load pre.js
, which needs Module.ccall
to run the nbind_init
-function.
Neither Module.ccall
or Module.Pointer_stringify
(See https://github.com/kripken/emscripten/issues/5940) are exported, and so nbind will crash.
A simple fix is to add
"-s", "EXPORTED_FUNCTIONS=[\"_nbind_init\",\"_nbind_value\"]",
+ "-s", "EXTRA_EXPORTED_RUNTIME_METHODS=[\"ccall\",\"Pointer_stringify\"]",
"-s", "DEFAULT_LIBRARY_FUNCS_TO_INCLUDE=[\"nbind_value\",\"\\$$Browser\"]"
to the nbind.gypi file.
I've tested this with the latest emsdk and it seems to work just fine.
Would this solution make for a good pull-request or is there perhaps a better way to fix this issue?
It sounds like a very good pull request, thanks!
Apparently, the suggested fix was not enough. After further investigation, it seems emscripten since 1.37.24 does not export some functions by default.
Much like ccall
, the function lengthBytesUTF8
is also used internally by nbind. While adding ccall
to EXTRA_EXPORTED_RUNTIME_METHODS
works, adding lengthBytesUTF8
does not.
This is probably caused by the fact that lengthBytesUTF8
is missing from this list (in which both lengthBytesUTF16
and lengthBytesUTF32
exist, suggesting that lengthBytesUTF8
has simply been forgotten).
I'll open an issue in the emscripten repo to see if those guys know anything about it.
EDIT: See https://github.com/kripken/emscripten/issues/6146.
I've now edited all Module.function()
-calls to use global instead (just function()
) and the build is working! I'll submit a pull request right away.
Thank you!