mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[CMake] Support Macros in Linux
For compiling codes required for macro support, we now need swiftc compiler in the build machine. Unlike Darwin OSes, where swiftCore runtime is guaranteed to be present in /usr/lib, Linux doesn't have ABI stability and the stdlib of the build machine is not at the specific location. So the built compiler cannot relies on the shared object in the toolchain.
This commit is contained in:
@@ -794,6 +794,7 @@ include(SwiftConfigureSDK)
|
||||
include(SwiftComponents)
|
||||
include(SwiftList)
|
||||
include(AddPureSwift)
|
||||
include(SwiftStripBuilderRpath)
|
||||
|
||||
# Configure swift include, install, build components.
|
||||
swift_configure_components()
|
||||
|
||||
@@ -235,7 +235,7 @@ else()
|
||||
#
|
||||
# step 1: generate a dummy source file, which just includes all headers
|
||||
# defined in include/swift/module.modulemap
|
||||
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/HeaderDependencies.cpp"
|
||||
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/HeaderDependencies.cpp.tmp"
|
||||
"
|
||||
#include \"Basic/BridgedSwiftObject.h\"
|
||||
#include \"Basic/BasicBridging.h\"
|
||||
@@ -251,6 +251,12 @@ else()
|
||||
|
||||
#include \"Parse/RegexParserBridging.h\"
|
||||
")
|
||||
add_custom_command(
|
||||
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/HeaderDependencies.cpp"
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/HeaderDependencies.cpp.tmp"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/HeaderDependencies.cpp"
|
||||
)
|
||||
|
||||
# step 2: build a library containing that source file. This library depends on all the included header files.
|
||||
# The swift modules can now depend on that target.
|
||||
|
||||
@@ -65,6 +65,27 @@ function(_add_host_swift_compile_options name)
|
||||
_add_host_variant_swift_sanitizer_flags(${name})
|
||||
endfunction()
|
||||
|
||||
function(_set_pure_swift_link_flags name relpath_to_lib_dir)
|
||||
if(SWIFT_HOST_VARIANT_SDK STREQUAL "LINUX")
|
||||
# Don't add builder's stdlib RPATH automatically, because we want to *de-prioritize* it.
|
||||
target_compile_options(${name} PRIVATE
|
||||
$<$<COMPILE_LANGUAGE:Swift>:-no-toolchain-stdlib-rpath>
|
||||
)
|
||||
|
||||
get_filename_component(swift_bin_dir ${CMAKE_Swift_COMPILER} DIRECTORY)
|
||||
get_filename_component(swift_dir ${swift_bin_dir} DIRECTORY)
|
||||
set(host_lib_dir "${swift_dir}/lib/swift/${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_LIB_SUBDIR}")
|
||||
|
||||
set_property(TARGET ${name}
|
||||
APPEND PROPERTY INSTALL_RPATH
|
||||
# At runtime, use swiftCore in the current toolchain.
|
||||
"$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()
|
||||
endfunction()
|
||||
|
||||
# Add a new "pure" Swift host library.
|
||||
#
|
||||
# "Pure" Swift host libraries can only contain Swift code, and will be built
|
||||
@@ -266,6 +287,7 @@ function(add_pure_swift_host_tool name)
|
||||
# Create the library.
|
||||
add_executable(${name} ${APSHT_SOURCES})
|
||||
_add_host_swift_compile_options(${name})
|
||||
_set_pure_swift_link_flags(${name} "../lib")
|
||||
|
||||
if(SWIFT_HOST_VARIANT_SDK IN_LIST SWIFT_DARWIN_PLATFORMS)
|
||||
set_property(TARGET ${name}
|
||||
|
||||
@@ -548,10 +548,14 @@ function(_add_swift_runtime_link_flags target relpath_to_lib_dir bootstrapping)
|
||||
target_link_libraries(${target} PRIVATE "swiftCore")
|
||||
|
||||
target_link_directories(${target} PRIVATE ${host_lib_dir})
|
||||
if(ASRLF_BOOTSTRAPPING_MODE STREQUAL "HOSTTOOLS")
|
||||
set(swift_runtime_rpath "${host_lib_dir}")
|
||||
else()
|
||||
|
||||
# At runtime, use swiftCore in the current toolchain.
|
||||
# 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}")
|
||||
|
||||
if(ASRLF_BOOTSTRAPPING_MODE STREQUAL "HOSTTOOLS")
|
||||
# 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}")
|
||||
endif()
|
||||
|
||||
elseif(ASRLF_BOOTSTRAPPING_MODE STREQUAL "BOOTSTRAPPING")
|
||||
@@ -576,9 +580,6 @@ function(_add_swift_runtime_link_flags target relpath_to_lib_dir bootstrapping)
|
||||
endif()
|
||||
|
||||
if(SWIFT_SWIFT_PARSER)
|
||||
# Make sure we can find the early SwiftSyntax libraries.
|
||||
target_link_directories(${target} PRIVATE "${SWIFT_PATH_TO_EARLYSWIFTSYNTAX_BUILD_DIR}/lib/swift/host")
|
||||
|
||||
# For the "end step" of bootstrapping configurations, we need to be
|
||||
# able to fall back to the SDK directory for libswiftCore et al.
|
||||
if (BOOTSTRAPPING_MODE MATCHES "BOOTSTRAPPING.*")
|
||||
@@ -967,7 +968,14 @@ function(add_swift_host_tool executable)
|
||||
swift_install_in_component(TARGETS ${executable}
|
||||
RUNTIME
|
||||
DESTINATION bin
|
||||
COMPONENT ${ASHT_SWIFT_COMPONENT})
|
||||
COMPONENT ${ASHT_SWIFT_COMPONENT}
|
||||
)
|
||||
|
||||
swift_install_strip_builder_rpath(
|
||||
TARGETS ${executable}
|
||||
DESTINATION bin
|
||||
COMPONENT ${ASHT_SWIFT_COMPONENT}
|
||||
)
|
||||
|
||||
swift_is_installing_component(${ASHT_SWIFT_COMPONENT} is_installing)
|
||||
endif()
|
||||
|
||||
@@ -5,10 +5,32 @@ add_custom_target(SwiftUnitTests)
|
||||
|
||||
set_target_properties(SwiftUnitTests PROPERTIES FOLDER "Tests")
|
||||
|
||||
# Add a new Swift unit test executable.
|
||||
#
|
||||
# Usage:
|
||||
# add_swift_unittest(name
|
||||
# [IS_TARGET_TEST]
|
||||
# source1 [source2 source3 ...])
|
||||
#
|
||||
# name
|
||||
# Name of the test (e.g., SwiftASTTest).
|
||||
#
|
||||
# IS_TARGET_TEST
|
||||
# Indicates this is a test for target libraries. Not host library.
|
||||
# This avoids linking with toolchains stdlib.
|
||||
#
|
||||
# source1 ...
|
||||
# Sources to add into this executable.
|
||||
function(add_swift_unittest test_dirname)
|
||||
cmake_parse_arguments(ASU
|
||||
"IS_TARGET_TEST"
|
||||
""
|
||||
""
|
||||
${ARGN})
|
||||
|
||||
# *NOTE* Even though "add_unittest" does not have llvm in its name, it is a
|
||||
# function defined by AddLLVM.cmake.
|
||||
add_unittest(SwiftUnitTests ${test_dirname} ${ARGN})
|
||||
add_unittest(SwiftUnitTests ${test_dirname} ${ASU_UNPARSED_ARGUMENTS})
|
||||
|
||||
set_target_properties(${test_dirname} PROPERTIES LINKER_LANGUAGE CXX)
|
||||
|
||||
@@ -89,7 +111,8 @@ function(add_swift_unittest test_dirname)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (SWIFT_SWIFT_PARSER)
|
||||
if (SWIFT_SWIFT_PARSER AND NOT ASU_IS_TARGET_TEST)
|
||||
# Link to stdlib the compiler uses.
|
||||
_add_swift_runtime_link_flags(${test_dirname} "../../lib" "")
|
||||
set_property(TARGET ${test_dirname} PROPERTY BUILD_WITH_INSTALL_RPATH OFF)
|
||||
endif()
|
||||
|
||||
@@ -6,7 +6,7 @@ function(swift_supports_implicit_module module_name out_var)
|
||||
"${CMAKE_Swift_COMPILER}"
|
||||
-Xfrontend -disable-implicit-${module_name}-module-import
|
||||
-Xfrontend -parse-stdlib
|
||||
-c - -o /dev/null
|
||||
-parse -
|
||||
INPUT_FILE
|
||||
"${CMAKE_BINARY_DIR}/tmp/empty-check-${module_name}.swift"
|
||||
OUTPUT_QUIET ERROR_QUIET
|
||||
|
||||
71
cmake/modules/SwiftStripBuilderRpath.cmake
Normal file
71
cmake/modules/SwiftStripBuilderRpath.cmake
Normal file
@@ -0,0 +1,71 @@
|
||||
set(SWIFT_SET_RPATH_SCRIPT_FILE "${CMAKE_CURRENT_LIST_FILE}")
|
||||
|
||||
function(swift_get_set_rpath_script_file out_var)
|
||||
set(${out_var} "${SWIFT_SET_RPATH_SCRIPT_FILE}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
# Actual RPATH_SET operation to the file.
|
||||
function(_swift_set_rpath_impl file new_rpath)
|
||||
# NOTE: RPATH_SET is not documented, and works only for ELF and XCOFF.
|
||||
file(RPATH_SET FILE "${file}" NEW_RPATH "${new_rpath}")
|
||||
endfunction()
|
||||
|
||||
# For 'install(SCRIPT <script> CODE swift_set_rpath(...)'.
|
||||
function(_swift_file_set_rpath_installed file new_rpath)
|
||||
set(DESTDIR $ENV{DESTDIR})
|
||||
if(NOT IS_ABSOLUTE "${file}")
|
||||
string(PREPEND file "${CMAKE_INSTALL_PREFIX}/")
|
||||
endif()
|
||||
string(PREPEND file "${DESTDIR}")
|
||||
_swift_set_rpath_impl("${file}" "${new_rpath}")
|
||||
endfunction()
|
||||
|
||||
# Add 'install' script that set runtime path to the specified file.
|
||||
function(swift_install_file_set_rpath file install_rpath component)
|
||||
if(NOT(SWIFT_HOST_VARIANT_SDK STREQUAL "LINUX"))
|
||||
return()
|
||||
endif()
|
||||
if((NOT SWIFT_SWIFT_PARSER) AND NOT(BOOTSTRAPPING_MODE STREQUAL "HOSTTOOLS"))
|
||||
return()
|
||||
endif()
|
||||
|
||||
swift_get_set_rpath_script_file(script)
|
||||
|
||||
swift_install_in_component(
|
||||
SCRIPT "${script}"
|
||||
CODE "_swift_file_set_rpath_installed(\"${file}\" \"${install_rpath}\")"
|
||||
COMPONENT ${component}
|
||||
)
|
||||
endfunction()
|
||||
|
||||
# Add 'install' script that set runtime path to the target but only startinig with '$ORIGIN'
|
||||
function(swift_install_strip_builder_rpath)
|
||||
cmake_parse_arguments(RPATH
|
||||
""
|
||||
"DESTINATION;COMPONENT"
|
||||
"TARGETS"
|
||||
${ARGN})
|
||||
|
||||
foreach(target ${RPATH_TARGETS})
|
||||
# Filter out RPATHs *not* starting with $ORIGIN
|
||||
set(stripped_rpaths)
|
||||
get_target_property(install_rpaths ${target} INSTALL_RPATH)
|
||||
foreach(path ${install_rpaths})
|
||||
if (path MATCHES "^\\$ORIGIN")
|
||||
list(APPEND stripped_rpaths "${path}")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
list(JOIN stripped_rpaths ":" install_rpath_str)
|
||||
swift_install_file_set_rpath(
|
||||
"${RPATH_DESTINATION}/$<TARGET_FILE_NAME:${target}>"
|
||||
"${install_rpath_str}"
|
||||
${RPATH_COMPONENT}
|
||||
)
|
||||
endforeach()
|
||||
endfunction()
|
||||
|
||||
# For 'cmake -P <scirpt>'.
|
||||
if (SWIFT_SET_RPATH_FILE AND SWIFT_SET_RPATH_NEW_RPATH)
|
||||
_swift_set_rpath_impl("${SWIFT_SET_RPATH_FILE}" "${SWIFT_SET_RPATH_NEW_RPATH}")
|
||||
endif()
|
||||
@@ -33,7 +33,7 @@ if (SWIFT_SWIFT_PARSER)
|
||||
list(TRANSFORM SWIFT_SYNTAX_MODULES PREPEND "SwiftSyntax::"
|
||||
OUTPUT_VARIABLE SWIFT_SYNTAX_TARGETS)
|
||||
|
||||
set(SWIFT_SYNTAX_LIBRARIES_SOURCE_DIR
|
||||
set(SWIFT_SYNTAX_LIBRARIES_BUILD_DIR
|
||||
"${SWIFT_PATH_TO_EARLYSWIFTSYNTAX_BUILD_DIR}/lib/swift/host")
|
||||
set(SWIFT_HOST_LIBRARIES_DEST_DIR
|
||||
"${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/swift/host")
|
||||
@@ -53,10 +53,27 @@ if (SWIFT_SWIFT_PARSER)
|
||||
# Copy over all of the shared libraries from earlyswiftsyntax so they can
|
||||
# be found via RPATH.
|
||||
foreach (sharedlib ${SWIFT_SYNTAX_SHARED_LIBRARIES})
|
||||
set(add_origin_rpath)
|
||||
if(SWIFT_HOST_VARIANT_SDK STREQUAL "LINUX")
|
||||
get_filename_component(swift_bin_dir ${CMAKE_Swift_COMPILER} DIRECTORY)
|
||||
get_filename_component(swift_dir ${swift_bin_dir} DIRECTORY)
|
||||
set(host_lib_dir "${swift_dir}/lib/swift/${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_LIB_SUBDIR}")
|
||||
|
||||
# At runtime, use swiftCore in the current toolchain.
|
||||
|
||||
swift_get_set_rpath_script_file(setrpath_command)
|
||||
set(add_origin_rpath COMMAND ${CMAKE_COMMAND}
|
||||
"-DSWIFT_SET_RPATH_FILE=${SWIFT_HOST_LIBRARIES_DEST_DIR}/${sharedlib}"
|
||||
"-DSWIFT_SET_RPATH_NEW_RPATH='$$ORIGIN:$$ORIGIN/../${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_LIB_SUBDIR}:${host_lib_dir}'"
|
||||
-P "${setrpath_command}"
|
||||
)
|
||||
endif()
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT "${SWIFT_HOST_LIBRARIES_DEST_DIR}/${sharedlib}"
|
||||
DEPENDS "${SWIFT_SYNTAX_LIBRARIES_SOURCE_DIR}/${sharedlib}"
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${SWIFT_SYNTAX_LIBRARIES_SOURCE_DIR}/${sharedlib} ${SWIFT_HOST_LIBRARIES_DEST_DIR}/${sharedlib}
|
||||
DEPENDS "${SWIFT_SYNTAX_LIBRARIES_BUILD_DIR}/${sharedlib}"
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${SWIFT_SYNTAX_LIBRARIES_BUILD_DIR}/${sharedlib} ${SWIFT_HOST_LIBRARIES_DEST_DIR}/${sharedlib}
|
||||
${add_origin_rpath}
|
||||
)
|
||||
|
||||
add_custom_target(copy_swiftSyntaxLibrary_${sharedlib}
|
||||
@@ -64,6 +81,18 @@ if (SWIFT_SWIFT_PARSER)
|
||||
COMMENT "Copying ${sharedlib}"
|
||||
)
|
||||
|
||||
swift_install_in_component(
|
||||
FILES "${SWIFT_HOST_LIBRARIES_DEST_DIR}/${sharedlib}"
|
||||
DESTINATION "lib${LLVM_LIBDIR_SUFFIX}/swift/host"
|
||||
COMPONENT compiler
|
||||
)
|
||||
|
||||
swift_install_file_set_rpath(
|
||||
"lib${LLVM_LIBDIR_SUFFIX}/swift/host/${sharedlib}"
|
||||
"$ORIGIN:$ORIGIN/../${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_LIB_SUBDIR}"
|
||||
compiler
|
||||
)
|
||||
|
||||
add_dependencies(swiftSyntaxLibraries copy_swiftSyntaxLibrary_${sharedlib})
|
||||
endforeach()
|
||||
|
||||
@@ -76,7 +105,7 @@ if (SWIFT_SWIFT_PARSER)
|
||||
foreach(module_dir ${SWIFT_SYNTAX_MODULE_DIRS})
|
||||
# Find all of the source module files.
|
||||
file(GLOB module_files
|
||||
"${SWIFT_SYNTAX_LIBRARIES_SOURCE_DIR}/${module_dir}/*.swiftinterface")
|
||||
"${SWIFT_SYNTAX_LIBRARIES_BUILD_DIR}/${module_dir}/*.swiftinterface")
|
||||
|
||||
# Determine the destination module files.
|
||||
set(dest_module_files)
|
||||
@@ -98,6 +127,12 @@ if (SWIFT_SWIFT_PARSER)
|
||||
COMMENT "Copying ${module_dir}"
|
||||
)
|
||||
|
||||
swift_install_in_component(
|
||||
FILES ${dest_module_files}
|
||||
DESTINATION "lib${LLVM_LIBDIR_SUFFIX}/swift/host/${module_dir}"
|
||||
COMPONENT compiler
|
||||
)
|
||||
|
||||
add_dependencies(swiftSyntaxLibraries copy_swiftSyntaxModule_${module_dir})
|
||||
endforeach()
|
||||
|
||||
|
||||
@@ -31,6 +31,19 @@ function(add_swift_macro_library name)
|
||||
# Add the library.
|
||||
add_pure_swift_host_library(${name} SHARED ${ASML_SOURCES})
|
||||
|
||||
# Add rpath to 'lib/{platform}'
|
||||
file(RELATIVE_PATH relpath_to_lib
|
||||
"${SWIFT_HOST_PLUGINS_DEST_DIR}"
|
||||
"${CMAKE_LIBRARY_OUTPUT_DIRECTORY}"
|
||||
)
|
||||
_set_pure_swift_link_flags(${name} "${relpath_to_lib}")
|
||||
|
||||
# Add rpath to 'lib/host'
|
||||
if(SWIFT_HOST_VARIANT_SDK STREQUAL "LINUX")
|
||||
set_property(TARGET ${name}
|
||||
APPEND PROPERTY INSTALL_RPATH "$ORIGIN/..")
|
||||
endif()
|
||||
|
||||
# If we don't have the Swift swift parser, bail out, because the above
|
||||
# add_pure_swift_host_library did nothing.
|
||||
if (NOT SWIFT_SWIFT_PARSER)
|
||||
@@ -44,14 +57,22 @@ function(add_swift_macro_library name)
|
||||
LIBRARY_OUTPUT_DIRECTORY "${SWIFT_HOST_PLUGINS_DEST_DIR}"
|
||||
)
|
||||
|
||||
set(destination_dir "lib${LLVM_LIBDIR_SUFFIX}/swift/host/plugins")
|
||||
|
||||
swift_install_in_component(TARGETS ${name}
|
||||
LIBRARY
|
||||
DESTINATION "lib${LLVM_LIBDIR_SUFFIX}/swift/host/plugins"
|
||||
DESTINATION "${destination_dir}"
|
||||
COMPONENT compiler
|
||||
ARCHIVE
|
||||
DESTINATION "lib${LLVM_LIBDIR_SUFFIX}/swift/host/plugins"
|
||||
DESTINATION "${destination_dir}"
|
||||
COMPONENT compiler)
|
||||
|
||||
swift_install_strip_builder_rpath(
|
||||
TARGETS ${name}
|
||||
DESTINATION "${destination_dir}"
|
||||
COMPONENT compiler
|
||||
)
|
||||
|
||||
# Export this macro plugin target.
|
||||
set_property(GLOBAL APPEND PROPERTY SWIFT_MACRO_PLUGINS ${name})
|
||||
endfunction()
|
||||
|
||||
@@ -17,3 +17,10 @@ swift_install_in_component(TARGETS swiftDemangle
|
||||
ARCHIVE
|
||||
DESTINATION "lib${LLVM_LIBDIR_SUFFIX}"
|
||||
COMPONENT compiler)
|
||||
|
||||
|
||||
swift_install_strip_builder_rpath(
|
||||
TARGETS swiftDemangle
|
||||
DESTINATION "lib${LLVM_LIBDIR_SUFFIX}"
|
||||
COMPONENT compiler
|
||||
)
|
||||
|
||||
36
test/lit.cfg
36
test/lit.cfg
@@ -533,35 +533,31 @@ lit_config.note("Using code completion cache: " + completion_cache_path)
|
||||
|
||||
config.swift_host_lib_dir = make_path(config.swift_lib_dir, 'swift', 'host')
|
||||
|
||||
if kIsWindows:
|
||||
config.swift_driver = (
|
||||
"%r %s %s %s -libc %s" % (config.swift, mcp_opt,
|
||||
config.swift_test_options,
|
||||
config.swift_driver_test_options,
|
||||
config.swift_stdlib_msvc_runtime))
|
||||
config.swiftc_driver = (
|
||||
"%r -toolchain-stdlib-rpath %s %s %s" % (config.swiftc, mcp_opt,
|
||||
config.swift_test_options,
|
||||
config.swift_driver_test_options))
|
||||
else:
|
||||
if platform.system() == 'Darwin':
|
||||
config.swift_driver = (
|
||||
"env SDKROOT=%s %r %s %s %s"
|
||||
% (shell_quote(config.host_sdkroot), config.swift, mcp_opt, config.swift_test_options, config.swift_driver_test_options))
|
||||
config.swiftc_driver = (
|
||||
"env SDKROOT=%s %r -toolchain-stdlib-rpath -Xlinker -rpath -Xlinker /usr/lib/swift %s %s %s"
|
||||
% (shell_quote(config.host_sdkroot), config.swiftc, mcp_opt, config.swift_test_options, config.swift_driver_test_options))
|
||||
|
||||
if platform.system() == 'Darwin':
|
||||
host_build_extra_rpath=""
|
||||
elif config.host_triple:
|
||||
config.host_build_swift = (
|
||||
"%s -sdk %s -target %s -I %s -L %s"
|
||||
% (config.swiftc_driver, config.host_sdkroot, config.host_triple, config.swift_host_lib_dir, config.swift_host_lib_dir))
|
||||
else:
|
||||
config.swift_driver = (
|
||||
"%r %s %s %s"
|
||||
% (config.swift, mcp_opt, config.swift_test_options, config.swift_driver_test_options))
|
||||
if kIsWindows:
|
||||
config.swift_driver += " -libc " + config.swift_stdlib_msvc_runtime
|
||||
config.swiftc_driver = (
|
||||
"%r -toolchain-stdlib-rpath %s %s %s"
|
||||
% (config.swiftc, mcp_opt, config.swift_test_options, config.swift_driver_test_options))
|
||||
# Parse the host triple.
|
||||
(host_cpu, host_vendor, host_os, host_vers) = re.match('([^-]+)-([^-]+)-([^0-9-]+)(.*)', config.host_triple).groups()
|
||||
host_build_extra_rpath="-Xlinker -rpath -Xlinker %s" % (make_path(config.swift_lib_dir, 'swift', host_os))
|
||||
else:
|
||||
host_build_extra_rpath=""
|
||||
|
||||
toolchain_lib_dir = make_path(config.swift_lib_dir, 'swift', host_os)
|
||||
config.host_build_swift = (
|
||||
"%s -sdk %s -target %s -I %s -L %s %s" % (config.swiftc_driver, config.host_sdkroot, config.host_triple, config.swift_host_lib_dir, config.swift_host_lib_dir, host_build_extra_rpath))
|
||||
"%s -target %s -I %s -L %s -Xlinker -rpath -Xlinker %s"
|
||||
% (config.swiftc_driver, config.host_triple, config.swift_host_lib_dir, config.swift_host_lib_dir, toolchain_lib_dir))
|
||||
|
||||
config.substitutions.append( ('%llvm_obj_root', config.llvm_obj_root) )
|
||||
config.substitutions.append( ('%swift-bin-dir', config.swift_bin_dir) )
|
||||
|
||||
@@ -129,11 +129,12 @@ function(add_sourcekit_swift_runtime_link_flags target path HAS_SWIFT_MODULES)
|
||||
target_link_libraries(${target} PRIVATE "swiftCore")
|
||||
|
||||
target_link_directories(${target} PRIVATE ${host_lib_dir})
|
||||
if(ASKD_BOOTSTRAPPING_MODE STREQUAL "HOSTTOOLS")
|
||||
list(APPEND RPATH_LIST "${host_lib_dir}")
|
||||
else()
|
||||
|
||||
file(RELATIVE_PATH relative_rtlib_path "${path}" "${SWIFTLIB_DIR}/${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_LIB_SUBDIR}")
|
||||
list(APPEND RPATH_LIST "$ORIGIN/${relative_rtlib_path}")
|
||||
|
||||
if(ASKD_BOOTSTRAPPING_MODE STREQUAL "HOSTTOOLS")
|
||||
list(APPEND RPATH_LIST "${host_lib_dir}")
|
||||
endif()
|
||||
|
||||
elseif(ASKD_BOOTSTRAPPING_MODE STREQUAL "BOOTSTRAPPING")
|
||||
@@ -301,6 +302,15 @@ macro(add_sourcekit_library name)
|
||||
RUNTIME
|
||||
DESTINATION "bin"
|
||||
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}
|
||||
DESTINATION "include/SourceKit"
|
||||
COMPONENT "${SOURCEKITLIB_INSTALL_IN_COMPONENT}")
|
||||
@@ -351,16 +361,6 @@ macro(add_sourcekit_executable name)
|
||||
add_sourcekit_default_compiler_flags("${name}")
|
||||
|
||||
set_target_properties(${name} PROPERTIES LINKER_LANGUAGE CXX)
|
||||
|
||||
if(SWIFT_SWIFT_PARSER)
|
||||
set(SKEXEC_HAS_SWIFT_MODULES TRUE)
|
||||
else()
|
||||
set(SKEXEC_HAS_SWIFT_MODULES FALSE)
|
||||
endif()
|
||||
|
||||
set(RPATH_LIST)
|
||||
add_sourcekit_swift_runtime_link_flags(${name} ${SOURCEKIT_LIBRARY_OUTPUT_INTDIR} ${SKEXEC_HAS_SWIFT_MODULES})
|
||||
|
||||
endmacro()
|
||||
|
||||
# Add a new SourceKit framework.
|
||||
|
||||
@@ -27,3 +27,9 @@ endif()
|
||||
add_dependencies(tools complete-test)
|
||||
swift_install_in_component(TARGETS complete-test
|
||||
RUNTIME DESTINATION bin COMPONENT tools)
|
||||
|
||||
swift_install_strip_builder_rpath(
|
||||
TARGETS complete-test
|
||||
DESTINATION bin
|
||||
COMPONENT tools
|
||||
)
|
||||
|
||||
@@ -29,3 +29,9 @@ endif()
|
||||
add_dependencies(tools sourcekitd-repl)
|
||||
swift_install_in_component(TARGETS sourcekitd-repl
|
||||
RUNTIME DESTINATION bin COMPONENT tools)
|
||||
|
||||
swift_install_strip_builder_rpath(
|
||||
TARGETS sourcekitd-repl
|
||||
DESTINATION bin
|
||||
COMPONENT tools
|
||||
)
|
||||
|
||||
@@ -39,3 +39,9 @@ endif()
|
||||
add_dependencies(tools sourcekitd-test)
|
||||
swift_install_in_component(TARGETS sourcekitd-test
|
||||
RUNTIME DESTINATION bin COMPONENT tools)
|
||||
|
||||
swift_install_strip_builder_rpath(
|
||||
TARGETS sourcekitd-test
|
||||
DESTINATION bin
|
||||
COMPONENT tools
|
||||
)
|
||||
|
||||
@@ -37,3 +37,9 @@ swift_install_in_component(TARGETS libStaticMirror
|
||||
swift_install_in_component(DIRECTORY "${SWIFT_MAIN_INCLUDE_DIR}/swift-c/StaticMirror/"
|
||||
DESTINATION "lib${LLVM_LIBDIR_SUFFIX}/swift/${SWIFT_SCAN_LIB_NAME}"
|
||||
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
|
||||
)
|
||||
|
||||
@@ -31,6 +31,7 @@ set_target_properties(libSwiftScan
|
||||
OUTPUT_NAME ${SWIFT_SCAN_LIB_NAME})
|
||||
|
||||
if(SWIFT_SWIFT_PARSER)
|
||||
if(SWIFT_HOST_VARIANT_SDK IN_LIST SWIFT_DARWIN_PLATFORMS)
|
||||
# Ensure that we can find the host shared libraries.
|
||||
set_property(
|
||||
TARGET libSwiftScan
|
||||
@@ -38,6 +39,14 @@ if(SWIFT_SWIFT_PARSER)
|
||||
set_property(
|
||||
TARGET libSwiftScan
|
||||
APPEND PROPERTY INSTALL_RPATH "@loader_path/../host")
|
||||
elseif(SWIFT_HOST_VARIANT_SDK STREQUAL "LINUX")
|
||||
set_property(
|
||||
TARGET libSwiftScan
|
||||
APPEND PROPERTY INSTALL_RPATH "$ORIGIN/swift/host")
|
||||
set_property(
|
||||
TARGET libSwiftScan
|
||||
APPEND PROPERTY INSTALL_RPATH "$ORIGIN/../host")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
add_llvm_symbol_exports(libSwiftScan ${LLVM_EXPORTED_SYMBOL_FILE})
|
||||
@@ -60,6 +69,12 @@ else()
|
||||
LIBRARY DESTINATION "lib${LLVM_LIBDIR_SUFFIX}/swift/host" 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}'
|
||||
# to the new location under 'lib/swift/host' for clients of the legacy path.
|
||||
if(EXISTS ${LLVM_CMAKE_DIR}/LLVMInstallSymlink.cmake)
|
||||
|
||||
@@ -30,4 +30,9 @@ if (SWIFT_SWIFT_PARSER)
|
||||
DESTINATION bin
|
||||
COMPONENT compiler
|
||||
)
|
||||
swift_install_strip_builder_rpath(
|
||||
TARGETS swift-plugin-server
|
||||
DESTINATION bin
|
||||
COMPONENT compiler
|
||||
)
|
||||
endif()
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
if(TARGET swiftDemangle)
|
||||
add_swift_unittest(SwiftDemangleTests
|
||||
add_swift_unittest(SwiftDemangleTests IS_TARGET_TEST
|
||||
DemangleTest.cpp
|
||||
)
|
||||
set_target_properties(SwiftDemangleTests
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
if(("${SWIFT_HOST_VARIANT_SDK}" STREQUAL "${SWIFT_PRIMARY_VARIANT_SDK}") AND
|
||||
("${SWIFT_HOST_VARIANT_ARCH}" STREQUAL "${SWIFT_PRIMARY_VARIANT_ARCH}"))
|
||||
add_swift_unittest(SwiftThreadingTests
|
||||
add_swift_unittest(SwiftThreadingTests IS_TARGET_TEST
|
||||
Mutex.cpp
|
||||
ConditionVariable.cpp
|
||||
Once.cpp
|
||||
|
||||
@@ -98,7 +98,7 @@ if(("${SWIFT_HOST_VARIANT_SDK}" STREQUAL "${SWIFT_PRIMARY_VARIANT_SDK}") AND
|
||||
Actor.cpp
|
||||
TaskStatus.cpp)
|
||||
|
||||
add_swift_unittest(SwiftRuntimeTests
|
||||
add_swift_unittest(SwiftRuntimeTests IS_TARGET_TEST
|
||||
Array.cpp
|
||||
CompatibilityOverrideRuntime.cpp
|
||||
CompatibilityOverrideConcurrency.cpp
|
||||
|
||||
@@ -34,7 +34,7 @@ if(("${SWIFT_HOST_VARIANT_SDK}" STREQUAL "${SWIFT_PRIMARY_VARIANT_SDK}") AND
|
||||
list(APPEND PLATFORM_TARGET_LINK_LIBRARIES DbgHelp;Synchronization)
|
||||
endif()
|
||||
|
||||
add_swift_unittest(SwiftRuntimeLongTests
|
||||
add_swift_unittest(SwiftRuntimeLongTests IS_TARGET_TEST
|
||||
LongRefcounting.cpp
|
||||
../Stdlib.cpp
|
||||
${PLATFORM_SOURCES}
|
||||
|
||||
@@ -859,7 +859,6 @@ install-lldb
|
||||
install-llbuild
|
||||
install-swiftpm
|
||||
install-swift-driver
|
||||
install-swiftsyntax
|
||||
install-xctest
|
||||
install-libicu
|
||||
install-prefix=/usr
|
||||
@@ -890,6 +889,8 @@ installable-package=%(installable_package)s
|
||||
# in Linux CI bots
|
||||
relocate-xdg-cache-home-under-build-subdir
|
||||
|
||||
# Linux only support 'hosttools' with early-swiftsyntax.
|
||||
bootstrapping=hosttools
|
||||
|
||||
[preset: buildbot_linux_base]
|
||||
mixin-preset=
|
||||
|
||||
@@ -36,7 +36,7 @@ class EarlySwiftSyntax(cmake_product.CMakeProduct):
|
||||
def should_build(self, host_target):
|
||||
# Temporarily disable for non-darwin since this build never works
|
||||
# outside of that case currently.
|
||||
if sys.platform != 'darwin':
|
||||
if sys.platform != 'darwin' and sys.platform != 'linux':
|
||||
return False
|
||||
|
||||
if self.args.build_early_swiftsyntax:
|
||||
@@ -73,18 +73,10 @@ class EarlySwiftSyntax(cmake_product.CMakeProduct):
|
||||
pass
|
||||
|
||||
def should_install(self, host_target):
|
||||
"""should_install() -> Bool
|
||||
|
||||
Whether or not this product should be installed with the given
|
||||
arguments.
|
||||
"""
|
||||
return self.should_build(host_target) and self.args.install_swiftsyntax
|
||||
# The artifacts are copied to build directory of 'swift' and are
|
||||
# installed as a part of 'swift' product.
|
||||
return False
|
||||
|
||||
def install(self, host_target):
|
||||
"""
|
||||
Perform the install phase for the product.
|
||||
|
||||
This phase might copy the artifacts from the previous phases into a
|
||||
destination directory.
|
||||
"""
|
||||
self.install_with_cmake(["install"], self.host_install_destdir(host_target))
|
||||
# No-op.
|
||||
None
|
||||
|
||||
Reference in New Issue
Block a user