@@ -180,7 +180,8 @@ function(_add_host_variant_c_compile_flags target)
180180 target_compile_options (${target} PRIVATE -g)
181181 endif ()
182182 else ()
183- target_compile_options (${target} PRIVATE -g0)
183+ target_compile_options (${target} PRIVATE $<$<COMPILE_LANGUAGE:C,CXX,OBJC,OBJCXX>:-g0>)
184+ target_compile_options (${target} PRIVATE $<$<COMPILE_LANGUAGE:Swift>:-gnone>)
184185 endif ()
185186 endif ()
186187
@@ -633,6 +634,19 @@ function(add_swift_host_tool executable)
633634 JOB_POOL_LINK swift_link_job_pool)
634635 endif ()
635636 if (${SWIFT_HOST_VARIANT_SDK} IN_LIST SWIFT_APPLE_PLATFORMS)
637+ # If we found a swift compiler and are going to use swift code in swift
638+ # host side tools but link with clang, add the appropriate -L paths so we
639+ # find all of the necessary swift libraries on Darwin.
640+ if (CMAKE_Swift_COMPILER)
641+ # Add in the SDK directory for the host platform and add an rpath.
642+ target_link_directories (${executable} PRIVATE
643+ ${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK} _ARCH_${SWIFT_HOST_VARIANT_ARCH} _PATH}/usr/lib/swift)
644+ # Add in the toolchain directory so we can grab compatibility libraries
645+ get_filename_component (TOOLCHAIN_BIN_DIR ${CMAKE_Swift_COMPILER} DIRECTORY )
646+ get_filename_component (TOOLCHAIN_LIB_DIR "${TOOLCHAIN_BIN_DIR} /../lib/swift/macosx" ABSOLUTE )
647+ target_link_directories (${executable} PUBLIC ${TOOLCHAIN_LIB_DIR} )
648+ endif ()
649+
636650 # Lists of rpaths that we are going to add to our executables.
637651 #
638652 # Please add each rpath separately below to the list, explaining why you are
@@ -644,8 +658,8 @@ function(add_swift_host_tool executable)
644658 # contain swift content.
645659 list (APPEND RPATH_LIST "@executable_path/../lib" )
646660
647- # Also include the swift specific resource dir in our rpath.
648- list (APPEND RPATH_LIST "@executable_path/.. /lib/swift/${SWIFT_SDK_ ${SWIFT_HOST_VARIANT_SDK} _LIB_SUBDIR} " )
661+ # Also include the abi stable system stdlib in our rpath.
662+ list (APPEND RPATH_LIST "/usr /lib/swift" )
649663
650664 set_target_properties (${executable} PROPERTIES
651665 BUILD_WITH_INSTALL_RPATH YES
0 commit comments