Skip to content

[build] Fix bootstrapping builds that disable back-deployment #73619

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 17 additions & 13 deletions cmake/modules/AddSwift.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ function(_add_swift_runtime_link_flags target relpath_to_lib_dir bootstrapping)

# Note we only check this for bootstrapping, since you ought to
# be able to build using hosttools with the stdlib disabled.
if(ASRLF_BOOTSTRAPPING_MODE MATCHES "BOOTSTRAPPING.*")
if(ASRLF_BOOTSTRAPPING_MODE MATCHES "BOOTSTRAPPING.*" AND SWIFT_STDLIB_SUPPORT_BACK_DEPLOYMENT)
# HostCompatibilityLibs is defined as an interface library that
# does not generate any concrete build target
# (https://cmake.org/cmake/help/latest/command/add_library.html#interface-libraries)
Expand Down Expand Up @@ -519,12 +519,14 @@ function(_add_swift_runtime_link_flags target relpath_to_lib_dir bootstrapping)
# Add the SDK directory for the host platform.
target_link_directories(${target} PRIVATE "${sdk_dir}")

# A backup in case the toolchain doesn't have one of the compatibility libraries.
# We are using on purpose `add_dependencies` instead of `target_link_libraries`,
# since we want to ensure the linker is pulling the matching archives
# only if needed
target_link_directories(${target} PRIVATE "${compatibility_libs_path}")
add_dependencies(${target} ${compatibility_libs})
if(compatibility_libs_path)
# A backup in case the toolchain doesn't have one of the compatibility libraries.
# We are using on purpose `add_dependencies` instead of `target_link_libraries`,
# since we want to ensure the linker is pulling the matching archives
# only if needed
target_link_directories(${target} PRIVATE "${compatibility_libs_path}")
add_dependencies(${target} ${compatibility_libs})
endif()

# Include the abi stable system stdlib in our rpath.
set(swift_runtime_rpath "/usr/lib/swift")
Expand All @@ -535,12 +537,14 @@ function(_add_swift_runtime_link_flags target relpath_to_lib_dir bootstrapping)
get_bootstrapping_swift_lib_dir(bs_lib_dir "${bootstrapping}")
target_link_directories(${target} PRIVATE ${bs_lib_dir})

# Required to pick up the built libswiftCompatibility<n>.a libraries
# We are using on purpose `add_dependencies` instead of `target_link_libraries`,
# since we want to ensure the linker is pulling the matching archives
# only if needed
target_link_directories(${target} PRIVATE "${compatibility_libs_path}")
add_dependencies(${target} ${compatibility_libs})
if(compatibility_libs_path)
# Required to pick up the built libswiftCompatibility<n>.a libraries
# We are using on purpose `add_dependencies` instead of `target_link_libraries`,
# since we want to ensure the linker is pulling the matching archives
# only if needed
target_link_directories(${target} PRIVATE "${compatibility_libs_path}")
add_dependencies(${target} ${compatibility_libs})
endif()

# At runtime link against the built swift libraries from the current
# bootstrapping stage.
Expand Down