mirror of
https://gitlab.kitware.com/cmake/cmake.git
synced 2026-09-25 04:09:36 +03:00
Merge topic 'swift-ninja-emit-module-ordering'
d741a4fb90 Swift/Ninja: Serialize compile edge after emit-module within target
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !11989
This commit is contained in:
@@ -2279,11 +2279,6 @@ void cmNinjaTargetGenerator::WriteSwiftObjectBuildStatement(
|
||||
|
||||
objBuild.OrderOnlyDeps.push_back(this->OrderDependsTargetForTarget(config));
|
||||
|
||||
// Write object build
|
||||
this->GetGlobalGenerator()->WriteBuild(this->GetImplFileStream(fileConfig),
|
||||
objBuild,
|
||||
this->ForceResponseFile() ? -1 : 0);
|
||||
|
||||
// Write a separate emit-module build edge that produces .swiftmodule
|
||||
// without compile outputs. This allows downstream Swift targets to start
|
||||
// compiling as soon as the module interface is ready, overlapping with
|
||||
@@ -2314,7 +2309,16 @@ void cmNinjaTargetGenerator::WriteSwiftObjectBuildStatement(
|
||||
this->GetGlobalGenerator()->WriteBuild(this->GetImplFileStream(fileConfig),
|
||||
modBuild,
|
||||
this->ForceResponseFile() ? -1 : 0);
|
||||
|
||||
// Both edges share the same -output-file-map; serialize the compile
|
||||
// edge after emit-module so they do not race on the module .swiftdeps.
|
||||
objBuild.OrderOnlyDeps.push_back(moduleFilepath);
|
||||
}
|
||||
|
||||
// Write object build
|
||||
this->GetGlobalGenerator()->WriteBuild(this->GetImplFileStream(fileConfig),
|
||||
objBuild,
|
||||
this->ForceResponseFile() ? -1 : 0);
|
||||
}
|
||||
|
||||
void cmNinjaTargetGenerator::WriteTargetDependInfo(std::string const& lang,
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
# 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()
|
||||
@@ -0,0 +1,14 @@
|
||||
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)
|
||||
@@ -186,6 +186,10 @@ if(RunCMake_GENERATOR MATCHES "Ninja")
|
||||
run_cmake_command(EmitModuleSeparatelyExistingModulePath-build ${CMAKE_COMMAND} --build . -- -vn)
|
||||
endblock()
|
||||
|
||||
block()
|
||||
run_cmake(EmitModuleSeparatelyOrdering)
|
||||
endblock()
|
||||
|
||||
block()
|
||||
if(CMAKE_SYSTEM_NAME MATCHES Windows)
|
||||
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/ImportLibraryFlags-build)
|
||||
|
||||
Reference in New Issue
Block a user