Wednesday, 9 February 2011

Profiling SpiderMonkey in gecko-1.9.2

I've had a few problems trying to build a profiling version of SpiderMonkey from gecko-1.9.2 on OS X.

First, in order to build SpiderMonkey at all on OS X 10.6, it's necessary to pick GCC 4.0 because the standard GCC 4.2.1 can't build it.

$ CC=gcc-4.0 CXX=g++-4.0 ../configure --enable-optimize --disable-debug

Then, in order to turn on the profiling support, the -pg flag must be passed to the compiler and linker:

$ CC=gcc-4.0 CXX=g++-4.0 ../configure --enable-optimize="-O3 -fstrict-aliasing -pg" --disable-debug

Finally, to stop the resulting JS shell from instantly crashing, __attribute((fastcall)) needs to be turned off in jstypes.h, jsdhash.h and nanojit/avmplus.h.