@@ -477,7 +477,17 @@ function(add_swift_host_library name)
477477 endif ()
478478
479479 add_library (${name} ${libkind} ${ASHL_SOURCES} )
480- add_dependencies (${name} ${LLVM_COMMON_DEPENDS} )
480+
481+ # Respect LLVM_COMMON_DEPENDS if it is set.
482+ #
483+ # LLVM_COMMON_DEPENDS if a global variable set in ./lib that provides targets
484+ # such as swift-syntax or tblgen that all LLVM/Swift based tools depend on. If
485+ # we don't have it defined, then do not add the dependency since some parts of
486+ # swift host tools do not interact with LLVM/Swift tools and do not define
487+ # LLVM_COMMON_DEPENDS.
488+ if (LLVM_COMMON_DEPENDS)
489+ add_dependencies (${name} ${LLVM_COMMON_DEPENDS} )
490+ endif ()
481491 if (NOT ASHL_PURE_SWIFT)
482492 llvm_update_compile_flags(${name} )
483493 endif ()
@@ -624,12 +634,21 @@ function(add_swift_host_tool executable)
624634 _add_host_variant_c_compile_flags(${executable} )
625635 _add_host_variant_link_flags(${executable} )
626636 _add_host_variant_c_compile_link_flags(${executable} )
627- target_link_directories (${executable} PRIVATE
628- ${SWIFTLIB_DIR} /${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK} _LIB_SUBDIR})
637+
629638 # Force executables linker language to be CXX so that we do not link using the
630639 # host toolchain swiftc.
631640 set_target_properties (${executable} PROPERTIES LINKER_LANGUAGE CXX)
632- add_dependencies (${executable} ${LLVM_COMMON_DEPENDS} )
641+
642+ # Respect LLVM_COMMON_DEPENDS if it is set.
643+ #
644+ # LLVM_COMMON_DEPENDS if a global variable set in ./lib that provides targets
645+ # such as swift-syntax or tblgen that all LLVM/Swift based tools depend on. If
646+ # we don't have it defined, then do not add the dependency since some parts of
647+ # swift host tools do not interact with LLVM/Swift tools and do not define
648+ # LLVM_COMMON_DEPENDS.
649+ if (LLVM_COMMON_DEPENDS)
650+ add_dependencies (${executable} ${LLVM_COMMON_DEPENDS} )
651+ endif ()
633652
634653 set_target_properties (${executable} PROPERTIES
635654 FOLDER "Swift executables" )
0 commit comments