Skip to content

Commit 601a706

Browse files
committed
host: match hermes_napi_create_env C linkage after upstream #2106
The pinned Hermes commit now includes facebook/hermes#2106, which wraps the public hermes_napi_* entry points in extern "C". Hermes therefore exports the unmangled C symbol for hermes_napi_create_env. CxxNodeApiHostModule forward-declares that entry point (to avoid including Hermes' node_api.h) but did so with C++ linkage, so it referenced the mangled name. After the pin bump the two no longer matched and the iOS app failed to link with "Undefined symbol: hermes_napi_create_env". Wrap the forward declaration in extern "C" so the reference resolves to the exported unmangled symbol. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TVfanKvtyfSsoMgZv3DJtY
1 parent 4820937 commit 601a706

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

packages/host/cpp/CxxNodeApiHostModule.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,18 @@ using namespace facebook;
99
// Declared by the vendored Hermes in API/napi/hermes_napi.h. We forward declare
1010
// it here (rather than including that header) to avoid pulling in Hermes' own
1111
// node_api.h alongside the weak-node-api copy already included transitively.
12-
// Only the mangled name matters for linking, so passing host as nullptr is
13-
// enough — async work / thread-safe functions will return failure until a
12+
//
13+
// The declaration must be `extern "C"`: since facebook/hermes#2106 (included in
14+
// the pinned Hermes commit) the public hermes_napi.h wraps these entry points
15+
// in `extern "C"`, so Hermes exports the unmangled C symbol. Without matching C
16+
// linkage here the reference would be to the C++-mangled name and the app fails
17+
// to link ("Undefined symbol: hermes_napi_create_env"). Passing host as nullptr
18+
// is enough — async work / thread-safe functions will return failure until a
1419
// host integration is wired up (Phase 3).
20+
extern "C" {
1521
struct hermes_napi_host;
1622
napi_env hermes_napi_create_env(void *hermes_runtime, hermes_napi_host *host);
23+
}
1724

1825
namespace callstack::react_native_node_api {
1926

0 commit comments

Comments
 (0)