[CMake] Swift typecheck step races _CopyHeaders on clean builds#65537
Merged
Conversation
Collaborator
|
EWS run on previous version of this PR (hash bd0863f) Details |
geoffreygaren
approved these changes
May 23, 2026
Comment on lines
+849
to
+855
| # The typecheck command that produces ${_stamp} only DEPENDS on | ||
| # ${_target}_SwiftGeneratedDeps (binary-dir headers). On a clean first | ||
| # build ninja can schedule it before _CopyHeaders has finished staging | ||
| # source-tree headers under <framework>/Headers/, leaving the umbrella | ||
| # modulemap pointing at a partial directory. swiftc then fails with | ||
| # "underlying Objective-C module '<module>' not found". Gate the | ||
| # typecheck on _CopyHeaders too. |
Contributor
There was a problem hiding this comment.
Let's remove this comment. I don't find it helpful. It's an execution trace of how the code would behave if it were written differently, and then what would go wrong in that other code. That doesn't really explain this code. And I think the code is reasonably self-explanatory, and if it isn't I can always review the commit message.
bd0863f to
757de42
Compare
Collaborator
|
EWS run on current version of this PR (hash 757de42) Details
|
https://bugs.webkit.org/show_bug.cgi?id=315424 rdar://177781369 Reviewed by Adrian Taylor and Geoffrey Garen. On a clean build, the PAL Swift C++-interop typecheck step intermittently fails with: error: underlying Objective-C module 'pal' not found @_exported public import pal error: no such module 'pal.Core.crypto.CryptoTypes' The same step succeeds on the next build. Root cause is a missing edge in the ninja graph: `_webkit_setup_swift_header_deps` collects the framework's `_CopyHeaders` / `_CopyPrivateHeaders` targets into `${_deps}` and attaches them only to the outer `${_target}_SwiftCxxHeader` ordering target. That gates the framework's main Swift compilation, but not the `add_custom_command(OUTPUT ${_stamp} ...)` that runs `swiftc -typecheck` to emit the C++ interop header. The typecheck command's DEPENDS list is `${_swift_sources} ${_target}_SwiftGeneratedDeps`, where `_SwiftGeneratedDeps` carries only binary-dir headers from `${_target}_HEADERS` / `${_target}_DERIVED_SOURCES`. Source-tree headers staged via `_CopyHeaders` (e.g. `PAL/Headers/pal/crypto/CryptoTypes.h`) are therefore not inputs to the typecheck node. Ninja can schedule the typecheck before the framework's umbrella header directory is fully populated, at which point Clang's `umbrella "."` discovery in the staged module.modulemap fails to resolve the imports requested by pal.swift's `import pal.Core.crypto.CryptoTypes`. Add the `_CopyHeaders` targets as dependencies of `_SwiftGeneratedDeps` so the typecheck node itself waits for header staging, not just the outer `_SwiftCxxHeader` target. The fix is symmetric across PAL, WebGPU, etc.; all consumers of `WEBKIT_SETUP_SWIFT_AND_GENERATE_SWIFT_CPP_INTEROP_HEADER` benefit. * Source/cmake/WebKitMacros.cmake: Canonical link: https://commits.webkit.org/313799@main
757de42 to
04934ae
Compare
Collaborator
|
Committed 313799@main (04934ae): https://commits.webkit.org/313799@main Reviewed commits have been landed. Closing PR #65537 and removing active labels. |
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.
🧪 api-mac
04934ae
757de42
🛠 mac🛠 wpe🧪 wpe-wk2🧪 win-tests🧪 ios-wk2🧪 api-mac🧪 api-wpe🧪 ios-wk2-wpt🧪 api-mac-debug🛠 gtk3-libwebrtc🧪 api-ios🛠 gtk🧪 mac-wk2🧪 gtk-wk2🧪 mac-AS-debug-wk2🧪 api-gtk🧪 mac-wk2-stress🧪 vision-wk2🧪 mac-intel-wk2🧪 jsc-armv7-tests🧪 mac-site-isolation