Conversation
chrfalch
force-pushed
the
chrfalch/fix-prebuild-stale-header-links
branch
from
September 18, 2026 16:33
2e0608b to
ebdb97a
Compare
The prebuild stages headers into .build/headers as hard links, and skipped any target that already existed. A hard link shares an inode, so in-place edits propagate, but git checkout renames a new file over the source and gives it a new inode. The staged link then serves the old contents forever and setup never repairs it, so the build compiles against headers from whichever commit was checked out when the link was first created. The staging function now compares the staged file against its source and relinks it when the inodes differ. Targets a pass has already claimed are left alone, so sources that flatten onto the same target keep resolving to the first one visited, as before. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
chrfalch
force-pushed
the
chrfalch/fix-prebuild-stale-header-links
branch
from
September 18, 2026 16:38
ebdb97a to
8f1d214
Compare
|
@shwanton has imported this pull request. If you are a Meta employee, you can view this in D120740409. |
cipolleschi
approved these changes
Sep 21, 2026
fabriziocucci
pushed a commit
that referenced
this pull request
Sep 24, 2026
Summary: The iOS prebuild (`node scripts/ios-prebuild`) stages React Native's headers into `packages/react-native/.build/headers` as hard links, and skipped any target that already existed. When changing the original source files, these hard links can become stale and errors like this can occur: ``` Libraries/LinkingIOS/RCTLinkingManager.mm:91:7: error: use of undeclared identifier 'RCTIsSceneDelegateApp' ``` This is a problem that contributors will see - not regular users, but the fix helps with strange error messages. ## Changelog: [INTERNAL] [FIXED] - Repair stale staged headers in the iOS prebuild instead of compiling against a previous checkout's copies Pull Request resolved: #58596 Test Plan: ✅ New unit tests, 16 cases in `packages/react-native/scripts/ios-prebuild/__tests__/setup-test.js`, using real temporary directories rather than an `fs` mock, since the defect is about inodes. End to end on an Xcode 27 checkout: - Replaced a staged header with a copy, so it kept the same contents but a different inode. `node scripts/ios-prebuild -s -f Debug` restored it to the source inode and logged `Linked React/Base → .build/headers/React`. The previous code skipped it. - Ran setup a second time with nothing changed: no file was relinked, and nothing was logged. - Confirmed the three colliding targets still resolve to the same source as before the change, by inode. - `node scripts/ios-prebuild -b -f Debug -p ios-simulator` → `** BUILD SUCCEEDED **`. Reviewed By: cipolleschi Differential Revision: D120740409 Pulled By: shwanton fbshipit-source-id: 41c1eb112c3395d6c7158d7151be7fdd92a21cef (cherry picked from commit b935e74)
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:
The iOS prebuild (
node scripts/ios-prebuild) stages React Native's headers intopackages/react-native/.build/headersas hard links, and skipped any target that already existed.When changing the original source files, these hard links can become stale and errors like this can occur:
This is a problem that contributors will see - not regular users, but the fix helps with strange error messages.
Changelog:
[INTERNAL] [FIXED] - Repair stale staged headers in the iOS prebuild instead of compiling against a previous checkout's copies
Test Plan:
✅ New unit tests, 16 cases in
packages/react-native/scripts/ios-prebuild/__tests__/setup-test.js, using real temporary directories rather than anfsmock, since the defect is about inodes.End to end on an Xcode 27 checkout:
node scripts/ios-prebuild -s -f Debugrestored it to the source inode and loggedLinked React/Base → .build/headers/React. The previous code skipped it.node scripts/ios-prebuild -b -f Debug -p ios-simulator→** BUILD SUCCEEDED **.