@@ -600,13 +600,22 @@ function(add_swift_host_library name)
600
600
# find all of the necessary swift libraries on Darwin.
601
601
if (NOT ASHL_PURE_SWIFT)
602
602
if (CMAKE_Swift_COMPILER)
603
- # Add in the SDK directory for the host platform and add an rpath.
604
- target_link_directories(${name} PRIVATE
605
- ${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK} _ARCH_${SWIFT_HOST_VARIANT_ARCH} _PATH}/usr/lib/swift)
606
603
# Add in the toolchain directory so we can grab compatibility libraries
607
604
get_filename_component(TOOLCHAIN_BIN_DIR ${CMAKE_Swift_COMPILER} DIRECTORY)
608
605
get_filename_component(TOOLCHAIN_LIB_DIR " ${TOOLCHAIN_BIN_DIR} /../lib/swift/macosx " ABSOLUTE)
609
606
target_link_directories(${name} PUBLIC ${TOOLCHAIN_LIB_DIR} )
607
+
608
+ # Add in the SDK directory for the host platform.
609
+ #
610
+ # NOTE: We do this /after/ target_link_directorying TOOLCHAIN_LIB_DIR to
611
+ # ensure that we first find libraries from the toolchain, rather than
612
+ # from the SDK. The reason why this is important is that when we perform
613
+ # a stage2 build, this path is into the stage1 build. This is not a pure
614
+ # SDK and also contains compatibility libraries. We need to make sure
615
+ # that the compiler sees the actual toolchain's compatibility libraries
616
+ # first before the just built compability libraries or build errors occur.
617
+ target_link_directories(${name} PRIVATE
618
+ ${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK} _ARCH_${SWIFT_HOST_VARIANT_ARCH} _PATH}/usr/lib/swift)
610
619
endif()
611
620
endif()
612
621
@@ -808,14 +817,23 @@ function(add_swift_host_tool executable)
808
817
# host side tools but link with clang, add the appropriate -L paths so we
809
818
# find all of the necessary swift libraries on Darwin.
810
819
if (CMAKE_Swift_COMPILER)
811
- # Add in the SDK directory for the host platform and add an rpath.
812
- target_link_directories(${executable} PRIVATE
813
- ${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK} _ARCH_${SWIFT_HOST_VARIANT_ARCH} _PATH}/usr/lib/swift)
814
820
# Add in the toolchain directory so we can grab compatibility libraries
815
821
get_filename_component(TOOLCHAIN_BIN_DIR ${CMAKE_Swift_COMPILER} DIRECTORY)
816
822
get_filename_component(TOOLCHAIN_LIB_DIR " ${TOOLCHAIN_BIN_DIR} /../lib/swift/macosx " ABSOLUTE)
817
823
target_link_directories(${executable} PUBLIC ${TOOLCHAIN_LIB_DIR} )
818
824
825
+ # Add in the SDK directory for the host platform and add an rpath.
826
+ #
827
+ # NOTE: We do this /after/ target_link_directorying TOOLCHAIN_LIB_DIR to
828
+ # ensure that we first find libraries from the toolchain, rather than from
829
+ # the SDK. The reason why this is important is that when we perform a
830
+ # stage2 build, this path is into the stage1 build. This is not a pure SDK
831
+ # and also contains compatibility libraries. We need to make sure that the
832
+ # compiler sees the actual toolchain's compatibility libraries first
833
+ # before the just built compability libraries or build errors occur.
834
+ target_link_directories(${executable} PRIVATE
835
+ ${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK} _ARCH_${SWIFT_HOST_VARIANT_ARCH} _PATH}/usr/lib/swift)
836
+
819
837
if (ASHT_HAS_LIBSWIFT AND SWIFT_TOOLS_ENABLE_LIBSWIFT)
820
838
# Workaround to make lldb happy: we have to explicitly add all libswift modules
821
839
# to the linker command line.
0 commit comments