@@ -102,6 +102,26 @@ function(_set_pure_swift_link_flags name relpath_to_lib_dir)
102
102
endif ()
103
103
endfunction ()
104
104
105
+ function (_set_pure_swift_profile_flags target_name )
106
+ # This replicates the code existing in LLVM llvm/cmake/modules/HandleLLVMOptions.cmake
107
+ # The second part of the clause replicates the LINKER_IS_LLD_LINK of the
108
+ # original.
109
+ if (LLVM_BUILD_INSTRUMENTED AND NOT (SWIFT_COMPILER_IS_MSVC_LIKE AND SWIFT_USE_LINKER STREQUAL "lld" ))
110
+ string (TOUPPER "${LLVM_BUILD_INSTRUMENTED} " uppercase_LLVM_BUILD_INSTRUMENTED )
111
+ if (LLVM_ENABLE_IR_PGO OR uppercase_LLVM_BUILD_INSTRUMENTED STREQUAL "IR" )
112
+ target_link_options (${target_name} PRIVATE
113
+ "SHELL:-Xclang-linker -fprofile-generate=\" ${LLVM_PROFILE_DATA_DIR} \" " )
114
+ elseif (uppercase_LLVM_BUILD_INSTRUMENTED STREQUAL "CSIR" )
115
+ target_link_options (${target_name} PRIVATE
116
+ "SHELL:-Xclang-linker -fcs-profile-generate=\" ${LLVM_CSPROFILE_DATA_DIR} \" " )
117
+ else ()
118
+ target_link_options (${target_name} PRIVATE
119
+ "SHELL:-Xclang-linker -fprofile-instr-generate=\" ${LLVM_PROFILE_FILE_PATTERN} \" " )
120
+ endif ()
121
+ endif ()
122
+ endfunction ()
123
+
124
+
105
125
# Add a new "pure" Swift host library.
106
126
#
107
127
# "Pure" Swift host libraries can only contain Swift code, and will be built
@@ -280,22 +300,7 @@ function(add_pure_swift_host_library name)
280
300
)
281
301
endif ()
282
302
283
- # This replicates he code existing in LLVM llvm/cmake/modules/HandleLLVMOptions.cmake
284
- # The second part of the clause replicates the LINKER_IS_LLD_LINK of the
285
- # original.
286
- if (LLVM_BUILD_INSTRUMENTED AND NOT (SWIFT_COMPILER_IS_MSVC_LIKE AND SWIFT_USE_LINKER STREQUAL "lld" ))
287
- string (TOUPPER "${LLVM_BUILD_INSTRUMENTED} " uppercase_LLVM_BUILD_INSTRUMENTED )
288
- if (LLVM_ENABLE_IR_PGO OR uppercase_LLVM_BUILD_INSTRUMENTED STREQUAL "IR" )
289
- target_link_options (${name} PRIVATE
290
- "SHELL:-Xclang-linker -fprofile-generate=\" ${LLVM_PROFILE_DATA_DIR} \" " )
291
- elseif (uppercase_LLVM_BUILD_INSTRUMENTED STREQUAL "CSIR" )
292
- target_link_options (${name} PRIVATE
293
- "SHELL:-Xclang-linker -fcs-profile-generate=\" ${LLVM_CSPROFILE_DATA_DIR} \" " )
294
- else ()
295
- target_link_options (${name} PRIVATE
296
- "SHELL:-Xclang-linker -fprofile-instr-generate=\" ${LLVM_PROFILE_FILE_PATTERN} \" " )
297
- endif ()
298
- endif ()
303
+ _set_pure_swift_profile_flags (${name} )
299
304
300
305
# Export this target.
301
306
set_property (GLOBAL APPEND PROPERTY SWIFT_EXPORTS ${name} )
@@ -430,4 +435,6 @@ function(add_pure_swift_host_tool name)
430
435
else ()
431
436
set_property (GLOBAL APPEND PROPERTY SWIFT_EXPORTS ${name} )
432
437
endif ()
438
+
439
+ _set_pure_swift_profile_flags (${name} )
433
440
endfunction ()
0 commit comments