RESOLVED FIXED315424
[CMake] Swift typecheck step races _CopyHeaders on clean builds
https://bugs.webkit.org/show_bug.cgi?id=315424
Summary [CMake] Swift typecheck step races _CopyHeaders on clean builds
Brandon
Reported 2026-05-23 07:50:06 PDT
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.
Attachments
Radar WebKit Bug Importer
Comment 1 2026-05-23 07:50:12 PDT
Brandon
Comment 2 2026-05-23 07:51:35 PDT
EWS
Comment 3 2026-05-23 19:56:27 PDT
Committed 313799@main (04934aedb7f1): <https://commits.webkit.org/313799@main> Reviewed commits have been landed. Closing PR #65537 and removing active labels.
Note You need to log in before you can comment on or make changes to this bug.