@@ -413,7 +413,7 @@ def download_stage0(self):
413
413
lib_dir = "{}/lib" .format (self .bin_root ())
414
414
for lib in os .listdir (lib_dir ):
415
415
if lib .endswith (".so" ):
416
- self .fix_bin_or_dylib ("{}/{}" . format (lib_dir , lib ))
416
+ self .fix_bin_or_dylib (os . path . join (lib_dir , lib ), rpath_libz = True )
417
417
with output (self .rustc_stamp ()) as rust_stamp :
418
418
rust_stamp .write (self .date )
419
419
@@ -451,10 +451,15 @@ def download_stage0(self):
451
451
"{}/src/bootstrap/download-ci-llvm-stamp" .format (top_level ),
452
452
]).decode (sys .getdefaultencoding ()).strip ()
453
453
llvm_assertions = self .get_toml ('assertions' , 'llvm' ) == 'true'
454
+ llvm_root = self .llvm_root ()
455
+ llvm_lib = os .path .join (llvm_root , "lib" )
454
456
if self .program_out_of_date (self .llvm_stamp (), llvm_sha + str (llvm_assertions )):
455
457
self ._download_ci_llvm (llvm_sha , llvm_assertions )
456
458
for binary in ["llvm-config" , "FileCheck" ]:
457
- self .fix_bin_or_dylib ("{}/bin/{}" .format (self .llvm_root (), binary ))
459
+ self .fix_bin_or_dylib (os .path .join (llvm_root , "bin" , binary ), rpath_libz = True )
460
+ for lib in os .listdir (llvm_lib ):
461
+ if lib .endswith (".so" ):
462
+ self .fix_bin_or_dylib (os .path .join (llvm_lib , lib ), rpath_libz = True )
458
463
with output (self .llvm_stamp ()) as llvm_stamp :
459
464
llvm_stamp .write (llvm_sha + str (llvm_assertions ))
460
465
@@ -501,7 +506,7 @@ def _download_ci_llvm(self, llvm_sha, llvm_assertions):
501
506
match = "rust-dev" ,
502
507
verbose = self .verbose )
503
508
504
- def fix_bin_or_dylib (self , fname ):
509
+ def fix_bin_or_dylib (self , fname , rpath_libz = False ):
505
510
"""Modifies the interpreter section of 'fname' to fix the dynamic linker,
506
511
or the RPATH section, to fix the dynamic library search path
507
512
@@ -571,20 +576,22 @@ def fix_bin_or_dylib(self, fname):
571
576
self .nix_deps_dir = nix_deps_dir
572
577
573
578
patchelf = "{}/patchelf/bin/patchelf" .format (nix_deps_dir )
579
+ patchelf_args = []
574
580
575
- if fname . endswith ( ".so" ) :
576
- # Dynamic library, patch RPATH to point to system dependencies.
581
+ if rpath_libz :
582
+ # Patch RPATH to add `zlib` dependency that stems from LLVM
577
583
dylib_deps = ["zlib" ]
578
584
rpath_entries = [
579
585
# Relative default, all binary and dynamic libraries we ship
580
586
# appear to have this (even when `../lib` is redundant).
581
587
"$ORIGIN/../lib" ,
582
588
] + ["{}/{}/lib" .format (nix_deps_dir , dep ) for dep in dylib_deps ]
583
- patchelf_args = ["--set-rpath" , ":" .join (rpath_entries )]
584
- else :
589
+ patchelf_args += ["--set-rpath" , ":" .join (rpath_entries )]
590
+ if not fname .endswith (".so" ):
591
+ # Finally, set the corret .interp for binaries
585
592
bintools_dir = "{}/stdenv.cc.bintools" .format (nix_deps_dir )
586
593
with open ("{}/nix-support/dynamic-linker" .format (bintools_dir )) as dynamic_linker :
587
- patchelf_args = ["--set-interpreter" , dynamic_linker .read ().rstrip ()]
594
+ patchelf_args + = ["--set-interpreter" , dynamic_linker .read ().rstrip ()]
588
595
589
596
try :
590
597
subprocess .check_output ([patchelf ] + patchelf_args + [fname ])
0 commit comments