Skip to content

Commit d045aa6

Browse files
authored
Do not test inferior Swift libraries on Darwin (#5611)
On platforms with ABI-stable Swift runtime libraries (currently only Darwin), we should not set `DYLD_LIBRARY_PATHS` to include the inferior Swift libs in `bootstrap` because compatibility issues can arise from SwiftPM's use of Foundation (which itself is a client of the stdlib) and from using dyld4 (which is used on macOS 12+). rdar://88475529
1 parent dd38692 commit d045aa6

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

Utilities/bootstrap

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

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

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

@@ -684,7 +696,7 @@ def get_swiftpm_env_cmd(args):
684696
env_cmd.append("SWIFTPM_MACOS_DEPLOYMENT_TARGET=%s" % g_macos_deployment_target)
685697

686698
if args.bootstrap:
687-
libs_joined = ":".join([
699+
library_paths = [
688700
os.path.join(args.bootstrap_dir, "lib"),
689701
os.path.join(args.build_dirs["tsc"], "lib"),
690702
os.path.join(args.build_dirs["llbuild"], "lib"),
@@ -694,11 +706,14 @@ def get_swiftpm_env_cmd(args):
694706
os.path.join(args.build_dirs["swift-crypto"], "lib"),
695707
os.path.join(args.build_dirs["swift-system"], "lib"),
696708
os.path.join(args.build_dirs["swift-collections"], "lib"),
697-
] + args.target_info["paths"]["runtimeLibraryPaths"])
709+
]
698710

699711
if platform.system() == 'Darwin':
712+
# Does not include Swift runtime library paths because of rdar://75752698
713+
libs_joined = ":".join(library_paths)
700714
env_cmd.append("DYLD_LIBRARY_PATH=%s" % libs_joined)
701715
else:
716+
libs_joined = ":".join(library_paths + args.target_info["paths"]["runtimeLibraryPaths"])
702717
env_cmd.append("LD_LIBRARY_PATH=%s" % libs_joined)
703718

704719
return env_cmd
@@ -738,6 +753,10 @@ def get_swiftpm_flags(args):
738753
# toolchains that include libraries not part of the OS (e.g. PythonKit or
739754
# TensorFlow).
740755
if platform.system() == "Darwin":
756+
# rpaths for compatibility libraries
757+
for lib_path in get_swift_backdeploy_library_paths(args):
758+
build_flags.extend(["-Xlinker", "-rpath", "-Xlinker", lib_path])
759+
741760
swift_library_rpath_prefix = "@executable_path/../"
742761
elif platform.system() == 'Linux' or platform.system() == 'OpenBSD':
743762
# `$ORIGIN` is an ELF construct.

0 commit comments

Comments
 (0)