-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
node-api: update headers for better wasm support #49037
node-api: update headers for better wasm support #49037
Conversation
Review requested:
|
@toyobayashi what is the likelyhood that this would affect any existing addons? |
@cjihrig I'm wondering if you have any thoughts/opinions on the request related to |
@mhdawson I don't think I'm familiar enough with this work to have a good opinion. |
This very intentionally already expands to What we could do instead is allow you to define your own |
@mhdawson Reverted changes on |
Should we add Lines 4 to 11 in 0d03b77
- #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 |
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. |
@legendecas is going to take another look at this before we land it. |
0d4a5ef
to
adee653
Compare
Landed in b55adfb |
PR-URL: nodejs#49037 Reviewed-By: Gabriel Schulhof <[email protected]> Reviewed-By: Chengzhong Wu <[email protected]>
PR-URL: #49037 Reviewed-By: Gabriel Schulhof <[email protected]> Reviewed-By: Chengzhong Wu <[email protected]>
PR-URL: #49037 Reviewed-By: Gabriel Schulhof <[email protected]> Reviewed-By: Chengzhong Wu <[email protected]>
PR-URL: nodejs#49037 Reviewed-By: Gabriel Schulhof <[email protected]> Reviewed-By: Chengzhong Wu <[email protected]>
PR-URL: nodejs/node#49037 Reviewed-By: Gabriel Schulhof <[email protected]> Reviewed-By: Chengzhong Wu <[email protected]>
PR-URL: nodejs/node#49037 Reviewed-By: Gabriel Schulhof <[email protected]> Reviewed-By: Chengzhong Wu <[email protected]>
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-emscripten
expand
NAPI_MODULE_EXPORT
to__attribute__((used))
(EMSCRIPTEN_KEEPALIVE
) to exportnapi_register_wasm_v1
andnode_api_module_get_api_version_v1
if 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_EXTERN
to__attribute__((__import_module__("env")))
if build with Emscripten. Not sure if this should.env
module by default. If don't do this change, emnapi must require user to provide ainstantiateWasm
hook to emscripten and addnapi
module during this hook call, which isn't whatinstantiateWasm
are 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-unknown
andwasm32-wasi
. It is worth mentioning that I created a PR src: defineNAPI_HAS_THREADS
to make TSFN available on Emscripten node-addon-api#1283 that addedNAPI_HAS_THREADS
toNapi::AsyncWorker
andNapi::ThreadSafeFunction
, now maybe just add it toNapi::AsyncProgressWorker
is enough because it's usingstd::mutex
, which requires__EMSCRIPTEN_PTHREADS__
or__wasi__ && _REENTRANT