Building SpiderMonkey Javascript 1.6 on MacOS X
I wanted to run a Javascript version of a Mandelbrot program that was submitted to me for my Fractal Benchmark page. Unfortunately, I ran into trouble compiling SpiderMonkey, Mozilla's Javascript interpreter. Here's how I finally got it working on MacOS X.
This Didn't Just Work™
The included instructions to compile it are very simple. Just download, extract and make. But unfortunately the version provided doesn't work with MacOS X.
curl -O http://ftp.mozilla.org/pub/mozilla.org/js/js-1.60.tar.gz
tar -zxvf js-1.60.tar.gz
cd js/src
make -f Makefile.ref
I got the following error. Crap!
libtool: unrecognized option `-framework'
Try `libtool --help' for more information.
make[1]: *** [Darwin_DBG.OBJ/libjs.so] Error 1
make: *** [all] Error 2
At this point, I tried plan B, which is utilize Darwin Ports. Evidently the newest version shown is js-1.5 instead of 1.6. Unfortunately, it couldn't find a version to download anywhere. See spidermonkey on darwinports if you want to go down this route.
sudo port install spidermonkey
...
Error: Target com.apple.fetch returned: fetch failed
Error: /opt/local/bin/port: Status 1 encountered during processing.
Determined Googling Yields a Patch
After some determined Googling, I found the following patch was checked in later to fix it. Unfortunately I can't find the link now. Here's the patch.
diff -r js/src/config/Darwin.mk js.working/src/config/Darwin.mk
52c52,53
< MKSHLIB = libtool $(XMKSHLIBOPTS) -framework System
---
> MKSHLIB = $(CC) -dynamiclib $(XMKSHLIBOPTS) -framework System
> SO_SUFFIX = dylib
diff -r js/src/jsatom.c js.working/src/jsatom.c
924,925c924,925
< jsrefcount js_atom_map_count;
< jsrefcount js_atom_map_hash_table_count;
---
> static jsrefcount js_atom_map_count;
> static jsrefcount js_atom_map_hash_table_count;
Patched Javascript SpiderMonkey 1.6
For your convenience, I've provided a patched version you can download and build. Just copy-and-paste the following into your terminal. (Tested on MacOS X 10.4.9 on 2007-05-26.)
curl -O http://www.timestretch.com/software/js-1.60-MacOSX-Patch.tar.gz
tar -zxvf js-1.60-MacOSX-Patch.tar.gz
cd js-1.60-MacOSX-Patch/src
make -f Makefile.ref
sudo mv Darwin_DBG.OBJ/js /usr/local/bin/
Comments
|
Determined Googling Yields a Patch
|
11/05/07
|
Dan When I try those commands in the Terminal, I get this error:
cat: ../../dist/Darwin_DBG.OBJ/nspr/Version: No such file or directory
Is there a version of NSPR as well? Thanks.
|
|
|
Building SpiderMonkey Javascript 1.6 on MacOS X
|
06/16/08
|
Alan As of June 2008, SpiderMonkey 1.7 builds just fine under MacPorts
|
|
Leave a Comment
Show Comment Form
|