Compile out RCTGetModuleClasses/RCTRegisterModule when both legacy interops are removed (#57670)#57670
Open
christophpurrer wants to merge 1 commit into
Open
Compile out RCTGetModuleClasses/RCTRegisterModule when both legacy interops are removed (#57670)#57670christophpurrer wants to merge 1 commit into
RCTGetModuleClasses/RCTRegisterModule when both legacy interops are removed (#57670)#57670christophpurrer wants to merge 1 commit into
Conversation
|
@christophpurrer has exported this pull request. If you are a Meta employee, you can view the originating Diff in D113555374. |
RCTGetModuleClasses/RCTRegisterModule when both legacy interops are removedRCTGetModuleClasses/RCTRegisterModule when both legacy interops are removed (#57670)
christophpurrer
added a commit
to christophpurrer/react-native-macos
that referenced
this pull request
Jul 25, 2026
…y interops are removed (react#57670) Summary: Changelog: [iOS][Changed] - Compile out `RCTGetModuleClasses`/`RCTRegisterModule` and skip static module registration when both `RCT_REMOVE_LEGACY_MODULE_INTEROP` and `RCT_REMOVE_LEGACY_COMPONENT_INTEROP` are defined `RCTGetModuleClasses()` and the `RCTModuleClasses` registry it reads (populated by `RCTRegisterModule`) exist solely to support the two legacy interop layers. Every reader of the registry is already gated behind either `RCT_REMOVE_LEGACY_MODULE_INTEROP` (TurboModule ⇄ legacy NativeModule interop) or `RCT_REMOVE_LEGACY_COMPONENT_INTEROP` (Fabric ⇄ legacy ViewManager interop). When an app defines **both** macros, the registry has no readers and the function, its backing statics, and `RCTRegisterModule` are dead code. This diff compiles them out in that configuration: - `React/Base/RCTBridge.mm`: guard `RCTModuleClasses`/`RCTModuleClassesSyncQueue`, `RCTGetModuleClasses()`, `getCoreModuleClasses()`, and `RCTRegisterModule()` behind `#if !defined(RCT_REMOVE_LEGACY_MODULE_INTEROP) || !defined(RCT_REMOVE_LEGACY_COMPONENT_INTEROP)`. The old-arch warning helpers (`getModulesLoadedWithOldArch` et al.) stay compiled in — they have an external caller in `RCTInstance.mm` — and simply observe an empty list once the registry's only writer is gone. - `React/Base/RCTBridge+Private.h`: guard the matching `RCT_EXTERN` declarations. - `React/Base/RCTBridgeModule.h`: add a "both-removed" variant of `RCT_EXPORT_MODULE` / `RCT_EXPORT_MODULE_NO_LOAD` that emits only `+moduleName` and omits the `RCTRegisterModule` call, so native modules still link when the symbol is gone. - `RCTLegacyUIManagerConstantsProvider.{h,mm}`: wrap the file body in `#ifndef RCT_REMOVE_LEGACY_COMPONENT_INTEROP`, matching the sibling `LegacyViewManagerInterop*` files. It was the one caller of `RCTGetModuleClasses` whose file body was not already guarded. - `fbobjc/Libraries/FBReactModuleRegistration/FBReactModuleRegistration.mm`: the FIT/new-arch path (`RCT_REMOVE_LEGACY_ARCH`) hand-calls `RCTRegisterModule`. On `cove-ios`, which sets all three macros, that symbol is now compiled out, so the call is additionally gated to only run when `RCTRegisterModule` still exists. The registry has no readers in that config, so this is a no-op. The default build (neither/one macro set) is behavior-unchanged: all guarded code is still compiled in. Differential Revision: D113555374
christophpurrer
force-pushed
the
export-D113555374
branch
from
July 25, 2026 00:00
e8abcbe to
78ea1f6
Compare
christophpurrer
added a commit
to christophpurrer/react-native-macos
that referenced
this pull request
Jul 25, 2026
…y interops are removed (react#57670) Summary: Changelog: [iOS][Changed] - Compile out `RCTGetModuleClasses`/`RCTRegisterModule` and skip static module registration when both `RCT_REMOVE_LEGACY_MODULE_INTEROP` and `RCT_REMOVE_LEGACY_COMPONENT_INTEROP` are defined `RCTGetModuleClasses()` and the `RCTModuleClasses` registry it reads (populated by `RCTRegisterModule`) exist solely to support the two legacy interop layers. Every reader of the registry is already gated behind either `RCT_REMOVE_LEGACY_MODULE_INTEROP` (TurboModule ⇄ legacy NativeModule interop) or `RCT_REMOVE_LEGACY_COMPONENT_INTEROP` (Fabric ⇄ legacy ViewManager interop). When an app defines **both** macros, the registry has no readers and the function, its backing statics, and `RCTRegisterModule` are dead code. This diff compiles them out in that configuration: - `React/Base/RCTBridge.mm`: guard `RCTModuleClasses`/`RCTModuleClassesSyncQueue`, `RCTGetModuleClasses()`, `getCoreModuleClasses()`, and `RCTRegisterModule()` behind `#if !defined(RCT_REMOVE_LEGACY_MODULE_INTEROP) || !defined(RCT_REMOVE_LEGACY_COMPONENT_INTEROP)`. The old-arch warning helpers (`getModulesLoadedWithOldArch` et al.) stay compiled in — they have an external caller in `RCTInstance.mm` — and simply observe an empty list once the registry's only writer is gone. - `React/Base/RCTBridge+Private.h`: guard the matching `RCT_EXTERN` declarations. - `React/Base/RCTBridgeModule.h`: add a "both-removed" variant of `RCT_EXPORT_MODULE` / `RCT_EXPORT_MODULE_NO_LOAD` that emits only `+moduleName` and omits the `RCTRegisterModule` call, so native modules still link when the symbol is gone. - `RCTLegacyUIManagerConstantsProvider.{h,mm}`: wrap the file body in `#ifndef RCT_REMOVE_LEGACY_COMPONENT_INTEROP`, matching the sibling `LegacyViewManagerInterop*` files. It was the one caller of `RCTGetModuleClasses` whose file body was not already guarded. - `fbobjc/Libraries/FBReactModuleRegistration/FBReactModuleRegistration.mm`: the FIT/new-arch path (`RCT_REMOVE_LEGACY_ARCH`) hand-calls `RCTRegisterModule`. On `cove-ios`, which sets all three macros, that symbol is now compiled out, so the call is additionally gated to only run when `RCTRegisterModule` still exists. The registry has no readers in that config, so this is a no-op. The default build (neither/one macro set) is behavior-unchanged: all guarded code is still compiled in. Differential Revision: D113555374
christophpurrer
force-pushed
the
export-D113555374
branch
from
July 25, 2026 01:40
78ea1f6 to
c6568ce
Compare
…y interops are removed (react#57670) Summary: Changelog: [iOS][Changed] - Compile out `RCTGetModuleClasses`/`RCTRegisterModule` and skip static module registration when both `RCT_REMOVE_LEGACY_MODULE_INTEROP` and `RCT_REMOVE_LEGACY_COMPONENT_INTEROP` are defined `RCTGetModuleClasses()` and the `RCTModuleClasses` registry it reads (populated by `RCTRegisterModule`) exist solely to support the two legacy interop layers. Every reader of the registry is already gated behind either `RCT_REMOVE_LEGACY_MODULE_INTEROP` (TurboModule ⇄ legacy NativeModule interop) or `RCT_REMOVE_LEGACY_COMPONENT_INTEROP` (Fabric ⇄ legacy ViewManager interop). When an app defines **both** macros, the registry has no readers and the function, its backing statics, and `RCTRegisterModule` are dead code. This diff compiles them out in that configuration: - `React/Base/RCTBridge.mm`: guard `RCTModuleClasses`/`RCTModuleClassesSyncQueue`, `RCTGetModuleClasses()`, `getCoreModuleClasses()`, and `RCTRegisterModule()` behind `#if !defined(RCT_REMOVE_LEGACY_MODULE_INTEROP) || !defined(RCT_REMOVE_LEGACY_COMPONENT_INTEROP)`. The old-arch warning helpers (`getModulesLoadedWithOldArch` et al.) stay compiled in — they have an external caller in `RCTInstance.mm` — and simply observe an empty list once the registry's only writer is gone. - `React/Base/RCTBridge+Private.h`: guard the matching `RCT_EXTERN` declarations. - `React/Base/RCTBridgeModule.h`: add a "both-removed" variant of `RCT_EXPORT_MODULE` / `RCT_EXPORT_MODULE_NO_LOAD` that emits only `+moduleName` and omits the `RCTRegisterModule` call, so native modules still link when the symbol is gone. - `RCTLegacyUIManagerConstantsProvider.{h,mm}`: wrap the file body in `#ifndef RCT_REMOVE_LEGACY_COMPONENT_INTEROP`, matching the sibling `LegacyViewManagerInterop*` files. It was the one caller of `RCTGetModuleClasses` whose file body was not already guarded. - `fbobjc/Libraries/FBReactModuleRegistration/FBReactModuleRegistration.mm`: the FIT/new-arch path (`RCT_REMOVE_LEGACY_ARCH`) hand-calls `RCTRegisterModule`. On `cove-ios`, which sets all three macros, that symbol is now compiled out, so the call is additionally gated to only run when `RCTRegisterModule` still exists. The registry has no readers in that config, so this is a no-op. The default build (neither/one macro set) is behavior-unchanged: all guarded code is still compiled in. Differential Revision: D113555374
christophpurrer
force-pushed
the
export-D113555374
branch
from
July 25, 2026 02:07
c6568ce to
40222e9
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
Changelog: [iOS][Changed] - Compile out
RCTGetModuleClasses/RCTRegisterModuleand skip static module registration when bothRCT_REMOVE_LEGACY_MODULE_INTEROPandRCT_REMOVE_LEGACY_COMPONENT_INTEROPare definedRCTGetModuleClasses()and theRCTModuleClassesregistry it reads (populated byRCTRegisterModule) exist solely to support the two legacy interop layers. Every readerof the registry is already gated behind either
RCT_REMOVE_LEGACY_MODULE_INTEROP(TurboModule⇄ legacy NativeModule interop) or
RCT_REMOVE_LEGACY_COMPONENT_INTEROP(Fabric ⇄ legacyViewManager interop). When an app defines both macros, the registry has no readers and the
function, its backing statics, and
RCTRegisterModuleare dead code.This diff compiles them out in that configuration:
React/Base/RCTBridge.mm: guardRCTModuleClasses/RCTModuleClassesSyncQueue,RCTGetModuleClasses(),getCoreModuleClasses(), andRCTRegisterModule()behind#if !defined(RCT_REMOVE_LEGACY_MODULE_INTEROP) || !defined(RCT_REMOVE_LEGACY_COMPONENT_INTEROP).The old-arch warning helpers (
getModulesLoadedWithOldArchet al.) stay compiled in — they havean external caller in
RCTInstance.mm— and simply observe an empty list once the registry's onlywriter is gone.
React/Base/RCTBridge+Private.h: guard the matchingRCT_EXTERNdeclarations.React/Base/RCTBridgeModule.h: add a "both-removed" variant ofRCT_EXPORT_MODULE/RCT_EXPORT_MODULE_NO_LOADthat emits only+moduleNameand omits theRCTRegisterModulecall,so native modules still link when the symbol is gone.
RCTLegacyUIManagerConstantsProvider.{h,mm}: wrap the file body in#ifndef RCT_REMOVE_LEGACY_COMPONENT_INTEROP, matching the siblingLegacyViewManagerInterop*files. It was the one caller of
RCTGetModuleClasseswhose file body was not already guarded.fbobjc/Libraries/FBReactModuleRegistration/FBReactModuleRegistration.mm: the FIT/new-arch path(
RCT_REMOVE_LEGACY_ARCH) hand-callsRCTRegisterModule. Oncove-ios, which sets all threemacros, that symbol is now compiled out, so the call is additionally gated to only run when
RCTRegisterModulestill exists. The registry has no readers in that config, so this is a no-op.The default build (neither/one macro set) is behavior-unchanged: all guarded code is still compiled in.
Differential Revision: D113555374