Auto merge of #122911 - Nilstrieb:live-love-patch, r=clubby789
Fix nix patching for LLVM 18 LLVM 18 now ships `libLLVM*.so.*`, so `.so` is not the sole extension anymore, which breaks the dylib detection. Oops! Adjust it to only search for `.so` somewhere. fixes #122906
This commit is contained in:
commit
c3b05c6e5b
@ -612,8 +612,14 @@ class RustBuild(object):
|
||||
self.fix_bin_or_dylib("{}/libexec/rust-analyzer-proc-macro-srv".format(bin_root))
|
||||
lib_dir = "{}/lib".format(bin_root)
|
||||
for lib in os.listdir(lib_dir):
|
||||
if lib.endswith(".so"):
|
||||
self.fix_bin_or_dylib(os.path.join(lib_dir, lib))
|
||||
# .so is not necessarily the suffix, there can be version numbers afterwards.
|
||||
if ".so" in lib:
|
||||
elf_path = os.path.join(lib_dir, lib)
|
||||
with open(elf_path, "rb") as f:
|
||||
magic = f.read(4)
|
||||
# Patchelf will skip non-ELF files, but issue a warning.
|
||||
if magic == b"\x7fELF":
|
||||
self.fix_bin_or_dylib(elf_path)
|
||||
|
||||
with output(self.rustc_stamp()) as rust_stamp:
|
||||
rust_stamp.write(key)
|
||||
@ -725,7 +731,7 @@ class RustBuild(object):
|
||||
os.path.join(os.path.realpath(nix_deps_dir), "lib")
|
||||
]
|
||||
patchelf_args = ["--set-rpath", ":".join(rpath_entries)]
|
||||
if not fname.endswith(".so"):
|
||||
if ".so" not in fname:
|
||||
# Finally, set the correct .interp for binaries
|
||||
with open("{}/nix-support/dynamic-linker".format(nix_deps_dir)) as dynamic_linker:
|
||||
patchelf_args += ["--set-interpreter", dynamic_linker.read().rstrip()]
|
||||
|
@ -1,6 +1,6 @@
|
||||
use std::{
|
||||
env,
|
||||
ffi::{OsStr, OsString},
|
||||
ffi::OsString,
|
||||
fs::{self, File},
|
||||
io::{BufRead, BufReader, BufWriter, ErrorKind, Write},
|
||||
path::{Path, PathBuf},
|
||||
@ -183,7 +183,7 @@ fn fix_bin_or_dylib(&self, fname: &Path) {
|
||||
entries
|
||||
};
|
||||
patchelf.args(&[OsString::from("--set-rpath"), rpath_entries]);
|
||||
if !fname.extension().map_or(false, |ext| ext == "so") {
|
||||
if !path_is_dylib(fname) {
|
||||
// Finally, set the correct .interp for binaries
|
||||
let dynamic_linker_path = nix_deps_dir.join("nix-support/dynamic-linker");
|
||||
// FIXME: can we support utf8 here? `args` doesn't accept Vec<u8>, only OsString ...
|
||||
@ -440,7 +440,7 @@ pub(crate) fn maybe_download_rustfmt(&self) -> Option<PathBuf> {
|
||||
let lib_dir = bin_root.join("lib");
|
||||
for lib in t!(fs::read_dir(&lib_dir), lib_dir.display().to_string()) {
|
||||
let lib = t!(lib);
|
||||
if lib.path().extension() == Some(OsStr::new("so")) {
|
||||
if path_is_dylib(&lib.path()) {
|
||||
self.fix_bin_or_dylib(&lib.path());
|
||||
}
|
||||
}
|
||||
@ -545,7 +545,7 @@ fn download_toolchain(
|
||||
let lib_dir = bin_root.join("lib");
|
||||
for lib in t!(fs::read_dir(&lib_dir), lib_dir.display().to_string()) {
|
||||
let lib = t!(lib);
|
||||
if lib.path().extension() == Some(OsStr::new("so")) {
|
||||
if path_is_dylib(&lib.path()) {
|
||||
self.fix_bin_or_dylib(&lib.path());
|
||||
}
|
||||
}
|
||||
@ -697,7 +697,7 @@ pub(crate) fn maybe_download_ci_llvm(&self) {
|
||||
let llvm_lib = llvm_root.join("lib");
|
||||
for entry in t!(fs::read_dir(llvm_lib)) {
|
||||
let lib = t!(entry).path();
|
||||
if lib.extension().map_or(false, |ext| ext == "so") {
|
||||
if path_is_dylib(&lib) {
|
||||
self.fix_bin_or_dylib(&lib);
|
||||
}
|
||||
}
|
||||
@ -743,3 +743,8 @@ fn download_ci_llvm(&self, llvm_sha: &str) {
|
||||
self.unpack(&tarball, &llvm_root, "rust-dev");
|
||||
}
|
||||
}
|
||||
|
||||
fn path_is_dylib(path: &Path) -> bool {
|
||||
// The .so is not necessarily the extension, it might be libLLVM.so.18.1
|
||||
path.to_str().map_or(false, |path| path.contains(".so"))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user