Skip to content

Commit d285123

Browse files
authored
[build] Pass target to linker for host tools for Apple SDKs (#32618)
As part of this refactor some code touched as part of #31794 to better fit into the work done in #32120 -- in detail * `_add_host_variant_c_compile_link_flags` is now invoked by both add_swift_host_library and add_swift_host_library * `_add_host_variant_c_compile_link_flags` now sets the target in linker arguments when building against Apple SDKs Addresses rdar://64911978
1 parent 337c4e8 commit d285123

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

cmake/modules/AddSwift.cmake

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ function(_add_host_variant_c_compile_link_flags name)
8888
MACCATALYST_BUILD_FLAVOR ""
8989
DEPLOYMENT_VERSION "${DEPLOYMENT_VERSION}")
9090
target_compile_options(${name} PRIVATE -target;${target})
91+
target_link_options(${name} PRIVATE -target;${target})
9192
endif()
9293

9394
set(_sysroot
@@ -470,6 +471,7 @@ function(add_swift_host_library name)
470471

471472
_add_host_variant_c_compile_flags(${name})
472473
_add_host_variant_link_flags(${name})
474+
_add_host_variant_c_compile_link_flags(${name})
473475
_set_target_prefix_and_suffix(${name} "${libkind}" "${SWIFT_HOST_VARIANT_SDK}")
474476

475477
# Set compilation and link flags.
@@ -526,11 +528,6 @@ function(add_swift_host_library name)
526528
target_link_options(${name} PRIVATE
527529
"LINKER:-current_version,${SWIFT_COMPILER_VERSION}")
528530
endif()
529-
530-
get_target_triple(target target_variant "${SWIFT_HOST_VARIANT_SDK}" "${SWIFT_HOST_VARIANT_ARCH}"
531-
MACCATALYST_BUILD_FLAVOR ""
532-
DEPLOYMENT_VERSION "${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_DEPLOYMENT_VERSION}")
533-
target_link_options(${name} PRIVATE -target;${target})
534531
endif()
535532

536533
add_dependencies(dev ${name})
@@ -575,6 +572,7 @@ function(add_swift_host_tool executable)
575572
add_executable(${executable} ${ASHT_UNPARSED_ARGUMENTS})
576573
_add_host_variant_c_compile_flags(${executable})
577574
_add_host_variant_link_flags(${executable})
575+
_add_host_variant_c_compile_link_flags(${executable})
578576
target_link_directories(${executable} PRIVATE
579577
${SWIFTLIB_DIR}/${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_LIB_SUBDIR})
580578
add_dependencies(${executable} ${LLVM_COMMON_DEPENDS})

0 commit comments

Comments
 (0)