- Mercurial 1.0 is needed to access source repositories. Make sure that the mq extension is enabled
- SpiderMonkey provides scripting capabilities for Dehydra. For use with GCC 4.5, mozilla-central hg revision 3aff97777291 is known to work. You probably want to use that. (Current tip as of 2010/09/14 does not.)
- GCC 4.5. (GCC 4.3 will not work with dehydra/mozilla-central tip, but did work until we migrated to 4.5.)
- A modern Linux distribution. Dehydra is not supported on Mac OS X.
Building GCC 4.5 on Linux
# Prepare a directory to build GCC and Dehydra in mkdir $HOME/gcc-dehydra cd $HOME/gcc-dehydra #Obtain GCC 4.3 sources wget ftp://ftp.nluug.nl/mirror/languages/gcc/releases/gcc-4.5.1/gcc-4.5.1.tar.bz2 tar jxvf gcc-4.5.1.tar.bz2 # Compile GCC and install it into $HOME/gcc-dehydra/gcc/ mkdir gcc-build cd gcc-build ../gcc-4.5.1/configure --prefix=$PWD/../installed make make install cd ..
[Deprecated] Building GCC 4.3 with plugin support on Linux
You probably want to use GCC 4.5, where plugins are natively supported -- so skip this section.
By default GCC 4.3 does not support plugins. Dehydra requires patching GCC 4.3 such that it can load plugins as shared libraries:
# Prepare a directory to build GCC and Dehydra in mkdir $HOME/gcc-dehydra cd $HOME/gcc-dehydra #Obtain GCC 4.3 sources wget ftp://ftp.nluug.nl/mirror/languages/gcc/releases/gcc-4.3.4/gcc-4.3.4.tar.bz2 tar jxvf gcc-4.3.4.tar.bz2 # Get the patches which enable plugins cd gcc-4.3.4/ # Create an hg repository. This makes it easy to apply patches, they can be applied manually hg init . hg clone http://hg.mozilla.org/users/tglek_mozilla.com/gcc-moz-plugin-mq .hg/patches # Apply gty.diff and plugin.diff # If you have mq setup, do hg qpush -a (for file in `cat .hg/patches/series`; do cat .hg/patches/$file; done) |patch -p1 cd .. # Compile GCC and install it into $HOME/gcc-dehydra/gcc/ mkdir gcc-build cd gcc-build ../gcc-4.3.4/configure --without-libstdcxx --prefix=$PWD/../installed # For plugin dev use: ../gcc-4.3.4/configure --without-libstdcxx --enable-checking --disable-bootstrap CFLAGS="-g3 -O0" --enable-languages=c,c++ --enable-__cxa_atexit --prefix=$PWD/../installed make make install cd ..
It is recommended that you use a known good Spidermonkey revision, against which Dehydra has been tested. Use other revisions at your own risk!
cd $HOME hg clone http://hg.mozilla.org/mozilla-central/ cd mozilla-central hg up 3aff97777291 mkdir $HOME/obj-js cd $HOME/obj-js $HOME/mozilla-central/js/src/configure --enable-optimize --disable-debug make
Building Dehydra and Treehydra
Building Dehydra requires SpiderMonkey development headers from the previous step. Note that CXX has to point to a plugin-capable C++ compiler.
It is recommended to get the latest Dehydra sources by checking out from Mercurial (Obsolete Dehydra releases can be found on the Mozilla ftp site).
cd $HOME/gcc-dehydra hg clone http://hg.mozilla.org/rewriting-and-analysis/dehydra/ cd dehydra export CXX=$HOME/gcc-dehydra/installed/bin/g++ ./configure \ --js-headers=$HOME/mozilla-central/js/src \ --js-libs=$HOME/obj-js \ --gcc-build=$HOME/gcc-dehydra/gcc-build make # run dehydra and treehydra tests make check
Dehydra checking can be performed directly within the Mozilla build. To enable static checking of a Mozilla build, see Building with static checking.
To run Dehydra manually using G++, add the
-fplugin-arg flags to specify the location of the Dehydra plugin and the location of the analysis script (in GCC 4.5 substitute -fplugin-arg-gcc_dehydra-script for -fplugin-arg):
$HOME/gcc-dehydra/installed/bin/g++ -quiet -fplugin=$HOME/gcc-dehydra/dehydra-gcc/gcc_dehydra.so -fplugin-arg=$DEHYDRA_SCRIPT \ -fshort-wchar $CPPFILE -S -o /dev/null
For example, in the tests directory created by the installation procedure, I can run a Dehydra script 'a.js' on a Mozilla file like this:
../../gcc-build/gcc/cc1plus -quiet -fplugin=../gcc_dehydra.so \ -fplugin-arg=a.js -fshort-wchar -fpreprocessed \ /home/dmandelin/builds/dehydra-gcc/browser/app/nsBrowserApp.ii -o /dev/null
-fshort-wchar is required for running against Firefox, but not necessarily for other codebases.
To generate preprocessed Mozilla source files (*.ii), see the Pork Install Instructions.