From 18f517fbd626ee0d4502f2237bbcc837366b4c74 Mon Sep 17 00:00:00 2001 From: Matthew Stewart Date: Sat, 14 Jul 2018 11:32:10 -0400 Subject: [PATCH] Enable new dtags in a way that works with binutils 2.30. In 3027bca, binutils was upgraded from 2.28.1 to 2.30. However, in 2.30, the ldmain.c file within binutils, which the nixpkgs new-dtags.patch file is meant to modify, was changed in such a way that the patch no longer works. As a result, the new dtags are not actually enabled, and binaries are built with RPATH set instead of RUNPATH, thereby preventing LD_LIBRARY_PATH from overriding this built-in path. This change corrects this. The patch file is no longer necessary because binutils's ldmain.c now sets link_info.new_dtags based on the configuration flags. This was probably not noticed immediately because, when the derivation is built with nix-build, the fixupPhase runs patchelf --shrink-rpath. patchelf converts any RPATH in the binary into RUNPATH (unless --force-rpath is specified). Of course, if the binary is built without nix-build (such as in a nix-shell), this never occurs, and any RPATH in the binary is left in place. --- pkgs/development/tools/misc/binutils/default.nix | 10 +++++----- pkgs/development/tools/misc/binutils/new-dtags.patch | 10 ---------- 2 files changed, 5 insertions(+), 15 deletions(-) delete mode 100644 pkgs/development/tools/misc/binutils/new-dtags.patch diff --git a/pkgs/development/tools/misc/binutils/default.nix b/pkgs/development/tools/misc/binutils/default.nix index 2badd0ed26a9..890ff7b64a91 100644 --- a/pkgs/development/tools/misc/binutils/default.nix +++ b/pkgs/development/tools/misc/binutils/default.nix @@ -26,11 +26,6 @@ stdenv.mkDerivation rec { }); patches = [ - # Turn on --enable-new-dtags by default to make the linker set - # RUNPATH instead of RPATH on binaries. This is important because - # RUNPATH can be overriden using LD_LIBRARY_PATH at runtime. - ./new-dtags.patch - # Since binutils 2.22, DT_NEEDED flags aren't copied for dynamic outputs. # That requires upstream changes for things to work. So we can patch it to # get the old behaviour by now. @@ -117,6 +112,11 @@ stdenv.mkDerivation rec { "--enable-deterministic-archives" "--disable-werror" "--enable-fix-loongson2f-nop" + + # Turn on --enable-new-dtags by default to make the linker set + # RUNPATH instead of RPATH on binaries. This is important because + # RUNPATH can be overriden using LD_LIBRARY_PATH at runtime. + "--enable-new-dtags" ] ++ optionals gold [ "--enable-gold" "--enable-plugins" ]; doCheck = false; # fails diff --git a/pkgs/development/tools/misc/binutils/new-dtags.patch b/pkgs/development/tools/misc/binutils/new-dtags.patch deleted file mode 100644 index eea6f8c39d57..000000000000 --- a/pkgs/development/tools/misc/binutils/new-dtags.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- binutils/ld/ldmain.c -+++ binutils/ld/ldmain.c -@@ -296,6 +296,7 @@ main (int argc, char **argv) - - link_info.allow_undefined_version = TRUE; - link_info.keep_memory = TRUE; -+ link_info.new_dtags = TRUE; - link_info.combreloc = TRUE; - link_info.strip_discarded = TRUE; - link_info.callbacks = &link_callbacks;