about summary refs log tree commit diff
path: root/src/bootstrap/bootstrap.py
diff options
context:
space:
mode:
authorNilstrieb <48135649+Nilstrieb@users.noreply.github.com>2024-03-22 21:52:44 +0100
committerNilstrieb <48135649+Nilstrieb@users.noreply.github.com>2024-03-22 22:38:48 +0100
commit60b97a2f3d6bd60edf7f9410ce04fd38e33a2192 (patch)
tree63143bb7f0819a8e70b8b9439eea37c0ea3603e3 /src/bootstrap/bootstrap.py
parentb3df0d7e5ef5f7dbeeca3fb289c65680ad013f87 (diff)
downloadrust-60b97a2f3d6bd60edf7f9410ce04fd38e33a2192.tar.gz
rust-60b97a2f3d6bd60edf7f9410ce04fd38e33a2192.zip
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.
Diffstat (limited to 'src/bootstrap/bootstrap.py')
-rw-r--r--src/bootstrap/bootstrap.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/bootstrap/bootstrap.py b/src/bootstrap/bootstrap.py
index 6e49bcc9744..30d728aa230 100644
--- a/src/bootstrap/bootstrap.py
+++ b/src/bootstrap/bootstrap.py
@@ -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()]