Skip to content

Commit 7f8825a

Browse files
committed
Provide symbol fallbacks for legacy Hermes Registration API when HERMES_V1_ENABLED
When prebuilt binaries are compiled with `HERMES_V1_ENABLED`, the `enableDebugging`/`disableDebugging` symbols were stripped entirely, causing linker errors for libraries depending on the legacy `inspector-modern/chrome/Registration.h` API. Add no-op fallback implementations in the `HERMES_V1_ENABLED` path to preserve backward compatibility. Cherry-picked from facebook#55400. ## Changelog: [General][Fixed] - Provide symbol fallbacks for `inspector-modern/chrome/Registration.h` when `HERMES_V1_ENABLED` is set
1 parent 5aee11b commit 7f8825a

File tree

1 file changed

+44
-2
lines changed
  • packages/react-native/ReactCommon/hermes/inspector-modern/chrome

1 file changed

+44
-2
lines changed

packages/react-native/ReactCommon/hermes/inspector-modern/chrome/Registration.cpp

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@
88
#include "Registration.h"
99
#include "ConnectionDemux.h"
1010

11-
#if defined(HERMES_ENABLE_DEBUGGER) && !defined(HERMES_V1_ENABLED)
11+
#if defined(HERMES_ENABLE_DEBUGGER)
12+
13+
#include <hermes/hermes.h>
14+
15+
#if !defined(HERMES_V1_ENABLED)
1216

1317
namespace facebook::hermes::inspector_modern::chrome {
1418

@@ -34,4 +38,42 @@ void disableDebugging(DebugSessionToken session) {
3438

3539
} // namespace facebook::hermes::inspector_modern::chrome
3640

37-
#endif // defined(HERMES_ENABLE_DEBUGGER) && !defined(HERMES_V1_ENABLED)
41+
#else
42+
43+
namespace facebook::hermes::inspector_modern {
44+
class RuntimeAdapter {
45+
// Backwards compatibility definition fallback for libraries that are compiled
46+
// without `HERMES_V1_ENABLED` but are linked against React Native with
47+
// `HERMES_V1_ENABLED` which doesn't provide this symbol.
48+
public:
49+
virtual ~RuntimeAdapter() = 0;
50+
virtual HermesRuntime& getRuntime() = 0;
51+
virtual void tickleJs();
52+
};
53+
54+
namespace chrome {
55+
56+
using DebugSessionToken = int;
57+
58+
DebugSessionToken enableDebugging(
59+
std::unique_ptr<RuntimeAdapter>,
60+
const std::string&) {
61+
// Backwards compatibility fallback for libraries that are compiled without
62+
// `HERMES_V1_ENABLED` but are linked against React Native with
63+
// `HERMES_V1_ENABLED` which doesn't provide this symbol.
64+
return -1;
65+
};
66+
67+
void disableDebugging(DebugSessionToken) {
68+
// Backwards compatibility fallback for libraries that are compiled without
69+
// `HERMES_V1_ENABLED` but are linked against React Native with
70+
// `HERMES_V1_ENABLED` which doesn't provide this symbol.
71+
}
72+
73+
} // namespace chrome
74+
75+
} // namespace facebook::hermes::inspector_modern
76+
77+
#endif // !defined(HERMES_V1_ENABLED)
78+
79+
#endif // defined(HERMES_ENABLE_DEBUGGER)

0 commit comments

Comments
 (0)