diff options
Diffstat (limited to 'pkgs/development/tools/rust/rustup/0001-use-hardcoded-dynamic-linker.patch')
-rw-r--r-- | pkgs/development/tools/rust/rustup/0001-use-hardcoded-dynamic-linker.patch | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/pkgs/development/tools/rust/rustup/0001-use-hardcoded-dynamic-linker.patch b/pkgs/development/tools/rust/rustup/0001-use-hardcoded-dynamic-linker.patch new file mode 100644 index 00000000000..3b429c1745e --- /dev/null +++ b/pkgs/development/tools/rust/rustup/0001-use-hardcoded-dynamic-linker.patch @@ -0,0 +1,75 @@ +From 36c053f37670c6003f9e8dc001741f7c49e9526a Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= <joerg@thalheim.io> +Date: Sat, 15 Apr 2017 20:42:10 +0200 +Subject: [PATCH] use hardcoded dynamic-linker +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Signed-off-by: Jörg Thalheim <joerg@thalheim.io> +--- + src/rustup-cli/common.rs | 3 ++- + src/rustup/toolchain.rs | 22 ++++++++++++++++++++-- + 2 files changed, 22 insertions(+), 3 deletions(-) + +diff --git a/src/rustup-cli/common.rs b/src/rustup-cli/common.rs +index 1abf345..21096e7 100644 +--- a/src/rustup-cli/common.rs ++++ b/src/rustup-cli/common.rs +@@ -220,7 +220,8 @@ pub fn rustc_version(toolchain: &Toolchain) -> String { + if toolchain.exists() { + let rustc_path = toolchain.binary_file("rustc"); + if utils::is_file(&rustc_path) { +- let mut cmd = Command::new(&rustc_path); ++ let mut cmd = Command::new("@dynamicLinker@"); ++ cmd.arg(&rustc_path); + cmd.arg("--version"); + toolchain.set_ldpath(&mut cmd); + +diff --git a/src/rustup/toolchain.rs b/src/rustup/toolchain.rs +index dc29c32..212a4ab 100644 +--- a/src/rustup/toolchain.rs ++++ b/src/rustup/toolchain.rs +@@ -315,7 +315,7 @@ impl<'a> Toolchain<'a> { + } + Path::new(&binary) + }; +- let mut cmd = Command::new(&path); ++ let mut cmd = wrap_elf_interpreter(&path); + self.set_env(&mut cmd); + Ok(cmd) + } +@@ -363,7 +363,7 @@ impl<'a> Toolchain<'a> { + } else { + src_file + }; +- let mut cmd = Command::new(exe_path); ++ let mut cmd = wrap_elf_interpreter(exe_path); + self.set_env(&mut cmd); + cmd.env("RUSTUP_TOOLCHAIN", &primary_toolchain.name); + Ok(cmd) +@@ -648,3 +648,21 @@ impl<'a> Toolchain<'a> { + path + } + } ++ ++fn wrap_elf_interpreter<S: AsRef<OsStr>>(p: S) -> Command { ++ use std::fs::File; ++ use std::io::Read; ++ let path = Path::new(&p); ++ let is_elf = File::open(path).map(|mut f| { ++ let mut buf = [0; 4]; ++ let _ = f.read(&mut buf); ++ buf == b"\x7fELF"[..] ++ }).unwrap_or(false); ++ if is_elf { ++ let mut cmd = Command::new("@dynamicLinker@"); ++ cmd.arg(&path); ++ cmd ++ } else { ++ Command::new(&path) ++ } ++} +-- +2.12.2 + |