Skip to content

Commit 78c4c3f

Browse files
committed
libswift: fixes for the linux bootstrapping build
1 parent 1a19d59 commit 78c4c3f

File tree

3 files changed

+26
-4
lines changed

3 files changed

+26
-4
lines changed

cmake/modules/AddSwift.cmake

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -741,9 +741,12 @@ function(add_libswift name)
741741
742742
get_bootstrapping_path(build_dir ${CMAKE_CURRENT_BINARY_DIR} "${ALS_BOOTSTRAPPING}")
743743
744+
set(sdk_option "")
745+
744746
if(SWIFT_HOST_VARIANT_SDK IN_LIST SWIFT_DARWIN_PLATFORMS)
745747
set(deployment_version "10.15") # TODO: once #38675 lands, replace this with
746748
# set(deployment_version "${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_DEPLOYMENT_VERSION}")
749+
set(sdk_option "-sdk" "${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_ARCH_${SWIFT_HOST_VARIANT_ARCH}_PATH}")
747750
endif()
748751
get_versioned_target_triple(target ${SWIFT_HOST_VARIANT_SDK}
749752
${SWIFT_HOST_VARIANT_ARCH} "${deployment_version}")
@@ -777,7 +780,7 @@ function(add_libswift name)
777780
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
778781
DEPENDS ${sources} ${deps} ${ALS_DEPENDS}
779782
COMMAND ${ALS_SWIFT_EXEC} "-c" "-o" ${module_obj_file}
780-
"-sdk" "${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_ARCH_${SWIFT_HOST_VARIANT_ARCH}_PATH}"
783+
${sdk_option}
781784
"-target" ${target}
782785
"-module-name" ${module} "-emit-module"
783786
"-emit-module-path" "${build_dir}/${module}.swiftmodule"
@@ -980,8 +983,11 @@ function(add_swift_host_tool executable)
980983
elseif(LIBSWIFT_BUILD_MODE STREQUAL "BOOTSTRAPPING")
981984
# At build time link against the built swift libraries from the
982985
# previous bootstrapping stage.
983-
get_bootstrapping_swift_lib_dir(bs_lib_dir "${ASHT_BOOTSTRAPPING}")
984-
target_link_directories(${executable} PRIVATE ${bs_lib_dir})
986+
if (NOT "${ASHT_BOOTSTRAPPING}" STREQUAL "0")
987+
get_bootstrapping_swift_lib_dir(bs_lib_dir "${ASHT_BOOTSTRAPPING}")
988+
target_link_directories(${executable} PRIVATE ${bs_lib_dir})
989+
target_link_libraries(${executable} PRIVATE "swiftCore")
990+
endif()
985991
986992
# At runtime link against the built swift libraries from the current
987993
# bootstrapping stage.

libswift/Sources/SIL/Utils.swift

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,19 @@ extension BridgedStringRef {
8181
}
8282
}
8383

84+
#if os(Linux)
85+
86+
extension std.__cxx11.string {
87+
public var string: String {
88+
// TODO: remove this once a new version of Swift is released (and call
89+
// c_str() directly).
90+
let mutableSelf = self
91+
return String(cString: mutableSelf.c_str())
92+
}
93+
}
94+
95+
#else
96+
8497
extension std.__1.string {
8598
public var string: String {
8699
// TODO: remove this once a new version of Swift is released (and call
@@ -90,6 +103,8 @@ extension std.__1.string {
90103
}
91104
}
92105

106+
#endif
107+
93108
extension String {
94109
public func withBridgedStringRef<T>(_ c: (BridgedStringRef) -> T) -> T {
95110
var str = self

stdlib/public/Platform/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ set(swiftDarwin_common_options
4242
DEPENDS ${darwin_depends})
4343

4444

45-
if(${LIBSWIFT_BUILD_MODE} STREQUAL "BOOTSTRAPPING")
45+
if(${LIBSWIFT_BUILD_MODE} STREQUAL "BOOTSTRAPPING" AND
46+
${SWIFT_HOST_VARIANT_SDK} IN_LIST SWIFT_DARWIN_PLATFORMS)
4647

4748
set(swiftDarwin_common_bootstrapping_options
4849
${swiftDarwin_common_options}

0 commit comments

Comments
 (0)