@@ -558,6 +558,14 @@ def add_rpath_for_cmake_build(args, rpath):
558
558
note (' ' .join (add_rpath_cmd ))
559
559
subprocess .call (add_rpath_cmd , stderr = subprocess .PIPE )
560
560
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
+
561
569
def build_swiftpm_with_cmake (args ):
562
570
"""Builds SwiftPM using CMake."""
563
571
note ("Building SwiftPM (with CMake)" )
@@ -589,6 +597,10 @@ def build_swiftpm_with_cmake(args):
589
597
add_rpath_for_cmake_build (args , os .path .join (args .build_dirs ["swift-system" ], "lib" ))
590
598
add_rpath_for_cmake_build (args , os .path .join (args .build_dirs ["swift-collections" ], "lib" ))
591
599
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
+
592
604
def build_swiftpm_with_swiftpm (args , integrated_swift_driver ):
593
605
"""Builds SwiftPM using the version of SwiftPM built with CMake."""
594
606
@@ -684,7 +696,7 @@ def get_swiftpm_env_cmd(args):
684
696
env_cmd .append ("SWIFTPM_MACOS_DEPLOYMENT_TARGET=%s" % g_macos_deployment_target )
685
697
686
698
if args .bootstrap :
687
- libs_joined = ":" . join ( [
699
+ library_paths = [
688
700
os .path .join (args .bootstrap_dir , "lib" ),
689
701
os .path .join (args .build_dirs ["tsc" ], "lib" ),
690
702
os .path .join (args .build_dirs ["llbuild" ], "lib" ),
@@ -694,11 +706,14 @@ def get_swiftpm_env_cmd(args):
694
706
os .path .join (args .build_dirs ["swift-crypto" ], "lib" ),
695
707
os .path .join (args .build_dirs ["swift-system" ], "lib" ),
696
708
os .path .join (args .build_dirs ["swift-collections" ], "lib" ),
697
- ] + args . target_info [ "paths" ][ "runtimeLibraryPaths" ])
709
+ ]
698
710
699
711
if platform .system () == 'Darwin' :
712
+ # Does not include Swift runtime library paths because of rdar://75752698
713
+ libs_joined = ":" .join (library_paths )
700
714
env_cmd .append ("DYLD_LIBRARY_PATH=%s" % libs_joined )
701
715
else :
716
+ libs_joined = ":" .join (library_paths + args .target_info ["paths" ]["runtimeLibraryPaths" ])
702
717
env_cmd .append ("LD_LIBRARY_PATH=%s" % libs_joined )
703
718
704
719
return env_cmd
@@ -738,6 +753,10 @@ def get_swiftpm_flags(args):
738
753
# toolchains that include libraries not part of the OS (e.g. PythonKit or
739
754
# TensorFlow).
740
755
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
+
741
760
swift_library_rpath_prefix = "@executable_path/../"
742
761
elif platform .system () == 'Linux' or platform .system () == 'OpenBSD' :
743
762
# `$ORIGIN` is an ELF construct.
0 commit comments