Skip to content

Commit 1bf49ae

Browse files
committed
cmake: fix a wrong library search directory order when building swift-frontend with bootstrapping
1 parent 43506a0 commit 1bf49ae

File tree

2 files changed

+27
-24
lines changed

2 files changed

+27
-24
lines changed

cmake/modules/AddSwift.cmake

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -800,16 +800,6 @@ macro(add_swift_lib_subdirectory name)
800800
add_llvm_subdirectory(SWIFT LIB ${name})
801801
endmacro()
802802
803-
function(_link_built_compatibility_libs executable)
804-
set(platform ${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_LIB_SUBDIR})
805-
target_link_directories(${executable} PRIVATE
806-
${SWIFTLIB_DIR}/${platform})
807-
add_dependencies(${executable}
808-
"swiftCompatibility50-${platform}"
809-
"swiftCompatibility51-${platform}"
810-
"swiftCompatibilityDynamicReplacements-${platform}")
811-
endfunction()
812-
813803
function(add_swift_host_tool executable)
814804
set(options HAS_LIBSWIFT)
815805
set(single_parameter_options SWIFT_COMPONENT BOOTSTRAPPING)
@@ -908,24 +898,26 @@ function(add_swift_host_tool executable)
908898
list(APPEND RPATH_LIST "/usr/lib/swift")
909899
910900
elseif(LIBSWIFT_BUILD_MODE STREQUAL "BOOTSTRAPPING-WITH-HOSTLIBS")
911-
# Pick up the built libswiftCompatibility<n>.a libraries
912-
_link_built_compatibility_libs(${executable})
913-
914901
# Add the SDK directory for the host platform.
915902
target_link_directories(${executable} PRIVATE "${sdk_dir}")
916903
904+
# A backup in case the toolchain doesn't have one of the compatibility libraries.
905+
target_link_directories(${executable} PRIVATE
906+
"${SWIFTLIB_DIR}/${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_LIB_SUBDIR}")
907+
917908
# Include the abi stable system stdlib in our rpath.
918909
list(APPEND RPATH_LIST "/usr/lib/swift")
919910
920911
elseif(LIBSWIFT_BUILD_MODE STREQUAL "BOOTSTRAPPING")
921-
# Pick up the built libswiftCompatibility<n>.a libraries
922-
_link_built_compatibility_libs(${executable})
923-
924912
# At build time link against the built swift libraries from the
925913
# previous bootstrapping stage.
926914
get_bootstrapping_swift_lib_dir(bs_lib_dir "${ASHT_BOOTSTRAPPING}")
927915
target_link_directories(${executable} PRIVATE ${bs_lib_dir})
928916
917+
# Required to pick up the built libswiftCompatibility<n>.a libraries
918+
target_link_directories(${executable} PRIVATE
919+
"${SWIFTLIB_DIR}/${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_LIB_SUBDIR}")
920+
929921
# At runtime link against the built swift libraries from the current
930922
# bootstrapping stage.
931923
list(APPEND RPATH_LIST "@executable_path/../lib/swift/${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_LIB_SUBDIR}")

libswift/CMakeLists.txt

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,28 +34,39 @@ else()
3434
set(b0_deps swift-frontend-bootstrapping0 symlink-headers-bootstrapping0)
3535
set(b1_deps swift-frontend-bootstrapping1 symlink-headers-bootstrapping1)
3636
if(${LIBSWIFT_BUILD_MODE} STREQUAL "BOOTSTRAPPING")
37-
set(b0_deps ${b0_deps} swiftCore-bootstrapping0)
38-
set(b1_deps ${b1_deps} swiftCore-bootstrapping1)
37+
list(APPEND b0_deps swiftCore-bootstrapping0)
38+
list(APPEND b1_deps swiftCore-bootstrapping1)
3939
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
40-
set(b0_deps ${b0_deps} swiftSwiftOnoneSupport-bootstrapping0)
41-
set(b1_deps ${b1_deps} swiftSwiftOnoneSupport-bootstrapping1)
40+
list(APPEND b0_deps swiftSwiftOnoneSupport-bootstrapping0)
41+
list(APPEND b1_deps swiftSwiftOnoneSupport-bootstrapping1)
4242
endif()
4343
if(SWIFT_HOST_VARIANT_SDK IN_LIST SWIFT_DARWIN_PLATFORMS)
44-
set(b0_deps ${b0_deps} swiftDarwin-bootstrapping0)
45-
set(b1_deps ${b1_deps} swiftDarwin-bootstrapping1)
44+
list(APPEND b0_deps swiftDarwin-bootstrapping0)
45+
list(APPEND b1_deps swiftDarwin-bootstrapping1)
4646
endif()
4747
endif()
48+
if(SWIFT_HOST_VARIANT_SDK IN_LIST SWIFT_DARWIN_PLATFORMS)
49+
set(platform ${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_LIB_SUBDIR})
50+
set(compatibility_libs
51+
"swiftCompatibility50-${platform}"
52+
"swiftCompatibility51-${platform}"
53+
"swiftCompatibilityDynamicReplacements-${platform}")
54+
55+
list(APPEND b0_deps ${compatibility_libs})
56+
list(APPEND b1_deps ${compatibility_libs})
57+
endif()
58+
4859

4960
# Bootstrapping - stage 1, using the compiler from level 0
5061

51-
add_libswift("libswift-bootstrapping1"
62+
add_libswift(libswift-bootstrapping1
5263
SWIFT_EXEC "${CMAKE_BINARY_DIR}/bootstrapping0/bin/swiftc"
5364
DEPENDS ${b0_deps}
5465
BOOTSTRAPPING 1)
5566

5667
# The final build, using the compiler from stage 1
5768

58-
add_libswift("libswift"
69+
add_libswift(libswift
5970
SWIFT_EXEC "${CMAKE_BINARY_DIR}/bootstrapping1/bin/swiftc"
6071
DEPENDS ${b1_deps})
6172

0 commit comments

Comments
 (0)