@@ -545,11 +545,11 @@ function(_add_swift_runtime_link_flags target relpath_to_lib_dir bootstrapping)
545
545
target_link_libraries (${target} PRIVATE "swiftCore" )
546
546
547
547
target_link_directories (${target} PRIVATE ${host_lib_dir} )
548
- if (ASRLF_BOOTSTRAPPING_MODE STREQUAL "HOSTTOOLS" )
549
- set (swift_runtime_rpath " ${host_lib_dir} " )
550
- else ()
551
- set (swift_runtime_rpath "$ORIGIN/ ${relpath_to_lib_dir} /swift/${SWIFT_SDK_ ${SWIFT_HOST_VARIANT_SDK} _LIB_SUBDIR}" )
552
- endif ( )
548
+
549
+ # At runtime, use swiftCore in the current toolchain.
550
+ # For building stdlib, LD_LIBRARY_PATH will be set to builder's stdlib
551
+ # FIXME: This assumes the ABI hasn't changed since the builder.
552
+ set (swift_runtime_rpath "$ORIGIN/ ${relpath_to_lib_dir} /swift/${SWIFT_SDK_ ${SWIFT_HOST_VARIANT_SDK} _LIB_SUBDIR}" )
553
553
554
554
elseif (ASRLF_BOOTSTRAPPING_MODE STREQUAL "BOOTSTRAPPING" )
555
555
# At build time link against the built swift libraries from the
@@ -573,10 +573,7 @@ function(_add_swift_runtime_link_flags target relpath_to_lib_dir bootstrapping)
573
573
endif ()
574
574
575
575
if (SWIFT_SWIFT_PARSER)
576
- # Make sure we can find the early SwiftSyntax libraries.
577
- target_link_directories (${target} PRIVATE "${SWIFT_PATH_TO_EARLYSWIFTSYNTAX_BUILD_DIR} /lib/swift/host" )
578
-
579
- # For the "end step" of bootstrapping configurations on Darwin, need to be
576
+ # For the "end step" of bootstrapping configurations, we need to be
580
577
# able to fall back to the SDK directory for libswiftCore et al.
581
578
if (BOOTSTRAPPING_MODE MATCHES "BOOTSTRAPPING.*" )
582
579
if (NOT "${bootstrapping} " STREQUAL "1" )
@@ -590,6 +587,13 @@ function(_add_swift_runtime_link_flags target relpath_to_lib_dir bootstrapping)
590
587
get_filename_component (TOOLCHAIN_BIN_DIR ${SWIFT_EXEC_FOR_SWIFT_MODULES} DIRECTORY )
591
588
get_filename_component (TOOLCHAIN_LIB_DIR "${TOOLCHAIN_BIN_DIR} /../lib/swift/${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK} _LIB_SUBDIR}" ABSOLUTE )
592
589
target_link_directories (${target} PUBLIC ${TOOLCHAIN_LIB_DIR} )
590
+ else ()
591
+ get_filename_component (swift_bin_dir ${SWIFT_EXEC_FOR_SWIFT_MODULES} DIRECTORY )
592
+ get_filename_component (swift_dir ${swift_bin_dir} DIRECTORY )
593
+ set (host_lib_dir "${swift_dir} /lib/swift/${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK} _LIB_SUBDIR}" )
594
+ target_link_directories (${target} PRIVATE ${host_lib_dir} )
595
+
596
+ set (swift_runtime_rpath "${host_lib_dir} " )
593
597
endif ()
594
598
endif ()
595
599
endif ()
@@ -822,8 +826,43 @@ macro(add_swift_lib_subdirectory name)
822
826
add_llvm_subdirectory(SWIFT LIB ${name} )
823
827
endmacro ()
824
828
829
+ # Add a new Swift host executable.
830
+ #
831
+ # Usage:
832
+ # add_swift_host_tool(name
833
+ # [HAS_SWIFT_MODULES | DOES_NOT_USE_SWIFT]
834
+ # [THINLTO_LD64_ADD_FLTO_CODEGEN_ONLY]
835
+ #
836
+ # [BOOTSTRAPPING 0|1]
837
+ # [SWIFT_COMPONENT component]
838
+ # [LLVM_LINK_COMPONENTS comp1 ...]
839
+ # source1 [source2 source3 ...])
840
+ #
841
+ # name
842
+ # Name of the executable (e.g., swift-frontend).
843
+ #
844
+ # HAS_SWIFT_MODULES
845
+ # Whether to link with SwiftCompilerSources library
846
+ #
847
+ # DOES_NOT_USE_SWIFT
848
+ # Do not link with swift runtime
849
+ #
850
+ # THINLTO_LD64_ADD_FLTO_CODEGEN_ONLY
851
+ # Opt-out of LLVM IR optimizations when linking ThinLTO with ld64
852
+ #
853
+ # BOOTSTRAPPING
854
+ # Bootstrapping stage.
855
+ #
856
+ # SWIFT_COMPONENT
857
+ # Installation component where this tool belongs to.
858
+ #
859
+ # LLVM_LINK_COMPONENTS
860
+ # LLVM components this library depends on.
861
+ #
862
+ # source1 ...
863
+ # Sources to add into this executable.
825
864
function (add_swift_host_tool executable)
826
- set (options HAS_SWIFT_MODULES THINLTO_LD64_ADD_FLTO_CODEGEN_ONLY)
865
+ set (options HAS_SWIFT_MODULES DOES_NOT_USE_SWIFT THINLTO_LD64_ADD_FLTO_CODEGEN_ONLY)
827
866
set (single_parameter_options SWIFT_COMPONENT BOOTSTRAPPING)
828
867
set (multiple_parameter_options LLVM_LINK_COMPONENTS)
829
868
@@ -879,12 +918,12 @@ function(add_swift_host_tool executable)
879
918
endif ()
880
919
881
920
# Once the new Swift parser is linked in, every host tool has Swift modules.
882
- if (SWIFT_SWIFT_PARSER)
921
+ if (SWIFT_SWIFT_PARSER AND NOT ASHT_DOES_NOT_USE_SWIFT )
883
922
set (ASHT_HAS_SWIFT_MODULES ON )
884
923
endif ()
885
924
886
925
if (ASHT_HAS_SWIFT_MODULES)
887
- _add_swift_runtime_link_flags(${executable} "../lib" "${ASHT_BOOTSTRAPPING} " )
926
+ _add_swift_runtime_link_flags(${executable} "../lib" "${ASHT_BOOTSTRAPPING} " )
888
927
endif ()
889
928
890
929
llvm_update_compile_flags(${executable} )
@@ -926,10 +965,17 @@ function(add_swift_host_tool executable)
926
965
endif ()
927
966
endif ()
928
967
929
- set_property (
930
- TARGET ${executable}
931
- APPEND PROPERTY INSTALL_RPATH
932
- "@executable_path/../${extra_relative_rpath} lib/swift/host" )
968
+ if (${SWIFT_HOST_VARIANT_SDK} IN_LIST SWIFT_DARWIN_PLATFORMS)
969
+ set_property (
970
+ TARGET ${executable}
971
+ APPEND PROPERTY INSTALL_RPATH
972
+ "@executable_path/../${extra_relative_rpath} lib/swift/host" )
973
+ else ()
974
+ set_property (
975
+ TARGET ${executable}
976
+ APPEND PROPERTY INSTALL_RPATH
977
+ "$ORIGIN/../${extra_relative_rpath} lib/swift/host" )
978
+ endif ()
933
979
endif ()
934
980
935
981
if (ASHT_THINLTO_LD64_ADD_FLTO_CODEGEN_ONLY)
@@ -950,7 +996,8 @@ function(add_swift_host_tool executable)
950
996
swift_install_in_component(TARGETS ${executable}
951
997
RUNTIME
952
998
DESTINATION bin
953
- COMPONENT ${ASHT_SWIFT_COMPONENT} )
999
+ COMPONENT ${ASHT_SWIFT_COMPONENT}
1000
+ )
954
1001
955
1002
swift_is_installing_component(${ASHT_SWIFT_COMPONENT} is_installing)
956
1003
endif ()
0 commit comments