Merge pull request #23393 from periklis/topic_valgrind_darwin

valgrind: enable darwin build
This commit is contained in:
Daiderd Jordan 2017-03-11 21:17:40 +01:00 committed by GitHub
commit 3ea16e98b4
3 changed files with 64 additions and 5 deletions

View file

@ -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;
};
}

View file

@ -0,0 +1,37 @@
Index: coregrind/m_main.c
===================================================================
--- a/coregrind/m_main.c (revision 16102)
+++ b/coregrind/m_main.c (revision 16103)
@@ -3489,6 +3489,10 @@
// skip check
return VG_(memset)(s,c,n);
}
+void __bzero(void* s, UWord n);
+void __bzero(void* s, UWord n) {
+ (void)VG_(memset)(s,0,n);
+}
void bzero(void *s, SizeT n);
void bzero(void *s, SizeT n) {
VG_(memset)(s,0,n);
@@ -4058,20 +4062,7 @@
#endif
-#if defined(VGO_darwin) && DARWIN_VERS == DARWIN_10_10
-/* This might also be needed for > DARWIN_10_10, but I have no way
- to test for that. Hence '==' rather than '>=' in the version
- test above. */
-void __bzero ( void* s, UWord n );
-void __bzero ( void* s, UWord n )
-{
- (void) VG_(memset)( s, 0, n );
-}
-
-#endif
-
-
/*--------------------------------------------------------------------*/
/*--- end ---*/
/*--------------------------------------------------------------------*/

View file

@ -6862,7 +6862,10 @@ with pkgs;
gdb-multitarget = lowPrio (gdb.override { multitarget = true; });
valgrind = callPackage ../development/tools/analysis/valgrind { };
valgrind = callPackage ../development/tools/analysis/valgrind {
inherit (darwin) xnu bootstrap_cmds cctools;
llvm = llvm_39;
};
valkyrie = callPackage ../development/tools/analysis/valkyrie { };