Uh oh!
There was an error while loading. Please reload this page.
node-api: update headers for better wasm support - #49037
Conversation
nodejs-github-bot
commented
Aug 6, 2023
Review requested:
|
mhdawson
commented
Aug 14, 2023
@toyobayashi what is the likelyhood that this would affect any existing addons? |
mhdawson
commented
Aug 14, 2023
@cjihrig I'm wondering if you have any thoughts/opinions on the request related to |
cjihrig
commented
Aug 14, 2023
@mhdawson I don't think I'm familiar enough with this work to have a good opinion. |
devsnek
commented
Aug 14, 2023
This very intentionally already expands to What we could do instead is allow you to define your own |
toyobayashi
commented
Aug 15, 2023
@mhdawson Reverted changes on |
Should we add https://github.com/nodejs/node/blob/0d03b777151b1d34bcbbc35d6c38c123a009dded/src/node_api.h#L4-L11 - #ifdef BUILDING_NODE_EXTENSION+ #if defined(BUILDING_NODE_EXTENSION) && !defined(NAPI_EXTERN)Sharp is using node-gyp, emnapi and emscripten to build wasm port, the wasm version is already available on StackBlitz WebContainer. Though |
gabrielschulhof
commented
Sep 22, 2023
It makes sense that, if js_native_api.h is included via node_api.h, then NAPI_EXTERN should still be used if already available. |
mhdawson
commented
Sep 29, 2023
@legendecas is going to take another look at this before we land it. |
0d4a5ef to
adee653Comparenodejs-github-bot
commented
Oct 5, 2023
nodejs-github-bot
commented
Oct 5, 2023
nodejs-github-bot
commented
Oct 5, 2023
Landed in b55adfb |
PR-URL: #49037 Reviewed-By: Gabriel Schulhof <gabrielschulhof@gmail.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
PR-URL: #49037 Reviewed-By: Gabriel Schulhof <gabrielschulhof@gmail.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
PR-URL: nodejs#49037 Reviewed-By: Gabriel Schulhof <gabrielschulhof@gmail.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
PR-URL: nodejs/node#49037 Reviewed-By: Gabriel Schulhof <gabrielschulhof@gmail.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
PR-URL: nodejs/node#49037 Reviewed-By: Gabriel Schulhof <gabrielschulhof@gmail.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Re-enable ThinLTO on macOS. Add a new patch to ensure N-API entry points aren't stripped by ThinLTO. Copy the `__attribute__((used))` approach from nodejs/node#49037 .
Hi, Node-API team @nodejs/node-api
I'm wondering if emnapi could use node-api-headers package instead of maintaining a modified version of headers.
Just a little modification:
change
__wasm32__to__wasm__for buildingwasm64-unknown-emscriptenexpand
NAPI_MODULE_EXPORTto__attribute__((used))(EMSCRIPTEN_KEEPALIVE) to exportnapi_register_wasm_v1andnode_api_module_get_api_version_v1if build with EmscriptenexpandCurrently there is no way to specify a custom module name in wasm import object for imported function which is implemented in JavaScript, all functions imported from JavaScript are underNAPI_EXTERNto__attribute__((__import_module__("env")))if build with Emscripten. Not sure if this should.envmodule by default. If don't do this change, emnapi must require user to provide ainstantiateWasmhook to emscripten and addnapimodule during this hook call, which isn't whatinstantiateWasmare supposed to be used for, that force users to write loading logic themselves.remove
__wasm32__guards on async work and TSFN, because they have been implemented and are available in wasm, even inwasm32-unknown-unknownandwasm32-wasi. It is worth mentioning that I created a PR src: defineNAPI_HAS_THREADSto make TSFN available on Emscripten node-addon-api#1283 that addedNAPI_HAS_THREADStoNapi::AsyncWorkerandNapi::ThreadSafeFunction, now maybe just add it toNapi::AsyncProgressWorkeris enough because it's usingstd::mutex, which requires__EMSCRIPTEN_PTHREADS__or__wasi__ && _REENTRANT