summary refs log tree commit diff
path: root/pkgs/development/tools
diff options
context:
space:
mode:
authorJörg Thalheim <Mic92@users.noreply.github.com>2020-06-23 20:56:35 +0100
committerGitHub <noreply@github.com>2020-06-23 20:56:35 +0100
commit5d8fa2ffa101aecfbb7bec9b423294b0578b441d (patch)
tree3f9457bd5d98cdf5f781dacf50cf7dab5e2305e1 /pkgs/development/tools
parentf166a13c7d3fbb09c9646f3279de168d326e1e13 (diff)
parent05b765d299c44397a299004531bc1d5416413b1e (diff)
downloadnixpkgs-5d8fa2ffa101aecfbb7bec9b423294b0578b441d.tar
nixpkgs-5d8fa2ffa101aecfbb7bec9b423294b0578b441d.tar.gz
nixpkgs-5d8fa2ffa101aecfbb7bec9b423294b0578b441d.tar.bz2
nixpkgs-5d8fa2ffa101aecfbb7bec9b423294b0578b441d.tar.lz
nixpkgs-5d8fa2ffa101aecfbb7bec9b423294b0578b441d.tar.xz
nixpkgs-5d8fa2ffa101aecfbb7bec9b423294b0578b441d.tar.zst
nixpkgs-5d8fa2ffa101aecfbb7bec9b423294b0578b441d.zip
Merge pull request #91327 from witchof0x20/rustupfix
Fix RPATH for libraries downloaded by rustup
Diffstat (limited to 'pkgs/development/tools')
-rw-r--r--pkgs/development/tools/rust/rustup/0001-dynamically-patchelf-binaries.patch27
-rw-r--r--pkgs/development/tools/rust/rustup/default.nix15
2 files changed, 25 insertions, 17 deletions
diff --git a/pkgs/development/tools/rust/rustup/0001-dynamically-patchelf-binaries.patch b/pkgs/development/tools/rust/rustup/0001-dynamically-patchelf-binaries.patch
index d46ad59109e..13649b387a3 100644
--- a/pkgs/development/tools/rust/rustup/0001-dynamically-patchelf-binaries.patch
+++ b/pkgs/development/tools/rust/rustup/0001-dynamically-patchelf-binaries.patch
@@ -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)]
diff --git a/pkgs/development/tools/rust/rustup/default.nix b/pkgs/development/tools/rust/rustup/default.nix
index 959eb6875ce..688159445d5 100644
--- a/pkgs/development/tools/rust/rustup/default.nix
+++ b/pkgs/development/tools/rust/rustup/default.nix
@@ -1,6 +1,6 @@
 { stdenv, lib, runCommand, patchelf
 , fetchFromGitHub, rustPlatform
-, pkgconfig, curl, Security, CoreServices }:
+, pkgconfig, curl, zlib, Security, CoreServices }:
 
 rustPlatform.buildRustPackage rec {
   pname = "rustup";
@@ -18,18 +18,25 @@ rustPlatform.buildRustPackage rec {
   nativeBuildInputs = [ pkgconfig ];
 
   buildInputs = [
-    curl
+    curl zlib
   ] ++ stdenv.lib.optionals stdenv.isDarwin [ CoreServices Security ];
 
   cargoBuildFlags = [ "--features no-self-update" ];
 
   patches = lib.optionals stdenv.isLinux [
-    (runCommand "0001-dynamically-patchelf-binaries.patch" { CC=stdenv.cc; patchelf = patchelf; } ''
+    (let
+      libPath = lib.makeLibraryPath [
+        zlib # libz.so.1
+      ];
+    in
+      (runCommand "0001-dynamically-patchelf-binaries.patch" { CC=stdenv.cc; patchelf = patchelf; libPath = "$ORIGIN/../lib:${libPath}"; } ''
        export dynamicLinker=$(cat $CC/nix-support/dynamic-linker)
        substitute ${./0001-dynamically-patchelf-binaries.patch} $out \
          --subst-var patchelf \
-         --subst-var dynamicLinker
+         --subst-var dynamicLinker \
+         --subst-var libPath
     '')
+    )
   ];
 
   doCheck = !stdenv.isAarch64 && !stdenv.isDarwin;