Skip to content

Commit 73133d3

Browse files
authored
Set rpath to compatibility libraries (#5703)
We're currently loading the incorrect version of the concurrency compatibility libraries in OSS toolchains. rdar://92270166
1 parent 64546fb commit 73133d3

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

Utilities/bootstrap

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,14 @@ def add_rpath_for_cmake_build(args, rpath):
559559
note(' '.join(add_rpath_cmd))
560560
subprocess.call(add_rpath_cmd, stderr=subprocess.PIPE)
561561

562+
def get_swift_backdeploy_library_paths(args):
563+
if platform.system() == 'Darwin':
564+
# Need to include backwards compatibility libraries for Concurrency
565+
# FIXME: Would be nice if we could get this from `swiftc -print-target-info`
566+
return ['/usr/lib/swift', args.target_info["paths"]["runtimeLibraryPaths"][0] + '/../../swift-5.5/macosx']
567+
else:
568+
return []
569+
562570
def build_swiftpm_with_cmake(args):
563571
"""Builds SwiftPM using CMake."""
564572
note("Building SwiftPM (with CMake)")
@@ -590,6 +598,10 @@ def build_swiftpm_with_cmake(args):
590598
add_rpath_for_cmake_build(args, os.path.join(args.build_dirs["swift-system"], "lib"))
591599
add_rpath_for_cmake_build(args, os.path.join(args.build_dirs["swift-collections"], "lib"))
592600

601+
# rpaths for compatibility libraries
602+
for lib_path in get_swift_backdeploy_library_paths(args):
603+
add_rpath_for_cmake_build(args, lib_path)
604+
593605
def build_swiftpm_with_swiftpm(args, integrated_swift_driver):
594606
"""Builds SwiftPM using the version of SwiftPM built with CMake."""
595607

@@ -739,6 +751,10 @@ def get_swiftpm_flags(args):
739751
# toolchains that include libraries not part of the OS (e.g. PythonKit or
740752
# TensorFlow).
741753
if platform.system() == "Darwin":
754+
# rpaths for compatibility libraries
755+
for lib_path in get_swift_backdeploy_library_paths(args):
756+
build_flags.extend(["-Xlinker", "-rpath", "-Xlinker", lib_path])
757+
742758
swift_library_rpath_prefix = "@executable_path/../"
743759
elif platform.system() == 'Linux' or platform.system() == 'OpenBSD':
744760
# `$ORIGIN` is an ELF construct.

0 commit comments

Comments
 (0)