Files
cmake/Tests/RunCMake/Swift/EmitModuleSeparatelyOrdering.cmake
T
Roman Lavrov d741a4fb90 Swift/Ninja: Serialize compile edge after emit-module within target
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
2026-04-29 10:42:37 -04:00

15 lines
515 B
CMake

cmake_policy(SET CMP0157 NEW)
cmake_policy(SET CMP0215 NEW)
if(NOT CMAKE_GENERATOR MATCHES "Ninja")
message(SEND_ERROR "this test must use a Ninja generator, found ${CMAKE_GENERATOR}")
endif()
enable_language(Swift)
# The compile and emit-module edges share the same -output-file-map.
# Within the target, the object compile edge must order-only depend on the
# .swiftmodule so the two edges do not run concurrently and corrupt the
# shared module-level swift-dependencies entry.
add_library(L STATIC L.swift)