@@ -576,7 +576,7 @@ function(_add_swift_runtime_link_flags target relpath_to_lib_dir bootstrapping)
576576 # Make sure we can find the early SwiftSyntax libraries.
577577 target_link_directories (${target} PRIVATE "${SWIFT_PATH_TO_EARLYSWIFTSYNTAX_BUILD_DIR} /lib/swift/host" )
578578
579- # For the "end step" of bootstrapping configurations on Darwin, need to be
579+ # For the "end step" of bootstrapping configurations, we need to be
580580 # able to fall back to the SDK directory for libswiftCore et al.
581581 if (BOOTSTRAPPING_MODE MATCHES "BOOTSTRAPPING.*" )
582582 if (NOT "${bootstrapping} " STREQUAL "1" )
@@ -590,6 +590,13 @@ function(_add_swift_runtime_link_flags target relpath_to_lib_dir bootstrapping)
590590 get_filename_component (TOOLCHAIN_BIN_DIR ${SWIFT_EXEC_FOR_SWIFT_MODULES} DIRECTORY )
591591 get_filename_component (TOOLCHAIN_LIB_DIR "${TOOLCHAIN_BIN_DIR} /../lib/swift/${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK} _LIB_SUBDIR}" ABSOLUTE )
592592 target_link_directories (${target} PUBLIC ${TOOLCHAIN_LIB_DIR} )
593+ else ()
594+ get_filename_component (swift_bin_dir ${SWIFT_EXEC_FOR_SWIFT_MODULES} DIRECTORY )
595+ get_filename_component (swift_dir ${swift_bin_dir} DIRECTORY )
596+ set (host_lib_dir "${swift_dir} /lib/swift/${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK} _LIB_SUBDIR}" )
597+ target_link_directories (${target} PRIVATE ${host_lib_dir} )
598+
599+ set (swift_runtime_rpath "${host_lib_dir} " )
593600 endif ()
594601 endif ()
595602 endif ()
@@ -926,10 +933,17 @@ function(add_swift_host_tool executable)
926933 endif ()
927934 endif ()
928935
929- set_property (
930- TARGET ${executable}
931- APPEND PROPERTY INSTALL_RPATH
932- "@executable_path/../${extra_relative_rpath} lib/swift/host" )
936+ if (${SWIFT_HOST_VARIANT_SDK} IN_LIST SWIFT_DARWIN_PLATFORMS)
937+ set_property (
938+ TARGET ${executable}
939+ APPEND PROPERTY INSTALL_RPATH
940+ "@executable_path/../${extra_relative_rpath} lib/swift/host" )
941+ else ()
942+ set_property (
943+ TARGET ${executable}
944+ APPEND PROPERTY INSTALL_RPATH
945+ "$ORIGIN/../${extra_relative_rpath} lib/swift/host" )
946+ endif ()
933947 endif ()
934948
935949 if (ASHT_THINLTO_LD64_ADD_FLTO_CODEGEN_ONLY)
0 commit comments