Bug 315424
| Summary: | [CMake] Swift typecheck step races _CopyHeaders on clean builds | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | Brandon <brandonstewart> |
| Component: | Tools / Tests | Assignee: | Brandon <brandonstewart> |
| Status: | RESOLVED FIXED | ||
| Severity: | Normal | CC: | webkit-bug-importer |
| Priority: | P2 | Keywords: | InRadar |
| Version: | WebKit Nightly Build | ||
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
Brandon
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 | ||
|---|---|---|
| Add attachment proposed patch, testcase, etc. |
Radar WebKit Bug Importer
<rdar://problem/177781369>
Brandon
Pull request: https://github.com/WebKit/WebKit/pull/65537
EWS
Committed 313799@main (04934aedb7f1): <https://commits.webkit.org/313799@main>
Reviewed commits have been landed. Closing PR #65537 and removing active labels.