From ca5a020e21963bb88817c35102434f68f65fc0c5 Mon Sep 17 00:00:00 2001 From: Rintaro Ishizaki Date: Tue, 11 Mar 2025 13:29:25 -0700 Subject: [PATCH] [CMake] '-no-emit-module-separately-wmo' for swift modules Emitting modules in separate frontend job doesn't give any benefits because single add_library is just a single job from CMake's point of view. Clients need to wait for `.dylib`/`.so` being emitted before using the `.swiftmodule`. *Not* emitting modules separately is actually faster in CMake because it doesn't parse and typecheck the source code twice. --- cmake/modules/AddPureSwift.cmake | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cmake/modules/AddPureSwift.cmake b/cmake/modules/AddPureSwift.cmake index 52cdfc3f66e7e..c37037762c500 100644 --- a/cmake/modules/AddPureSwift.cmake +++ b/cmake/modules/AddPureSwift.cmake @@ -28,6 +28,10 @@ function(_add_host_swift_compile_options name) "$<$:SHELL:-Xfrontend -disable-implicit-string-processing-module-import>") endif() + # Emitting module seprately doesn't give us any benefit. + target_compile_options(${name} PRIVATE + "$<$:-no-emit-module-separately-wmo>") + if(SWIFT_ANALYZE_CODE_COVERAGE) set(_cov_flags $<$:-profile-generate -profile-coverage-mapping>) target_compile_options(${name} PRIVATE ${_cov_flags})