Skip to content

Commit a345e57

Browse files
authored
Merge pull request #69491 from hamishknight/cmake-cov-fix
2 parents 5b2e534 + b81e352 commit a345e57

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

cmake/modules/AddPureSwift.cmake

+6
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ function(_add_host_swift_compile_options name)
3131
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xfrontend -disable-implicit-backtracing-module-import>")
3232
endif()
3333

34+
if(SWIFT_ANALYZE_CODE_COVERAGE)
35+
set(_cov_flags $<$<COMPILE_LANGUAGE:Swift>:-profile-generate -profile-coverage-mapping>)
36+
target_compile_options(${name} PRIVATE ${_cov_flags})
37+
target_link_options(${name} PRIVATE ${_cov_flags})
38+
endif()
39+
3440
# The compat56 library is not available in current toolchains. The stage-0
3541
# compiler will build fine since the builder compiler is not aware of the 56
3642
# compat library, but the stage-1 and subsequent stage compilers will fail as

cmake/modules/AddSwift.cmake

+6-5
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,12 @@ function(_add_host_variant_c_compile_link_flags name)
179179
target_compile_options(${name} PRIVATE $<$<COMPILE_LANGUAGE:C,CXX,OBJC,OBJCXX>:${_lto_flag_out}>)
180180
target_link_options(${name} PRIVATE ${_lto_flag_out})
181181
endif()
182+
183+
if(SWIFT_ANALYZE_CODE_COVERAGE)
184+
set(_cov_flags $<$<COMPILE_LANGUAGE:C,CXX,OBJC,OBJCXX>:-fprofile-instr-generate -fcoverage-mapping>)
185+
target_compile_options(${name} PRIVATE ${_cov_flags})
186+
target_link_options(${name} PRIVATE ${_cov_flags})
187+
endif()
182188
endfunction()
183189

184190

@@ -322,11 +328,6 @@ function(_add_host_variant_c_compile_flags target)
322328
target_compile_definitions(${target} PRIVATE
323329
"SWIFT_THREADING_${_threading_package}")
324330

325-
if(SWIFT_ANALYZE_CODE_COVERAGE)
326-
target_compile_options(${target} PRIVATE
327-
$<$<COMPILE_LANGUAGE:C,CXX,OBJC,OBJCXX>:-fprofile-instr-generate -fcoverage-mapping>)
328-
endif()
329-
330331
if((SWIFT_HOST_VARIANT_ARCH STREQUAL "armv7" OR
331332
SWIFT_HOST_VARIANT_ARCH STREQUAL "aarch64") AND
332333
(SWIFT_HOST_VARIANT_SDK STREQUAL "LINUX" OR

0 commit comments

Comments
 (0)