Monday, January 26, 2009

Compiling Valgrind for Mac OS X

I was trying to compile Valgrind (version 3.3.1 r8180, VEX r1854) for Mac OS X as per Greg Parker's instructions.

The make step failed with something like:
gcc -arch i386 -O2 -gstabs -Wmissing-prototypes -Wall -Wshadow -Wpointer-arith -Wstrict-prototypes -Wmissing-declarations -fno-strict-aliasing -O2 -mmacosx-version-min=10.5 -gstabs -fno-stack-protector -O2 -Wno-long-long -Wno-pointer-sign -Wdeclaration-after-statement -nodefaultlibs -nostartfiles -Wl,-u,__start -Wl,-e,__start -Wl,-bind_at_load /usr/lib/dyld -arch i386 -mdynamic-no-pic -Wl,-seg1addr,0xf0080000 -Wl,-stack_addr,0xf0080000 -Wl,-stack_size,0x80000 -Wl,-pagezero_size,0xf0000000 -o memcheck-x86-darwin memcheck_x86_darwin-mc_leakcheck.o memcheck_x86_darwin-mc_malloc_wrappers.o memcheck_x86_darwin-mc_main.o memcheck_x86_darwin-mc_translate.o memcheck_x86_darwin-mc_machine.o memcheck_x86_darwin-mc_errors.o ../coregrind/libcoregrind_x86_darwin.a ../VEX/libvex_x86_darwin.a -lgcc ld: in ../VEX/libvex_x86_darwin.a, archive has no table of contents collect2: ld returned 1 exit status make[3]: *** [memcheck-x86-darwin] Error 1 make[2]: *** [all-recursive] Error 1 make[1]: *** [all-recursive] Error 1 make: *** [all] Error 2

I was able to fix this with:
$ ranlib VEX/libvex_x86_darwin.a

This needs to be repeated with VEX/libvex_amd64_darwin.a which'll fail the same way. Continuing with make built valgrind successfully for me.