Skip to content

Commit 1d54816

Browse files
authored
Merge pull request #73619 from apple/egorzhdan/bootstrapping-without-backdeployment
[build] Fix bootstrapping builds that disable back-deployment
2 parents 3caef44 + 421ee98 commit 1d54816

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

cmake/modules/AddSwift.cmake

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ function(_add_swift_runtime_link_flags target relpath_to_lib_dir bootstrapping)
469469
470470
# Note we only check this for bootstrapping, since you ought to
471471
# be able to build using hosttools with the stdlib disabled.
472-
if(ASRLF_BOOTSTRAPPING_MODE MATCHES "BOOTSTRAPPING.*")
472+
if(ASRLF_BOOTSTRAPPING_MODE MATCHES "BOOTSTRAPPING.*" AND SWIFT_STDLIB_SUPPORT_BACK_DEPLOYMENT)
473473
# HostCompatibilityLibs is defined as an interface library that
474474
# does not generate any concrete build target
475475
# (https://cmake.org/cmake/help/latest/command/add_library.html#interface-libraries)
@@ -519,12 +519,14 @@ function(_add_swift_runtime_link_flags target relpath_to_lib_dir bootstrapping)
519519
# Add the SDK directory for the host platform.
520520
target_link_directories(${target} PRIVATE "${sdk_dir}")
521521
522-
# A backup in case the toolchain doesn't have one of the compatibility libraries.
523-
# We are using on purpose `add_dependencies` instead of `target_link_libraries`,
524-
# since we want to ensure the linker is pulling the matching archives
525-
# only if needed
526-
target_link_directories(${target} PRIVATE "${compatibility_libs_path}")
527-
add_dependencies(${target} ${compatibility_libs})
522+
if(compatibility_libs_path)
523+
# A backup in case the toolchain doesn't have one of the compatibility libraries.
524+
# We are using on purpose `add_dependencies` instead of `target_link_libraries`,
525+
# since we want to ensure the linker is pulling the matching archives
526+
# only if needed
527+
target_link_directories(${target} PRIVATE "${compatibility_libs_path}")
528+
add_dependencies(${target} ${compatibility_libs})
529+
endif()
528530
529531
# Include the abi stable system stdlib in our rpath.
530532
set(swift_runtime_rpath "/usr/lib/swift")
@@ -535,12 +537,14 @@ function(_add_swift_runtime_link_flags target relpath_to_lib_dir bootstrapping)
535537
get_bootstrapping_swift_lib_dir(bs_lib_dir "${bootstrapping}")
536538
target_link_directories(${target} PRIVATE ${bs_lib_dir})
537539
538-
# Required to pick up the built libswiftCompatibility<n>.a libraries
539-
# We are using on purpose `add_dependencies` instead of `target_link_libraries`,
540-
# since we want to ensure the linker is pulling the matching archives
541-
# only if needed
542-
target_link_directories(${target} PRIVATE "${compatibility_libs_path}")
543-
add_dependencies(${target} ${compatibility_libs})
540+
if(compatibility_libs_path)
541+
# Required to pick up the built libswiftCompatibility<n>.a libraries
542+
# We are using on purpose `add_dependencies` instead of `target_link_libraries`,
543+
# since we want to ensure the linker is pulling the matching archives
544+
# only if needed
545+
target_link_directories(${target} PRIVATE "${compatibility_libs_path}")
546+
add_dependencies(${target} ${compatibility_libs})
547+
endif()
544548
545549
# At runtime link against the built swift libraries from the current
546550
# bootstrapping stage.

0 commit comments

Comments
 (0)