|
1 | 1 | use std::{ |
2 | 2 | env, |
3 | | - ffi::{OsStr, OsString}, |
| 3 | + ffi::OsString, |
4 | 4 | fs::{self, File}, |
5 | 5 | io::{BufRead, BufReader, BufWriter, ErrorKind, Write}, |
6 | 6 | path::{Path, PathBuf}, |
@@ -183,7 +183,7 @@ impl Config { |
183 | 183 | entries |
184 | 184 | }; |
185 | 185 | patchelf.args(&[OsString::from("--set-rpath"), rpath_entries]); |
186 | | - if !fname.extension().map_or(false, |ext| ext == "so") { |
| 186 | + if !path_is_dylib(fname) { |
187 | 187 | // Finally, set the correct .interp for binaries |
188 | 188 | let dynamic_linker_path = nix_deps_dir.join("nix-support/dynamic-linker"); |
189 | 189 | // FIXME: can we support utf8 here? `args` doesn't accept Vec<u8>, only OsString ... |
@@ -440,7 +440,7 @@ impl Config { |
440 | 440 | let lib_dir = bin_root.join("lib"); |
441 | 441 | for lib in t!(fs::read_dir(&lib_dir), lib_dir.display().to_string()) { |
442 | 442 | let lib = t!(lib); |
443 | | - if lib.path().extension() == Some(OsStr::new("so")) { |
| 443 | + if path_is_dylib(&lib.path()) { |
444 | 444 | self.fix_bin_or_dylib(&lib.path()); |
445 | 445 | } |
446 | 446 | } |
@@ -545,7 +545,7 @@ impl Config { |
545 | 545 | let lib_dir = bin_root.join("lib"); |
546 | 546 | for lib in t!(fs::read_dir(&lib_dir), lib_dir.display().to_string()) { |
547 | 547 | let lib = t!(lib); |
548 | | - if lib.path().extension() == Some(OsStr::new("so")) { |
| 548 | + if path_is_dylib(&lib.path()) { |
549 | 549 | self.fix_bin_or_dylib(&lib.path()); |
550 | 550 | } |
551 | 551 | } |
@@ -697,7 +697,7 @@ download-rustc = false |
697 | 697 | let llvm_lib = llvm_root.join("lib"); |
698 | 698 | for entry in t!(fs::read_dir(llvm_lib)) { |
699 | 699 | let lib = t!(entry).path(); |
700 | | - if lib.extension().map_or(false, |ext| ext == "so") { |
| 700 | + if path_is_dylib(&lib) { |
701 | 701 | self.fix_bin_or_dylib(&lib); |
702 | 702 | } |
703 | 703 | } |
@@ -743,3 +743,8 @@ download-rustc = false |
743 | 743 | self.unpack(&tarball, &llvm_root, "rust-dev"); |
744 | 744 | } |
745 | 745 | } |
| 746 | + |
| 747 | +fn path_is_dylib(path: &Path) -> bool { |
| 748 | + // The .so is not necessarily the extension, it might be libLLVM.so.18.1 |
| 749 | + path.to_str().map_or(false, |path| path.contains(".so")) |
| 750 | +} |
0 commit comments