Wednesday, July 14, 2010

GPSEE, Valgrind and MacPorts

Running Valgrind in recent versions of TraceMonkey -- in particular versions since the addition of the conservative stack-scanning garbage collector -- requires special code to quiesce spurious noise from Valgrind.

This special code includes valgrind/valgrind.h, which in turn requires that the MacPorts include directory, /opt/local/include, be included in the path searched by the C precompiler.

Unfortunately, simply tweaking the global CFLAGS or CPPFLAGS on a project-wide basis doesn't work well with GPSEE, as we use the system iconv library. Including the header for GNU iconv, via MacPorts, will cause GPSEE to crash whenever we load a module which uses iconv, such as Binary/B or GFFI.

So, we need to include the MacPorts include directory when building TraceMonkey, but not GPSEE. We also need to pass the --enable-valgrind option to TraceMonkey's autoconf script. Here's how you do it:

# cd gpsee
# ./configure --prefix=/opt/local/gpsee --with-jsapi-build=DEBUG --with-jsapi-options=--enable-valgrind --with-jsapi-cppflags=-I/opt/local/include --with-build=DEBUG

# make build
# sudo make install


Presumably something very similar will also need to be done for users running Leopard+Homebrew or Solaris. Linux users are in the clear because they should not have iconv library/header conflicts.