From 0889bbe88fc6c6a9c962421ce38b7f2fad690e4a Mon Sep 17 00:00:00 2001 From: Evgeny Egorochkin Date: Tue, 25 Jun 2013 10:53:37 +0300 Subject: [PATCH] Patch binutils to produce more deterministic output --- pkgs/development/tools/misc/binutils/default.nix | 9 ++++++--- .../tools/misc/binutils/deterministic.patch | 12 ++++++++++++ pkgs/top-level/all-packages.nix | 2 ++ 3 files changed, 20 insertions(+), 3 deletions(-) create mode 100644 pkgs/development/tools/misc/binutils/deterministic.patch diff --git a/pkgs/development/tools/misc/binutils/default.nix b/pkgs/development/tools/misc/binutils/default.nix index e1afceebaa23..ca763a5e1fb3 100644 --- a/pkgs/development/tools/misc/binutils/default.nix +++ b/pkgs/development/tools/misc/binutils/default.nix @@ -1,4 +1,6 @@ -{ stdenv, fetchurl, noSysDirs, zlib, cross ? null, gold ? false, bison ? null, flex2535 ? null, bc ? null, dejagnu ? null }: +{ stdenv, fetchurl, noSysDirs, zlib +, cross ? null, gold ? false, bison ? null, flex2535 ? null, bc ? null, dejagnu ? null +, deterministic ? false }: let basename = "binutils-2.23.1"; in stdenv.mkDerivation rec { @@ -19,7 +21,7 @@ stdenv.mkDerivation rec { # That requires upstream changes for things to work. So we can patch it to # get the old behaviour by now. ./dtneeded.patch - ]; + ] ++ (stdenv.lib.optional deterministic ./deterministic.patch); buildInputs = [ zlib ] @@ -48,7 +50,8 @@ stdenv.mkDerivation rec { + stdenv.lib.optionalString (stdenv.system == "mips64el-linux") " --enable-fix-loongson2f-nop" + stdenv.lib.optionalString (cross != null) " --target=${cross.config}" - + stdenv.lib.optionalString gold " --enable-gold"; + + stdenv.lib.optionalString gold " --enable-gold" + + stdenv.lib.optionalString deterministic " --enable-deterministic-archives"; enableParallelBuilding = true; diff --git a/pkgs/development/tools/misc/binutils/deterministic.patch b/pkgs/development/tools/misc/binutils/deterministic.patch new file mode 100644 index 000000000000..736e0aca6ce1 --- /dev/null +++ b/pkgs/development/tools/misc/binutils/deterministic.patch @@ -0,0 +1,12 @@ +diff -ur orig/binutils-2.23.1/ld/ldlang.c binutils-2.23.1/ld/ldlang.c +--- orig/ld/ldlang.c ++++ new/ld/ldlang.c +@@ -3095,6 +3095,8 @@ + ldfile_output_machine)) + einfo (_("%P%F:%s: can not set architecture: %E\n"), name); + ++ link_info.output_bfd->flags |= BFD_DETERMINISTIC_OUTPUT; ++ + link_info.hash = bfd_link_hash_table_create (link_info.output_bfd); + if (link_info.hash == NULL) + einfo (_("%P%F: can not create hash table: %E\n")); diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index c8acc2c39c79..ba9a6c4b7de6 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -3206,6 +3206,8 @@ let inherit noSysDirs; }; + binutils_deterministic = binutils.override { deterministic = true; }; + binutils_gold = lowPrio (callPackage ../development/tools/misc/binutils { inherit noSysDirs; gold = true;