mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
cmake: add support for bootstrapping with swiftly
For hosts that have a swiftly-managed Swift compiler, we could not bootstrap using those tools, because of some hardcoded assumptions about where the `/lib` directory lives, relative to the `/bin` directory that contains the detected `swiftc`. This patch adds specific support for detecting when the `swiftc` is coming from a swiftly install and uses the correct paths. I've tested this patch on my Linux machine that has swiftly 1.0.1, with the Swift 6.1.2 toolchain.
This commit is contained in:
@@ -550,6 +550,19 @@ function(_add_swift_runtime_link_flags target relpath_to_lib_dir bootstrapping)
|
||||
else()
|
||||
get_filename_component(swift_bin_dir ${SWIFT_EXEC_FOR_SWIFT_MODULES} DIRECTORY)
|
||||
get_filename_component(swift_dir ${swift_bin_dir} DIRECTORY)
|
||||
|
||||
# Detect and handle swiftly-managed hosts.
|
||||
if(swift_bin_dir MATCHES ".*/swiftly/bin")
|
||||
execute_process(COMMAND swiftly use --print-location
|
||||
OUTPUT_VARIABLE swiftly_dir
|
||||
ERROR_VARIABLE err)
|
||||
if(err)
|
||||
message(SEND_ERROR "Failed to find swiftly Swift compiler")
|
||||
endif()
|
||||
string(STRIP "${swiftly_dir}" swiftly_dir)
|
||||
set(swift_dir "${swiftly_dir}/usr")
|
||||
endif()
|
||||
|
||||
endif()
|
||||
set(host_lib_dir "${swift_dir}/lib/swift/${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_LIB_SUBDIR}")
|
||||
else()
|
||||
@@ -611,6 +624,19 @@ function(_add_swift_runtime_link_flags target relpath_to_lib_dir bootstrapping)
|
||||
else()
|
||||
get_filename_component(swift_bin_dir ${SWIFT_EXEC_FOR_SWIFT_MODULES} DIRECTORY)
|
||||
get_filename_component(swift_dir ${swift_bin_dir} DIRECTORY)
|
||||
|
||||
# Detect and handle swiftly-managed hosts.
|
||||
if(swift_bin_dir MATCHES ".*/swiftly/bin")
|
||||
execute_process(COMMAND swiftly use --print-location
|
||||
OUTPUT_VARIABLE swiftly_dir
|
||||
ERROR_VARIABLE err)
|
||||
if(err)
|
||||
message(SEND_ERROR "Failed to find swiftly Swift compiler")
|
||||
endif()
|
||||
string(STRIP "${swiftly_dir}" swiftly_dir)
|
||||
set(swift_dir "${swiftly_dir}/usr")
|
||||
endif()
|
||||
|
||||
set(host_lib_dir "${swift_dir}/lib/swift/${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_LIB_SUBDIR}")
|
||||
target_link_directories(${target} PRIVATE ${host_lib_dir})
|
||||
|
||||
|
||||
@@ -115,6 +115,19 @@ function(get_bootstrapping_swift_lib_dir bs_lib_dir bootstrapping)
|
||||
# FIXME: This assumes the ABI hasn't changed since the builder.
|
||||
get_filename_component(swift_bin_dir ${CMAKE_Swift_COMPILER} DIRECTORY)
|
||||
get_filename_component(swift_dir ${swift_bin_dir} DIRECTORY)
|
||||
|
||||
# Detect and handle swiftly-managed hosts.
|
||||
if(swift_bin_dir MATCHES ".*/swiftly/bin")
|
||||
execute_process(COMMAND swiftly use --print-location
|
||||
OUTPUT_VARIABLE swiftly_dir
|
||||
ERROR_VARIABLE err)
|
||||
if(err)
|
||||
message(SEND_ERROR "Failed to find swiftly Swift compiler")
|
||||
endif()
|
||||
string(STRIP "${swiftly_dir}" swiftly_dir)
|
||||
set(swift_dir "${swiftly_dir}/usr")
|
||||
endif()
|
||||
|
||||
set(bs_lib_dir "${swift_dir}/lib/swift/${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_LIB_SUBDIR}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
Reference in New Issue
Block a user