fix(iOS): gate prebuilt headers on Swift C++-interop importability#57606
Open
chrfalch wants to merge 1 commit into
Open
fix(iOS): gate prebuilt headers on Swift C++-interop importability#57606chrfalch wants to merge 1 commit into
chrfalch wants to merge 1 commit into
Conversation
Add a compile gate to headers-verify.js that imports every composed ReactNativeHeaders module under -cxx-interoperability-mode=default and probes ClangImporter's copyability path for a list of value types, so a C++ type with an ill-formed-on-instantiation implicit copy constructor (invisible to C++ CI, breaks every Nitro-based Swift consumer) fails the prebuild instead of a downstream community nightly. Covers the two known offenders (TraceRecordingState, HostTracingProfile); future types are a one-line list edit. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
chrfalch
force-pushed
the
chrfalch/headers-verify-cxx-interop-gate
branch
from
July 21, 2026 11:11
ce116a2 to
4265263
Compare
cipolleschi
approved these changes
Jul 21, 2026
|
@cipolleschi has imported this pull request. If you are a Meta employee, you can view this in D113011048. |
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
Adds a generator-time gate so a Swift-C++-interop-hostile C++ type can never silently ship in the prebuilt iOS core headers again.
The class this guards: the prebuilt core headers ship as real clang modules. A C++ value type reachable from a shipped module whose implicit copy constructor is declared but ill-formed on instantiation — e.g. an implicit-copy struct with a
std::vector<move-only-T>member — compiles fine in C++ but hard-errors when a Swift target with-cxx-interoperability-mode=defaultimports the module and its generated bridging uses the type as a copyable value. This is invisible to C++ CI (plain C++ never instantiates the copy), so it only surfaced as a broken community-library nightly (react-native-unistyles, viaTraceRecordingState/HostTracingProfile— fixed in #57605).The gate: a fourth compile gate (stage 3d) in
headers-verify.js'srunCompileGates, compiling a Swift TU with-cxx-interoperability-mode=defaultthat imports every module declared by the composedReactNativeHeadersmodule map (parsed at runtime, not hardcoded), plus a probe that forces the ClangImporter copyability path for a small explicit list of value types (SWIFT_CXX_INTEROP_PROBE_TYPES). Because a bareimportdoes not eagerly instantiate copy constructors on the current toolchain, the probe reproduces what a real interop consumer's generated code does: for each listed type it conditionally instantiates a copy, which fails exactly as the real consumer fails if the type regresses to an implicit copy. Adding future coverage is a one-line list edit.One module (
React_RCTAppDelegate) is excluded as non-importable under interop by design (ObjC bootstrap module with C++-only factory conformances); the inspector C++ graph it would reach is covered directly by the probe instead. The exclusion is documented in-source, and new exclusions are required to carry a justification.Independent review confirmed the probe reproduces the real failure for the right reason (the dangerous shape reports
is_copy_constructible_v == true, so the probe enters the branch and forces the ill-formed body instantiation — mirroring ClangImporter, not masking the bug), and that both offender types are covered.Changelog:
[INTERNAL] [ADDED] - Prebuild gate that fails composed iOS headers unusable from a Swift C++-interop consumer
Test Plan
Against a freshly composed Debug artifact (
node scripts/ios-prebuild -c -f Debug):node scripts/ios-prebuild/headers-verify.js --flavor Debugpasses the new gate with both probe types (TraceRecordingState,HostTracingProfile) fixed in the artifact.TraceRecordingState.hinto the composed artifact fails the gate with the exact__construct_at/ implicit-copy diagnostic; restoring the fix → green.HostTracingProfileunfixed (TraceRecordingState left fixed) → gate fails namingHostTracingProfileand its probe specialization; restore → green.node --check,prettier --check,flow focus-checkclean. Gate is skipped by--skip-compilelike the other compile gates.🤖 Generated with Claude Code