@@ -548,11 +548,11 @@ function(_add_swift_runtime_link_flags target relpath_to_lib_dir bootstrapping)
548548 target_link_libraries (${target} PRIVATE "swiftCore" )
549549
550550 target_link_directories (${target} PRIVATE ${host_lib_dir} )
551- if (ASRLF_BOOTSTRAPPING_MODE STREQUAL "HOSTTOOLS" )
552- set (swift_runtime_rpath " ${host_lib_dir} " )
553- else ()
554- set (swift_runtime_rpath "$ORIGIN/ ${relpath_to_lib_dir} /swift/${SWIFT_SDK_ ${SWIFT_HOST_VARIANT_SDK} _LIB_SUBDIR}" )
555- endif ( )
551+
552+ # At runtime, use swiftCore in the current toolchain.
553+ # For building stdlib, LD_LIBRARY_PATH will be set to builder's stdlib
554+ # FIXME: This assumes the ABI hasn't changed since the builder.
555+ set (swift_runtime_rpath "$ORIGIN/ ${relpath_to_lib_dir} /swift/${SWIFT_SDK_ ${SWIFT_HOST_VARIANT_SDK} _LIB_SUBDIR}" )
556556
557557 elseif (ASRLF_BOOTSTRAPPING_MODE STREQUAL "BOOTSTRAPPING" )
558558 # At build time link against the built swift libraries from the
@@ -576,9 +576,6 @@ function(_add_swift_runtime_link_flags target relpath_to_lib_dir bootstrapping)
576576 endif ()
577577
578578 if (SWIFT_SWIFT_PARSER)
579- # Make sure we can find the early SwiftSyntax libraries.
580- target_link_directories (${target} PRIVATE "${SWIFT_PATH_TO_EARLYSWIFTSYNTAX_BUILD_DIR} /lib/swift/host" )
581-
582579 # For the "end step" of bootstrapping configurations, we need to be
583580 # able to fall back to the SDK directory for libswiftCore et al.
584581 if (BOOTSTRAPPING_MODE MATCHES "BOOTSTRAPPING.*" )
@@ -832,8 +829,43 @@ macro(add_swift_lib_subdirectory name)
832829 add_llvm_subdirectory(SWIFT LIB ${name} )
833830endmacro ()
834831
832+ # Add a new Swift host executable.
833+ #
834+ # Usage:
835+ # add_swift_host_tool(name
836+ # [HAS_SWIFT_MODULES | DOES_NOT_USE_SWIFT]
837+ # [THINLTO_LD64_ADD_FLTO_CODEGEN_ONLY]
838+ #
839+ # [BOOTSTRAPPING 0|1]
840+ # [SWIFT_COMPONENT component]
841+ # [LLVM_LINK_COMPONENTS comp1 ...]
842+ # source1 [source2 source3 ...])
843+ #
844+ # name
845+ # Name of the executable (e.g., swift-frontend).
846+ #
847+ # HAS_SWIFT_MODULES
848+ # Whether to link with SwiftCompilerSources library
849+ #
850+ # DOES_NOT_USE_SWIFT
851+ # Do not link with swift runtime
852+ #
853+ # THINLTO_LD64_ADD_FLTO_CODEGEN_ONLY
854+ # Opt-out of LLVM IR optimizations when linking ThinLTO with ld64
855+ #
856+ # BOOTSTRAPPING
857+ # Bootstrapping stage.
858+ #
859+ # SWIFT_COMPONENT
860+ # Installation component where this tool belongs to.
861+ #
862+ # LLVM_LINK_COMPONENTS
863+ # LLVM components this library depends on.
864+ #
865+ # source1 ...
866+ # Sources to add into this executable.
835867function (add_swift_host_tool executable)
836- set (options HAS_SWIFT_MODULES THINLTO_LD64_ADD_FLTO_CODEGEN_ONLY)
868+ set (options HAS_SWIFT_MODULES DOES_NOT_USE_SWIFT THINLTO_LD64_ADD_FLTO_CODEGEN_ONLY)
837869 set (single_parameter_options SWIFT_COMPONENT BOOTSTRAPPING)
838870 set (multiple_parameter_options LLVM_LINK_COMPONENTS)
839871
@@ -889,12 +921,12 @@ function(add_swift_host_tool executable)
889921 endif ()
890922
891923 # Once the new Swift parser is linked in, every host tool has Swift modules.
892- if (SWIFT_SWIFT_PARSER)
924+ if (SWIFT_SWIFT_PARSER AND NOT ASHT_DOES_NOT_USE_SWIFT )
893925 set (ASHT_HAS_SWIFT_MODULES ON )
894926 endif ()
895927
896928 if (ASHT_HAS_SWIFT_MODULES)
897- _add_swift_runtime_link_flags(${executable} "../lib" "${ASHT_BOOTSTRAPPING} " )
929+ _add_swift_runtime_link_flags(${executable} "../lib" "${ASHT_BOOTSTRAPPING} " )
898930 endif ()
899931
900932 llvm_update_compile_flags(${executable} )
@@ -967,7 +999,8 @@ function(add_swift_host_tool executable)
967999 swift_install_in_component(TARGETS ${executable}
9681000 RUNTIME
9691001 DESTINATION bin
970- COMPONENT ${ASHT_SWIFT_COMPONENT} )
1002+ COMPONENT ${ASHT_SWIFT_COMPONENT}
1003+ )
9711004
9721005 swift_is_installing_component(${ASHT_SWIFT_COMPONENT} is_installing)
9731006 endif ()
0 commit comments