mirror of
https://gitlab.kitware.com/cmake/cmake.git
synced 2026-09-25 04:09:36 +03:00
Since commit b6367f723b (Swift/Ninja: Emit modules separately from
compilation, 2026-04-10) the compile and emit-module edges share the
same -output-file-map, which references a single module-level
.swiftdeps file. When ninja schedules both edges concurrently, both
swift invocations write that file and corrupt it.
Add the .swiftmodule output as an order-only dependency of the object
compile edge so the two edges within a target run sequentially.
Downstream targets are unaffected: they still unblock as soon as the
emit-module edge finishes, preserving cross-target parallelism.
Move the object-build WriteBuild call to after the emit-module block
so the order-only dep is added after modBuild is copied from objBuild,
avoiding a self-reference on the emit-module edge's own output.
Issue: #27748
29 lines
1.1 KiB
CMake
29 lines
1.1 KiB
CMake
# The Swift object compile edge must order-only depend on the .swiftmodule
|
|
# produced by the separate emit-module edge. Both edges share the same
|
|
# -output-file-map; running them concurrently corrupts the module-level
|
|
# swift-dependencies file referenced by that map.
|
|
if(RunCMake_GENERATOR_IS_MULTI_CONFIG)
|
|
set(path "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/impl-Debug.ninja")
|
|
else()
|
|
set(path "${RunCMake_TEST_BINARY_DIR}/build.ninja")
|
|
endif()
|
|
file(READ "${path}" build_ninja)
|
|
|
|
# Find the object compile edge for L and confirm L.swiftmodule appears
|
|
# after the order-only `||` separator. The edge ends at the next `build `
|
|
# at the start of a line (or end of file).
|
|
string(REGEX MATCH
|
|
"build [^\n]*L\\.swift\\.o[^\n]*:[^\n]*(\n [^\n]+)*"
|
|
obj_edge "${build_ninja}")
|
|
|
|
if(NOT obj_edge)
|
|
string(APPEND RunCMake_TEST_FAILED
|
|
"Could not find object compile edge for L.swift.\n")
|
|
return()
|
|
endif()
|
|
|
|
if(NOT obj_edge MATCHES "\\|\\|[^\n]*L\\.swiftmodule")
|
|
string(APPEND RunCMake_TEST_FAILED
|
|
"Object compile edge for L.swift is missing an order-only dependency on L.swiftmodule.\nEdge:\n${obj_edge}\n")
|
|
endif()
|