Skip to content

Commit 7fb99d6

Browse files
witchof0x20matklad
authored andcommitted
(rustup): (add zlib to rpath in rustup libraries)
(Rust now has a dynamic library dependence on zlib. (see rust-lang/rust#72696))
1 parent c9d124e commit 7fb99d6

File tree

2 files changed

+25
-17
lines changed

2 files changed

+25
-17
lines changed

pkgs/development/tools/rust/rustup/0001-dynamically-patchelf-binaries.patch

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,24 @@
11
diff --git a/src/dist/component/package.rs b/src/dist/component/package.rs
2-
index 4b432785..fa45e87e 100644
2+
index 3beddf54..0f859b8d 100644
33
--- a/src/dist/component/package.rs
44
+++ b/src/dist/component/package.rs
5-
@@ -109,10 +109,11 @@ impl Package for DirectoryPackage {
6-
match &*part.0 {
7-
"file" => {
8-
if self.copy {
9-
- builder.copy_file(path.clone(), &src_path)?
10-
+ builder.copy_file(path.clone(), &src_path)?;
5+
@@ -113,6 +113,7 @@ impl Package for DirectoryPackage {
116
} else {
12-
- builder.move_file(path.clone(), &src_path)?
13-
+ builder.move_file(path.clone(), &src_path)?;
7+
builder.move_file(path.clone(), &src_path)?
148
}
159
+ nix_patchelf_if_needed(&target.prefix().path().join(path.clone()), &src_path)
1610
}
1711
"dir" => {
1812
if self.copy {
19-
@@ -135,6 +136,22 @@ impl Package for DirectoryPackage {
13+
@@ -135,6 +136,29 @@ impl Package for DirectoryPackage {
2014
}
2115
}
2216

2317
+fn nix_patchelf_if_needed(dest_path: &Path, src_path: &Path) {
24-
+ let is_bin = if let Some(p) = src_path.parent() {
25-
+ p.ends_with("bin")
18+
+ let (is_bin, is_lib) = if let Some(p) = src_path.parent() {
19+
+ (p.ends_with("bin"), p.ends_with("lib"))
2620
+ } else {
27-
+ false
21+
+ (false, false)
2822
+ };
2923
+
3024
+ if is_bin {
@@ -34,6 +28,13 @@ index 4b432785..fa45e87e 100644
3428
+ .arg(dest_path)
3529
+ .output();
3630
+ }
31+
+ else if is_lib {
32+
+ let _ = ::std::process::Command::new("@patchelf@/bin/patchelf")
33+
+ .arg("--set-rpath")
34+
+ .arg("@libPath@")
35+
+ .arg(dest_path)
36+
+ .output();
37+
+ }
3738
+}
3839
+
3940
#[derive(Debug)]

pkgs/development/tools/rust/rustup/default.nix

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{ stdenv, lib, runCommand, patchelf
22
, fetchFromGitHub, rustPlatform
3-
, pkgconfig, curl, Security, CoreServices }:
3+
, pkgconfig, curl, zlib, Security, CoreServices }:
44

55
rustPlatform.buildRustPackage rec {
66
pname = "rustup";
@@ -18,18 +18,25 @@ rustPlatform.buildRustPackage rec {
1818
nativeBuildInputs = [ pkgconfig ];
1919

2020
buildInputs = [
21-
curl
21+
curl zlib
2222
] ++ stdenv.lib.optionals stdenv.isDarwin [ CoreServices Security ];
2323

2424
cargoBuildFlags = [ "--features no-self-update" ];
2525

2626
patches = lib.optionals stdenv.isLinux [
27-
(runCommand "0001-dynamically-patchelf-binaries.patch" { CC=stdenv.cc; patchelf = patchelf; } ''
27+
(let
28+
libPath = lib.makeLibraryPath [
29+
zlib # libz.so.1
30+
];
31+
in
32+
(runCommand "0001-dynamically-patchelf-binaries.patch" { CC=stdenv.cc; patchelf = patchelf; libPath = "$ORIGIN/../lib:${libPath}"; } ''
2833
export dynamicLinker=$(cat $CC/nix-support/dynamic-linker)
2934
substitute ${./0001-dynamically-patchelf-binaries.patch} $out \
3035
--subst-var patchelf \
31-
--subst-var dynamicLinker
36+
--subst-var dynamicLinker \
37+
--subst-var libPath
3238
'')
39+
)
3340
];
3441

3542
doCheck = !stdenv.isAarch64 && !stdenv.isDarwin;

0 commit comments

Comments
 (0)