@@ -153,12 +153,17 @@ function(add_sourcekit_swift_runtime_link_flags target path HAS_SWIFT_MODULES)
153153 message (FATAL_ERROR "Unknown ASKD_BOOTSTRAPPING_MODE '${ASKD_BOOTSTRAPPING_MODE} '" )
154154 endif ()
155155 endif ()
156- set (RPATH_LIST ${RPATH_LIST} PARENT_SCOPE)
157156
158157 if (SWIFT_SWIFT_PARSER)
159158 # Make sure we can find the early SwiftSyntax libraries.
160159 target_link_directories (${target} PRIVATE "${SWIFT_PATH_TO_EARLYSWIFTSYNTAX_BUILD_DIR} /lib/swift/host" )
161160
161+ # Add rpath to the host Swift libraries.
162+ if (NOT ${SWIFT_HOST_VARIANT_SDK} IN_LIST SWIFT_DARWIN_PLATFORMS)
163+ file (RELATIVE_PATH relative_hostlib_path "${path} " "${SWIFTLIB_DIR} /host" )
164+ list (APPEND RPATH_LIST "$ORIGIN/${relative_hostlib_path} " )
165+ endif ()
166+
162167 # For the "end step" of bootstrapping configurations on Darwin, need to be
163168 # able to fall back to the SDK directory for libswiftCore et al.
164169 if (BOOTSTRAPPING_MODE MATCHES "BOOTSTRAPPING.*" )
@@ -173,10 +178,19 @@ function(add_sourcekit_swift_runtime_link_flags target path HAS_SWIFT_MODULES)
173178 get_filename_component (TOOLCHAIN_BIN_DIR ${SWIFT_EXEC_FOR_SWIFT_MODULES} DIRECTORY )
174179 get_filename_component (TOOLCHAIN_LIB_DIR "${TOOLCHAIN_BIN_DIR} /../lib/swift/${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK} _LIB_SUBDIR}" ABSOLUTE )
175180 target_link_directories (${target} PUBLIC ${TOOLCHAIN_LIB_DIR} )
181+ else ()
182+ get_filename_component (swift_bin_dir ${SWIFT_EXEC_FOR_SWIFT_MODULES} DIRECTORY )
183+ get_filename_component (swift_dir ${swift_bin_dir} DIRECTORY )
184+ set (host_lib_dir "${swift_dir} /lib/swift/${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK} _LIB_SUBDIR}" )
185+ target_link_directories (${target} PUBLIC ${host_lib_dir} )
186+
187+ list (APPEND RPATH_LIST "${host_lib_dir} " )
176188 endif ()
177189 endif ()
178190 endif ()
179191 endif ()
192+
193+ set (RPATH_LIST ${RPATH_LIST} PARENT_SCOPE)
180194endfunction ()
181195
182196# Add a new SourceKit library.
0 commit comments