mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Avoid adding redundant temporary RUNPATH to builder's stdlib
Many shared libs and executables are only run after stdlib/runtime are built. They don't need to link with builders stdlib at all.
This commit is contained in:
@@ -80,8 +80,7 @@ function(_set_pure_swift_link_flags name relpath_to_lib_dir)
|
|||||||
APPEND PROPERTY INSTALL_RPATH
|
APPEND PROPERTY INSTALL_RPATH
|
||||||
# At runtime, use swiftCore in the current toolchain.
|
# At runtime, use swiftCore in the current toolchain.
|
||||||
"$ORIGIN/${relpath_to_lib_dir}/swift/${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_LIB_SUBDIR}"
|
"$ORIGIN/${relpath_to_lib_dir}/swift/${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_LIB_SUBDIR}"
|
||||||
# But before building the stdlib with the tool, use the builder libs. This should be removed in install time.
|
)
|
||||||
"${host_lib_dir}")
|
|
||||||
|
|
||||||
endif()
|
endif()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|||||||
@@ -440,7 +440,7 @@ function(_add_host_variant_link_flags target)
|
|||||||
endif()
|
endif()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
function(_add_swift_runtime_link_flags target relpath_to_lib_dir bootstrapping)
|
function(_add_swift_runtime_link_flags target relpath_to_lib_dir bootstrapping required_for_minimal_compiler)
|
||||||
if(NOT BOOTSTRAPPING_MODE)
|
if(NOT BOOTSTRAPPING_MODE)
|
||||||
if (SWIFT_SWIFT_PARSER)
|
if (SWIFT_SWIFT_PARSER)
|
||||||
set(ASRLF_BOOTSTRAPPING_MODE "HOSTTOOLS")
|
set(ASRLF_BOOTSTRAPPING_MODE "HOSTTOOLS")
|
||||||
@@ -553,7 +553,7 @@ function(_add_swift_runtime_link_flags target relpath_to_lib_dir bootstrapping)
|
|||||||
# FIXME: This assumes the ABI hasn't changed since the builder.
|
# FIXME: This assumes the ABI hasn't changed since the builder.
|
||||||
set(swift_runtime_rpath "$ORIGIN/${relpath_to_lib_dir}/swift/${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_LIB_SUBDIR}")
|
set(swift_runtime_rpath "$ORIGIN/${relpath_to_lib_dir}/swift/${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_LIB_SUBDIR}")
|
||||||
|
|
||||||
if(ASRLF_BOOTSTRAPPING_MODE STREQUAL "HOSTTOOLS")
|
if(ASRLF_BOOTSTRAPPING_MODE STREQUAL "HOSTTOOLS" AND required_for_minimal_compiler)
|
||||||
# But before building the stdlib with the tool, use the builder libs. This should be removed in install time.
|
# But before building the stdlib with the tool, use the builder libs. This should be removed in install time.
|
||||||
list(APPEND swift_runtime_rpath "${host_lib_dir}")
|
list(APPEND swift_runtime_rpath "${host_lib_dir}")
|
||||||
endif()
|
endif()
|
||||||
@@ -745,7 +745,7 @@ function(add_swift_host_library name)
|
|||||||
_set_target_prefix_and_suffix(${name} "${libkind}" "${SWIFT_HOST_VARIANT_SDK}")
|
_set_target_prefix_and_suffix(${name} "${libkind}" "${SWIFT_HOST_VARIANT_SDK}")
|
||||||
|
|
||||||
if (ASHL_SHARED AND ASHL_HAS_SWIFT_MODULES)
|
if (ASHL_SHARED AND ASHL_HAS_SWIFT_MODULES)
|
||||||
_add_swift_runtime_link_flags(${name} "." "")
|
_add_swift_runtime_link_flags(${name} "." "" FALSE)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Set compilation and link flags.
|
# Set compilation and link flags.
|
||||||
@@ -833,8 +833,44 @@ macro(add_swift_lib_subdirectory name)
|
|||||||
add_llvm_subdirectory(SWIFT LIB ${name})
|
add_llvm_subdirectory(SWIFT LIB ${name})
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
|
# Add a new Swift host executable.
|
||||||
|
#
|
||||||
|
# Usage:
|
||||||
|
# add_swift_host_tool(name
|
||||||
|
# [HAS_SWIFT_MODULES]
|
||||||
|
# [THINLTO_LD64_ADD_FLTO_CODEGEN_ONLY]
|
||||||
|
# [REQUIRED_FOR_MINIMAL_COMPILER]
|
||||||
|
#
|
||||||
|
# [BOOTSTRAPPING 0|1]
|
||||||
|
# [SWIFT_COMPONENT component]
|
||||||
|
# [LLVM_LINK_COMPONENTS comp1 ...]
|
||||||
|
# source1 [source2 source3 ...])
|
||||||
|
#
|
||||||
|
# name
|
||||||
|
# Name of the executable (e.g., swift-frontend).
|
||||||
|
#
|
||||||
|
# HAS_SWIFT_MODULES
|
||||||
|
# Whether to link with SwiftCompilerSources library
|
||||||
|
#
|
||||||
|
# THINLTO_LD64_ADD_FLTO_CODEGEN_ONLY
|
||||||
|
# Opt-out of LLVM IR optimizations when linking ThinLTO with ld64
|
||||||
|
#
|
||||||
|
# REQUIRED_FOR_MINIMAL_COMPILER
|
||||||
|
# Required for building standard libraries.
|
||||||
|
#
|
||||||
|
# BOOTSTRAPPING
|
||||||
|
# Bootstrapping stage.
|
||||||
|
#
|
||||||
|
# SWIFT_COMPONENT
|
||||||
|
# Installation component where this tool belongs to.
|
||||||
|
#
|
||||||
|
# LLVM_LINK_COMPONENTS
|
||||||
|
# LLVM components this library depends on.
|
||||||
|
#
|
||||||
|
# source1 ...
|
||||||
|
# Sources to add into this executable.
|
||||||
function(add_swift_host_tool executable)
|
function(add_swift_host_tool executable)
|
||||||
set(options HAS_SWIFT_MODULES THINLTO_LD64_ADD_FLTO_CODEGEN_ONLY)
|
set(options HAS_SWIFT_MODULES THINLTO_LD64_ADD_FLTO_CODEGEN_ONLY REQUIRED_FOR_MINIMAL_COMPILER)
|
||||||
set(single_parameter_options SWIFT_COMPONENT BOOTSTRAPPING)
|
set(single_parameter_options SWIFT_COMPONENT BOOTSTRAPPING)
|
||||||
set(multiple_parameter_options LLVM_LINK_COMPONENTS)
|
set(multiple_parameter_options LLVM_LINK_COMPONENTS)
|
||||||
|
|
||||||
@@ -895,7 +931,7 @@ function(add_swift_host_tool executable)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (ASHT_HAS_SWIFT_MODULES)
|
if (ASHT_HAS_SWIFT_MODULES)
|
||||||
_add_swift_runtime_link_flags(${executable} "../lib" "${ASHT_BOOTSTRAPPING}")
|
_add_swift_runtime_link_flags(${executable} "../lib" "${ASHT_BOOTSTRAPPING}" "${ASHT_REQUIRED_FOR_MINIMAL_COMPILER}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
llvm_update_compile_flags(${executable})
|
llvm_update_compile_flags(${executable})
|
||||||
@@ -971,11 +1007,13 @@ function(add_swift_host_tool executable)
|
|||||||
COMPONENT ${ASHT_SWIFT_COMPONENT}
|
COMPONENT ${ASHT_SWIFT_COMPONENT}
|
||||||
)
|
)
|
||||||
|
|
||||||
swift_install_strip_builder_rpath(
|
if (ASHT_REQUIRED_FOR_MINIMAL_COMPILER)
|
||||||
TARGETS ${executable}
|
swift_install_strip_builder_rpath(
|
||||||
DESTINATION bin
|
TARGETS ${executable}
|
||||||
COMPONENT ${ASHT_SWIFT_COMPONENT}
|
DESTINATION bin
|
||||||
)
|
COMPONENT ${ASHT_SWIFT_COMPONENT}
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
swift_is_installing_component(${ASHT_SWIFT_COMPONENT} is_installing)
|
swift_is_installing_component(${ASHT_SWIFT_COMPONENT} is_installing)
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ function(add_swift_unittest test_dirname)
|
|||||||
|
|
||||||
if (SWIFT_SWIFT_PARSER AND NOT ASU_IS_TARGET_TEST)
|
if (SWIFT_SWIFT_PARSER AND NOT ASU_IS_TARGET_TEST)
|
||||||
# Link to stdlib the compiler uses.
|
# Link to stdlib the compiler uses.
|
||||||
_add_swift_runtime_link_flags(${test_dirname} "../../lib" "")
|
_add_swift_runtime_link_flags(${test_dirname} "../../lib" "" FALSE)
|
||||||
set_property(TARGET ${test_dirname} PROPERTY BUILD_WITH_INSTALL_RPATH OFF)
|
set_property(TARGET ${test_dirname} PROPERTY BUILD_WITH_INSTALL_RPATH OFF)
|
||||||
endif()
|
endif()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|||||||
@@ -67,12 +67,6 @@ function(add_swift_macro_library name)
|
|||||||
DESTINATION "${destination_dir}"
|
DESTINATION "${destination_dir}"
|
||||||
COMPONENT compiler)
|
COMPONENT compiler)
|
||||||
|
|
||||||
swift_install_strip_builder_rpath(
|
|
||||||
TARGETS ${name}
|
|
||||||
DESTINATION "${destination_dir}"
|
|
||||||
COMPONENT compiler
|
|
||||||
)
|
|
||||||
|
|
||||||
# Export this macro plugin target.
|
# Export this macro plugin target.
|
||||||
set_property(GLOBAL APPEND PROPERTY SWIFT_MACRO_PLUGINS ${name})
|
set_property(GLOBAL APPEND PROPERTY SWIFT_MACRO_PLUGINS ${name})
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|||||||
@@ -17,10 +17,3 @@ swift_install_in_component(TARGETS swiftDemangle
|
|||||||
ARCHIVE
|
ARCHIVE
|
||||||
DESTINATION "lib${LLVM_LIBDIR_SUFFIX}"
|
DESTINATION "lib${LLVM_LIBDIR_SUFFIX}"
|
||||||
COMPONENT compiler)
|
COMPONENT compiler)
|
||||||
|
|
||||||
|
|
||||||
swift_install_strip_builder_rpath(
|
|
||||||
TARGETS swiftDemangle
|
|
||||||
DESTINATION "lib${LLVM_LIBDIR_SUFFIX}"
|
|
||||||
COMPONENT compiler
|
|
||||||
)
|
|
||||||
|
|||||||
@@ -303,14 +303,6 @@ macro(add_sourcekit_library name)
|
|||||||
DESTINATION "bin"
|
DESTINATION "bin"
|
||||||
COMPONENT "${SOURCEKITLIB_INSTALL_IN_COMPONENT}")
|
COMPONENT "${SOURCEKITLIB_INSTALL_IN_COMPONENT}")
|
||||||
|
|
||||||
if(SOURCEKITLIB_SHARED)
|
|
||||||
swift_install_strip_builder_rpath(
|
|
||||||
TARGETS ${name}
|
|
||||||
DESTINATION "lib${LLVM_LIBDIR_SUFFIX}"
|
|
||||||
COMPONENT "${SOURCEKITLIB_INSTALL_IN_COMPONENT}"
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
swift_install_in_component(FILES ${SOURCEKITLIB_HEADERS}
|
swift_install_in_component(FILES ${SOURCEKITLIB_HEADERS}
|
||||||
DESTINATION "include/SourceKit"
|
DESTINATION "include/SourceKit"
|
||||||
COMPONENT "${SOURCEKITLIB_INSTALL_IN_COMPONENT}")
|
COMPONENT "${SOURCEKITLIB_INSTALL_IN_COMPONENT}")
|
||||||
|
|||||||
@@ -27,9 +27,3 @@ endif()
|
|||||||
add_dependencies(tools complete-test)
|
add_dependencies(tools complete-test)
|
||||||
swift_install_in_component(TARGETS complete-test
|
swift_install_in_component(TARGETS complete-test
|
||||||
RUNTIME DESTINATION bin COMPONENT tools)
|
RUNTIME DESTINATION bin COMPONENT tools)
|
||||||
|
|
||||||
swift_install_strip_builder_rpath(
|
|
||||||
TARGETS complete-test
|
|
||||||
DESTINATION bin
|
|
||||||
COMPONENT tools
|
|
||||||
)
|
|
||||||
|
|||||||
@@ -29,9 +29,3 @@ endif()
|
|||||||
add_dependencies(tools sourcekitd-repl)
|
add_dependencies(tools sourcekitd-repl)
|
||||||
swift_install_in_component(TARGETS sourcekitd-repl
|
swift_install_in_component(TARGETS sourcekitd-repl
|
||||||
RUNTIME DESTINATION bin COMPONENT tools)
|
RUNTIME DESTINATION bin COMPONENT tools)
|
||||||
|
|
||||||
swift_install_strip_builder_rpath(
|
|
||||||
TARGETS sourcekitd-repl
|
|
||||||
DESTINATION bin
|
|
||||||
COMPONENT tools
|
|
||||||
)
|
|
||||||
|
|||||||
@@ -39,9 +39,3 @@ endif()
|
|||||||
add_dependencies(tools sourcekitd-test)
|
add_dependencies(tools sourcekitd-test)
|
||||||
swift_install_in_component(TARGETS sourcekitd-test
|
swift_install_in_component(TARGETS sourcekitd-test
|
||||||
RUNTIME DESTINATION bin COMPONENT tools)
|
RUNTIME DESTINATION bin COMPONENT tools)
|
||||||
|
|
||||||
swift_install_strip_builder_rpath(
|
|
||||||
TARGETS sourcekitd-test
|
|
||||||
DESTINATION bin
|
|
||||||
COMPONENT tools
|
|
||||||
)
|
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ if(BOOTSTRAPPING_MODE MATCHES "BOOTSTRAPPING.*")
|
|||||||
HAS_SWIFT_MODULES
|
HAS_SWIFT_MODULES
|
||||||
BOOTSTRAPPING 0
|
BOOTSTRAPPING 0
|
||||||
THINLTO_LD64_ADD_FLTO_CODEGEN_ONLY
|
THINLTO_LD64_ADD_FLTO_CODEGEN_ONLY
|
||||||
|
REQUIRED_FOR_MINIMAL_COMPILER
|
||||||
)
|
)
|
||||||
target_link_libraries(swift-frontend-bootstrapping0
|
target_link_libraries(swift-frontend-bootstrapping0
|
||||||
PRIVATE
|
PRIVATE
|
||||||
@@ -47,6 +48,7 @@ if(BOOTSTRAPPING_MODE MATCHES "BOOTSTRAPPING.*")
|
|||||||
HAS_SWIFT_MODULES
|
HAS_SWIFT_MODULES
|
||||||
BOOTSTRAPPING 1
|
BOOTSTRAPPING 1
|
||||||
THINLTO_LD64_ADD_FLTO_CODEGEN_ONLY
|
THINLTO_LD64_ADD_FLTO_CODEGEN_ONLY
|
||||||
|
REQUIRED_FOR_MINIMAL_COMPILER
|
||||||
)
|
)
|
||||||
target_link_libraries(swift-frontend-bootstrapping1
|
target_link_libraries(swift-frontend-bootstrapping1
|
||||||
PRIVATE
|
PRIVATE
|
||||||
@@ -65,6 +67,7 @@ add_swift_host_tool(swift-frontend
|
|||||||
driver.cpp
|
driver.cpp
|
||||||
SWIFT_COMPONENT compiler
|
SWIFT_COMPONENT compiler
|
||||||
HAS_SWIFT_MODULES
|
HAS_SWIFT_MODULES
|
||||||
|
REQUIRED_FOR_MINIMAL_COMPILER
|
||||||
)
|
)
|
||||||
target_link_libraries(swift-frontend
|
target_link_libraries(swift-frontend
|
||||||
PUBLIC
|
PUBLIC
|
||||||
|
|||||||
@@ -37,9 +37,3 @@ swift_install_in_component(TARGETS libStaticMirror
|
|||||||
swift_install_in_component(DIRECTORY "${SWIFT_MAIN_INCLUDE_DIR}/swift-c/StaticMirror/"
|
swift_install_in_component(DIRECTORY "${SWIFT_MAIN_INCLUDE_DIR}/swift-c/StaticMirror/"
|
||||||
DESTINATION "lib${LLVM_LIBDIR_SUFFIX}/swift/${SWIFT_SCAN_LIB_NAME}"
|
DESTINATION "lib${LLVM_LIBDIR_SUFFIX}/swift/${SWIFT_SCAN_LIB_NAME}"
|
||||||
COMPONENT static-mirror-lib)
|
COMPONENT static-mirror-lib)
|
||||||
|
|
||||||
swift_install_strip_builder_rpath(
|
|
||||||
TARGETS libStaticMirror
|
|
||||||
DESTINATION "lib${LLVM_LIBDIR_SUFFIX}/swift/${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_LIB_SUBDIR}"
|
|
||||||
COMPONENT static-mirror-lib
|
|
||||||
)
|
|
||||||
|
|||||||
@@ -69,12 +69,6 @@ else()
|
|||||||
LIBRARY DESTINATION "lib${LLVM_LIBDIR_SUFFIX}/swift/host" COMPONENT compiler
|
LIBRARY DESTINATION "lib${LLVM_LIBDIR_SUFFIX}/swift/host" COMPONENT compiler
|
||||||
RUNTIME DESTINATION "bin" COMPONENT compiler)
|
RUNTIME DESTINATION "bin" COMPONENT compiler)
|
||||||
|
|
||||||
swift_install_strip_builder_rpath(
|
|
||||||
TARGETS libSwiftScan
|
|
||||||
DESTINATION "lib${LLVM_LIBDIR_SUFFIX}/swift/host"
|
|
||||||
COMPONENT compiler
|
|
||||||
)
|
|
||||||
|
|
||||||
# Create a symlink to previously-used path of 'lib/swift/${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_LIB_SUBDIR}'
|
# Create a symlink to previously-used path of 'lib/swift/${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_LIB_SUBDIR}'
|
||||||
# to the new location under 'lib/swift/host' for clients of the legacy path.
|
# to the new location under 'lib/swift/host' for clients of the legacy path.
|
||||||
if(EXISTS ${LLVM_CMAKE_DIR}/LLVMInstallSymlink.cmake)
|
if(EXISTS ${LLVM_CMAKE_DIR}/LLVMInstallSymlink.cmake)
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ add_swift_host_tool(swift-compatibility-symbols
|
|||||||
swift-compatibility-symbols.cpp
|
swift-compatibility-symbols.cpp
|
||||||
LLVM_LINK_COMPONENTS support
|
LLVM_LINK_COMPONENTS support
|
||||||
SWIFT_COMPONENT tools
|
SWIFT_COMPONENT tools
|
||||||
|
REQUIRED_FOR_MINIMAL_COMPILER
|
||||||
)
|
)
|
||||||
|
|
||||||
set(syms_file "${CMAKE_BINARY_DIR}/share/swift/compatibility-symbols")
|
set(syms_file "${CMAKE_BINARY_DIR}/share/swift/compatibility-symbols")
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
add_swift_host_tool(swift-def-to-strings-converter
|
add_swift_host_tool(swift-def-to-strings-converter
|
||||||
swift-def-to-strings-converter.cpp
|
swift-def-to-strings-converter.cpp
|
||||||
SWIFT_COMPONENT tools
|
SWIFT_COMPONENT tools
|
||||||
|
REQUIRED_FOR_MINIMAL_COMPILER
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(swift-def-to-strings-converter PRIVATE
|
target_link_libraries(swift-def-to-strings-converter PRIVATE
|
||||||
|
|||||||
@@ -30,9 +30,4 @@ if (SWIFT_SWIFT_PARSER)
|
|||||||
DESTINATION bin
|
DESTINATION bin
|
||||||
COMPONENT compiler
|
COMPONENT compiler
|
||||||
)
|
)
|
||||||
swift_install_strip_builder_rpath(
|
|
||||||
TARGETS swift-plugin-server
|
|
||||||
DESTINATION bin
|
|
||||||
COMPONENT compiler
|
|
||||||
)
|
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
add_swift_host_tool(swift-serialize-diagnostics
|
add_swift_host_tool(swift-serialize-diagnostics
|
||||||
swift-serialize-diagnostics.cpp
|
swift-serialize-diagnostics.cpp
|
||||||
SWIFT_COMPONENT tools
|
SWIFT_COMPONENT tools
|
||||||
|
REQUIRED_FOR_MINIMAL_COMPILER
|
||||||
)
|
)
|
||||||
target_link_libraries(swift-serialize-diagnostics PRIVATE
|
target_link_libraries(swift-serialize-diagnostics PRIVATE
|
||||||
swiftLocalization)
|
swiftLocalization)
|
||||||
|
|||||||
Reference in New Issue
Block a user