about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/tools/rust/rustup/0001-dynamically-patchelf-binaries.patch
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/development/tools/rust/rustup/0001-dynamically-patchelf-binaries.patch')
-rw-r--r--nixpkgs/pkgs/development/tools/rust/rustup/0001-dynamically-patchelf-binaries.patch42
1 files changed, 42 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/development/tools/rust/rustup/0001-dynamically-patchelf-binaries.patch b/nixpkgs/pkgs/development/tools/rust/rustup/0001-dynamically-patchelf-binaries.patch
new file mode 100644
index 000000000000..2b191031da60
--- /dev/null
+++ b/nixpkgs/pkgs/development/tools/rust/rustup/0001-dynamically-patchelf-binaries.patch
@@ -0,0 +1,42 @@
+diff --git a/src/dist/component/package.rs b/src/dist/component/package.rs
+index 73a533b5..408ab815 100644
+--- a/src/dist/component/package.rs
++++ b/src/dist/component/package.rs
+@@ -113,6 +113,7 @@ fn install<'a>(
+                     } else {
+                         builder.move_file(path.clone(), &src_path)?
+                     }
++                    nix_patchelf_if_needed(&target.prefix().path().join(path.clone()), &src_path)
+                 }
+                 "dir" => {
+                     if self.copy {
+@@ -135,6 +136,29 @@ fn components(&self) -> Vec<String> {
+     }
+ }
+ 
++fn nix_patchelf_if_needed(dest_path: &Path, src_path: &Path) {
++    let (is_bin, is_lib) = if let Some(p) = src_path.parent() {
++        (p.ends_with("bin") || p.ends_with("libexec"), p.ends_with("lib"))
++    } else {
++        (false, false)
++    };
++
++    if is_bin {
++        let _ = ::std::process::Command::new("@patchelf@/bin/patchelf")
++            .arg("--set-interpreter")
++            .arg("@dynamicLinker@")
++            .arg(dest_path)
++            .output();
++    }
++    else if is_lib {
++        let _ = ::std::process::Command::new("@patchelf@/bin/patchelf")
++            .arg("--set-rpath")
++            .arg("@libPath@")
++            .arg(dest_path)
++            .output();
++    }
++}
++
+ #[derive(Debug)]
+ pub(crate) struct TarPackage<'a>(DirectoryPackage, temp::Dir<'a>);
+