valgrind: enable darwin build

This commit is contained in:
Periklis Tsirakidis
2017-03-11 20:29:52 +01:00
parent 89e4618222
commit 7c980f5e9c
3 changed files with 64 additions and 5 deletions
@@ -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;
};
}