@@ -747,13 +747,13 @@ def get_swiftc_path():
747
747
except :
748
748
error ("unable to find 'swiftc' tool for bootstrap build" )
749
749
750
- def delete_rpath (rpath , binary ):
750
+ def delete_rpath (rpath , binary , allowFailing = False ):
751
751
if platform .system () == 'Darwin' :
752
752
cmd = ["install_name_tool" , "-delete_rpath" , rpath , binary ]
753
753
note ("removing RPATH from %s: %s" % (
754
754
binary , ' ' .join (cmd )))
755
755
result = subprocess .call (cmd )
756
- if result != 0 :
756
+ if not allowFailing and result != 0 :
757
757
error ("command failed with exit status %d" % (result ,))
758
758
else :
759
759
error ("unable to remove RPATHs on this platform" )
@@ -789,10 +789,8 @@ def installBinary(binary_path, install_path, swiftc_path, add_rpaths=[], delete_
789
789
if platform .system () == 'Darwin' :
790
790
installed_path = os .path .join (
791
791
install_path , os .path .basename (binary_path ))
792
- stdlib_path = os .path .normpath (
793
- os .path .join (os .path .dirname (os .path .realpath (swiftc_path )), ".." ,
794
- "lib" , "swift" , "macosx" ))
795
- delete_rpath (stdlib_path , installed_path )
792
+ stdlib_path = swift_macos_stdlib_path (swiftc_path )
793
+ delete_rpath (stdlib_path , installed_path , True )
796
794
797
795
# Remove additional RPATHs, if requested.
798
796
for rpath in delete_rpaths :
@@ -802,6 +800,8 @@ def installBinary(binary_path, install_path, swiftc_path, add_rpaths=[], delete_
802
800
for rpath in add_rpaths :
803
801
add_rpath (rpath , installed_path )
804
802
803
+ def swift_macos_stdlib_path (swiftc ):
804
+ return os .path .normpath (os .path .join (os .path .dirname (os .path .realpath (swiftc )), ".." , "lib" , "swift" , "macosx" ))
805
805
806
806
def llbuild_import_paths (args ):
807
807
if args .llbuild_link_framework :
@@ -1232,6 +1232,13 @@ def main():
1232
1232
]
1233
1233
if args .sysroot :
1234
1234
env_cmd .append ("SYSROOT=" + args .sysroot )
1235
+
1236
+ # Look for stdlib libraries using dyld library path on macOS.
1237
+ if platform .system () == 'Darwin' :
1238
+ stdlib_path = swift_macos_stdlib_path (args .swiftc_path )
1239
+ build_flags .extend (["-Xlinker" , "-rpath" , "-Xlinker" , stdlib_path ])
1240
+ env_cmd .append ("DYLD_LIBRARY_PATH=" + stdlib_path )
1241
+
1235
1242
cmd = env_cmd + [bootstrapped_product ] + build_flags
1236
1243
1237
1244
# Always build tests in stage2.
0 commit comments