Skip to content

Build Android Node-API modules against a weak-node-api.so #35

Description

@kraenhansen

When building Node-API module dynamic libraries using our react-native-node-api-modules-cmake we're passing -Wl,--allow-shlib-undefined to satisfy the linker when it's missing the Node-API symbols.

This is not great for a couple of reasons:

  • We're essentially allowing any symbol to be undefined, which might open up for unresolved symbols other than those from Node-API, which will lead to hard to debug issues for library developers.
  • We're postponing the issue until runtime, since dlopen on Android won't share even global symbols from libhermes.so with the Node-API module dynamic library and it cannot load anyway. It needs to declare libhermes.so (or whatever .so brings the Node-API symbols) as DT_NEEDED (which is added to the binary automatically when linking against an .so).

Instead, we could build a "fake" libnode.so which would provide failing implementations of all the Node-API symbols. We can use this to link against and then update the DT_NEEDED record in the dynamic library when auto-linking into the Android app, at which point we'd know what library brings the Node-API symbols: For now the only option will be Hermes (engine symbols) in combination with our NodeApiHost (runtime symbols).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Android 🤖Anything related to the Android platform (Gradle, NDK, Android SDK)CMake RNOur `cmake` wrapping CLI

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions