(rustup): (add zlib to rpath in rustup libraries)

(Rust now has a dynamic library dependence on zlib. (see https://github.com/rust-lang/rust/pull/72696))
This commit is contained in:
Jade Harley
2020-06-22 21:23:01 -05:00
parent 48faedc336
commit 05b765d299
2 changed files with 25 additions and 17 deletions
@@ -1,30 +1,24 @@
diff --git a/src/dist/component/package.rs b/src/dist/component/package.rs
index 4b432785..fa45e87e 100644
index 3beddf54..0f859b8d 100644
--- a/src/dist/component/package.rs
+++ b/src/dist/component/package.rs
@@ -109,10 +109,11 @@ impl Package for DirectoryPackage {
match &*part.0 {
"file" => {
if self.copy {
- builder.copy_file(path.clone(), &src_path)?
+ builder.copy_file(path.clone(), &src_path)?;
@@ -113,6 +113,7 @@ impl Package for DirectoryPackage {
} else {
- builder.move_file(path.clone(), &src_path)?
+ builder.move_file(path.clone(), &src_path)?;
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,22 @@ impl Package for DirectoryPackage {
@@ -135,6 +136,29 @@ impl Package for DirectoryPackage {
}
}
+fn nix_patchelf_if_needed(dest_path: &Path, src_path: &Path) {
+ let is_bin = if let Some(p) = src_path.parent() {
+ p.ends_with("bin")
+ let (is_bin, is_lib) = if let Some(p) = src_path.parent() {
+ (p.ends_with("bin"), p.ends_with("lib"))
+ } else {
+ false
+ (false, false)
+ };
+
+ if is_bin {
@@ -34,6 +28,13 @@ index 4b432785..fa45e87e 100644
+ .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)]