summary refs log tree commit diff
path: root/pkgs/development/tools/analysis/valgrind/default.nix
diff options
context:
space:
mode:
authorPeriklis Tsirakidis <periklis.tsirakidis@mayflower.de>2017-03-02 15:19:45 +0100
committerPeriklis Tsirakidis <periklis.tsirakidis@mayflower.de>2017-03-11 20:29:52 +0100
commit7c980f5e9c2c9c6bc58a5bdbe4009458a38d9e84 (patch)
treecbc842cd3147860be95d11cd4085da96b03c51ca /pkgs/development/tools/analysis/valgrind/default.nix
parent89e461822233683767eb809a9f8153b3c942e7cc (diff)
downloadnixpkgs-7c980f5e9c2c9c6bc58a5bdbe4009458a38d9e84.tar
nixpkgs-7c980f5e9c2c9c6bc58a5bdbe4009458a38d9e84.tar.gz
nixpkgs-7c980f5e9c2c9c6bc58a5bdbe4009458a38d9e84.tar.bz2
nixpkgs-7c980f5e9c2c9c6bc58a5bdbe4009458a38d9e84.tar.lz
nixpkgs-7c980f5e9c2c9c6bc58a5bdbe4009458a38d9e84.tar.xz
nixpkgs-7c980f5e9c2c9c6bc58a5bdbe4009458a38d9e84.tar.zst
nixpkgs-7c980f5e9c2c9c6bc58a5bdbe4009458a38d9e84.zip
valgrind: enable darwin build
Diffstat (limited to 'pkgs/development/tools/analysis/valgrind/default.nix')
-rw-r--r--pkgs/development/tools/analysis/valgrind/default.nix27
1 files changed, 23 insertions, 4 deletions
diff --git a/pkgs/development/tools/analysis/valgrind/default.nix b/pkgs/development/tools/analysis/valgrind/default.nix
index 2ecb5eaa132..80e3fdfc807 100644
--- a/pkgs/development/tools/analysis/valgrind/default.nix
+++ b/pkgs/development/tools/analysis/valgrind/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, fetchpatch, perl, gdb }:
+{ stdenv, fetchurl, fetchpatch, perl, gdb, llvm, cctools, xnu, bootstrap_cmds }:
 
 stdenv.mkDerivation rec {
   name = "valgrind-3.12.0";
@@ -14,11 +14,13 @@ stdenv.mkDerivation rec {
 
   # Perl is needed for `cg_annotate'.
   # GDB is needed to provide a sane default for `--db-command'.
-  buildInputs = [ perl ] ++ stdenv.lib.optional (!stdenv.isDarwin) gdb;
+  buildInputs = [ perl gdb ]  ++ stdenv.lib.optionals (stdenv.isDarwin) [ bootstrap_cmds xnu ];
 
   enableParallelBuilding = true;
 
-  postPatch =
+  patches = stdenv.lib.optionals (stdenv.isDarwin) [ ./valgrind-bzero.patch ];
+
+  postPatch = stdenv.lib.optionalString (stdenv.isDarwin)
     # Apple's GCC doesn't recognize `-arch' (as of version 4.2.1, build 5666).
     ''
       echo "getting rid of the \`-arch' GCC option..."
@@ -27,6 +29,23 @@ stdenv.mkDerivation rec {
 
       sed -i coregrind/link_tool_exe_darwin.in \
           -e 's/^my \$archstr = .*/my $archstr = "x86_64";/g'
+
+      echo "substitute hardcoded /usr/include/mach with ${xnu}/include/mach"
+      substituteInPlace coregrind/Makefile.in \
+         --replace /usr/include/mach ${xnu}/include/mach
+
+      echo "substitute hardcoded dsymutil with ${llvm}/bin/llvm-dsymutil"
+      find -name "Makefile.in" | while read file; do
+         substituteInPlace "$file" \
+           --replace dsymutil ${llvm}/bin/llvm-dsymutil
+      done
+
+      substituteInPlace coregrind/m_debuginfo/readmacho.c \
+         --replace /usr/bin/dsymutil ${llvm}/bin/llvm-dsymutil
+
+      echo "substitute hardcoded /usr/bin/ld with ${cctools}/bin/ld"
+      substituteInPlace coregrind/link_tool_exe_darwin.in \
+        --replace /usr/bin/ld ${cctools}/bin/ld
     '';
 
   configureFlags =
@@ -58,6 +77,6 @@ stdenv.mkDerivation rec {
     license = stdenv.lib.licenses.gpl2Plus;
 
     maintainers = [ stdenv.lib.maintainers.eelco ];
-    platforms = stdenv.lib.platforms.linux;
+    platforms = stdenv.lib.platforms.unix;
   };
 }