@@ -440,7 +440,7 @@ function(_add_host_variant_link_flags target)
440440 endif ()
441441endfunction ()
442442
443- function (_add_swift_runtime_link_flags target relpath_to_lib_dir bootstrapping)
443+ function (_add_swift_runtime_link_flags target relpath_to_lib_dir bootstrapping required_for_minimal_compiler )
444444 if (NOT BOOTSTRAPPING_MODE)
445445 if (SWIFT_SWIFT_PARSER)
446446 set (ASRLF_BOOTSTRAPPING_MODE "HOSTTOOLS" )
@@ -553,7 +553,7 @@ function(_add_swift_runtime_link_flags target relpath_to_lib_dir bootstrapping)
553553 # FIXME: This assumes the ABI hasn't changed since the builder.
554554 set (swift_runtime_rpath "$ORIGIN/${relpath_to_lib_dir} /swift/${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK} _LIB_SUBDIR}" )
555555
556- if (ASRLF_BOOTSTRAPPING_MODE STREQUAL "HOSTTOOLS" )
556+ if (ASRLF_BOOTSTRAPPING_MODE STREQUAL "HOSTTOOLS" AND required_for_minimal_compiler )
557557 # But before building the stdlib with the tool, use the builder libs. This should be removed in install time.
558558 list (APPEND swift_runtime_rpath "${host_lib_dir} " )
559559 endif ()
@@ -745,7 +745,7 @@ function(add_swift_host_library name)
745745 _set_target_prefix_and_suffix(${name} "${libkind} " "${SWIFT_HOST_VARIANT_SDK} " )
746746
747747 if (ASHL_SHARED AND ASHL_HAS_SWIFT_MODULES)
748- _add_swift_runtime_link_flags(${name} "." "" )
748+ _add_swift_runtime_link_flags(${name} "." "" FALSE )
749749 endif ()
750750
751751 # Set compilation and link flags.
@@ -833,8 +833,44 @@ macro(add_swift_lib_subdirectory name)
833833 add_llvm_subdirectory(SWIFT LIB ${name} )
834834endmacro ()
835835
836+ # Add a new Swift host executable.
837+ #
838+ # Usage:
839+ # add_swift_host_tool(name
840+ # [HAS_SWIFT_MODULES]
841+ # [THINLTO_LD64_ADD_FLTO_CODEGEN_ONLY]
842+ # [REQUIRED_FOR_MINIMAL_COMPILER]
843+ #
844+ # [BOOTSTRAPPING 0|1]
845+ # [SWIFT_COMPONENT component]
846+ # [LLVM_LINK_COMPONENTS comp1 ...]
847+ # source1 [source2 source3 ...])
848+ #
849+ # name
850+ # Name of the executable (e.g., swift-frontend).
851+ #
852+ # HAS_SWIFT_MODULES
853+ # Whether to link with SwiftCompilerSources library
854+ #
855+ # THINLTO_LD64_ADD_FLTO_CODEGEN_ONLY
856+ # Opt-out of LLVM IR optimizations when linking ThinLTO with ld64
857+ #
858+ # REQUIRED_FOR_MINIMAL_COMPILER
859+ # Required for building standard libraries.
860+ #
861+ # BOOTSTRAPPING
862+ # Bootstrapping stage.
863+ #
864+ # SWIFT_COMPONENT
865+ # Installation component where this tool belongs to.
866+ #
867+ # LLVM_LINK_COMPONENTS
868+ # LLVM components this library depends on.
869+ #
870+ # source1 ...
871+ # Sources to add into this executable.
836872function (add_swift_host_tool executable)
837- set (options HAS_SWIFT_MODULES THINLTO_LD64_ADD_FLTO_CODEGEN_ONLY)
873+ set (options HAS_SWIFT_MODULES THINLTO_LD64_ADD_FLTO_CODEGEN_ONLY REQUIRED_FOR_MINIMAL_COMPILER )
838874 set (single_parameter_options SWIFT_COMPONENT BOOTSTRAPPING)
839875 set (multiple_parameter_options LLVM_LINK_COMPONENTS)
840876
@@ -895,7 +931,7 @@ function(add_swift_host_tool executable)
895931 endif ()
896932
897933 if (ASHT_HAS_SWIFT_MODULES)
898- _add_swift_runtime_link_flags(${executable} "../lib" "${ASHT_BOOTSTRAPPING} " )
934+ _add_swift_runtime_link_flags(${executable} "../lib" "${ASHT_BOOTSTRAPPING} " " ${ASHT_REQUIRED_FOR_MINIMAL_COMPILER } " )
899935 endif ()
900936
901937 llvm_update_compile_flags(${executable} )
@@ -971,11 +1007,13 @@ function(add_swift_host_tool executable)
9711007 COMPONENT ${ASHT_SWIFT_COMPONENT}
9721008 )
9731009
974- swift_install_strip_builder_rpath(
975- TARGETS ${executable}
976- DESTINATION bin
977- COMPONENT ${ASHT_SWIFT_COMPONENT}
978- )
1010+ if (ASHT_REQUIRED_FOR_MINIMAL_COMPILER)
1011+ swift_install_strip_builder_rpath(
1012+ TARGETS ${executable}
1013+ DESTINATION bin
1014+ COMPONENT ${ASHT_SWIFT_COMPONENT}
1015+ )
1016+ endif ()
9791017
9801018 swift_is_installing_component(${ASHT_SWIFT_COMPONENT} is_installing)
9811019 endif ()
0 commit comments