Installing Dehydra

  • Revision slug: Dehydra/Installing_Dehydra
  • Revision title: Installing Dehydra
  • Revision id: 41706
  • Created:
  • Creator: Vlad.sukhoy
  • Is current revision? No
  • Comment 16 words removed

Revision Content

Prerequisites

  • Mercurial 1.0 is needed to access source repositories. Make sure that the mq extension is enabled
  • SpiderMonkey 1.7 or newer provides scripting capabilities for Dehydra (trunk is preferred).
  • GCC 4.3 on Linux, Apple GCC 4.2 Preview 1 on OSX
    • May need libgmp >= 4.2.2 on Linux
  • XCode 3.0 and OSX 10.5 (mac only)

Building GCC with plugin support on Linux

By default GCC does not support plugins. Dehydra requires patching GCC 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/...-4.3.0.tar.bz2
tar jxvf gcc-4.3.0.tar.bz2

# Get the patches which enable plugins
cd gcc-4.3.0/
# 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.0/configure --without-libstdcxx --enable-checking --disable-bootstrap CFLAGS="-g3 -O0" --enable-languages=c,c++ --enable-__cxa_atexit --prefix=$PWD/../installed
(on x86_64, use ../gcc-4.3.0/configure --without-libstdcxx --enable-checking --disable-bootstrap CFLAGS="-g3 -O0 -m64" --enable-languages=c,c++ --disable-multilib --enable-__cxa_atexit --prefix=$PWD/../installed )
make
make install
cd ..

Building GCC with plugin support on OSX

Few notes: the gcc build process on Mac is significantly different from that under Linux: it deviates from FSF's configure => make => make install paradigm. This unusual process is usually called "Apple-style gcc build" and consists of a single "make install" command which performs configuration, build and installation. Apple-style build is a preferred to way of producing gcc binaries suitable for dehydra on Mac. It is still possible to perform FSF-style build but experience with gcc installation that results may be quite painful. It is suggested to perform gcc build that is described below under a low-priviliged user that is not capable of writing to /usr and other system locations, i.e. avoid "sudo" when running the build sequence. The risk is overwriting system compiler, e.g. the one installed by XCode by our experimental gcc which supports plugins or by broken compiler should something go wrong with the build. Texinfo mac port is known to interfere with gcc build and make it fail. It is advised that you deactivate it before building gcc.

# Prepare a directory to build GCC and Dehydra in
mkdir $HOME/gcc-dehydra
cd $HOME/gcc-dehydra
# Obtain Apple GCC 4.2 prerelease sources
wget http://www.opensource.apple.com/darwinsource/tarballs/other/gcc_42-5531.tar.gz
tar zxvf gcc_42-5531.tar.gz
# Obtain and apply only the plugin patch (bug 447560)
cd gcc_42-5531
wget --no-check-certificate https://bugzilla.mozilla.org/attachment.cgi?id=331685 -O plugin.diff
patch -p1 < plugin.diff
# Apply one more patch to fix certain issues with parameter attributes (bug 438062)
wget --no-check-certificate  https://bugzilla.mozilla.org/attachment.cgi?id=320305 -O parm_attrs.diff
patch -p1 < parm_attrs.diff
# Compile and install GCC Apple way
# You may need to "sudo port deactivate texinfo" if applicable as it seems to interfere with the build
make install
# Make Apple-style build friendlier for dehydra
ditto dst/usr ../installed
cd ..
ln -s gcc_42-5531/obj/obj-i686-i686 gcc-build

Before proceeding to build dehydra and treehydra, please apply one more patch on GCC source. This patch is required by treehydra bootstraping process which is a part of dehydra build described further. Currently this patch makes the gcc source uncompilable and this is {{ Bug("428593") }}. To workaround, apply this patch only after the gcc build:

cd gcc_42-5531
wget --no-check-certificate https://bugzilla.mozilla.org/attachment.cgi?id=315074 -O gty.diff
patch -p1 < gty.diff
cd ..

Building Dehydra

Building Dehydra requires a standalone SpiderMonkey library, version 1.7 or higher (the current SpiderMonkey trunk is preferred). The SpiderMonkey built for Firefox or other Mozilla product is not suitable. See SpiderMonkey_Build_Documentation for how to build SpiderMonkey.

We'll assume here that your SpiderMonkey build is in $MOZILLA_CENTRAL/src/js, it's a BUILD_OPT=1 build, and you're on linux.

Dehydra releases can be found on the Mozilla ftp site, however it is recommended to get the latest Dehydra sources by checking out from Mercurial.

cd $HOME/gcc-dehydra
hg clone http://hg.mozilla.org/users/tglek_mozilla.com/dehydra-gcc/
cd dehydra-gcc
./configure \
  --js-libs=$MOZILLA_CENTRAL/js/src/Linux_All_OPT.OBJ \ 
  --js-include=$MOZILLA_CENTRAL/js/src  
make

# run dehydra-gcc tests
make check

Usage

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 and -fplugin-arg flags to specify the location of the Dehydra plugin and the location of the analysis script:

$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

The -fshort-wchar is required for running against Firefox, but not necessarily for other codebases.

   

See Also

Revision Source

<h3 name="Prerequisites">Prerequisites</h3>
<ul> <li><a class="external" href="http://www.selenic.com/mercurial/wiki/">Mercurial</a> 1.0 is needed to access source repositories. Make sure that the <a class="external" href="http://www.selenic.com/mercurial/wiki/index.cgi/MqExtension">mq extension</a> is enabled</li> <li><a href="/en/SpiderMonkey" title="en/SpiderMonkey">SpiderMonkey</a> 1.7 or newer provides scripting capabilities for <a href="/en/Dehydra" title="en/Dehydra">Dehydra</a> (trunk is preferred).</li> <li><a class="external" href="http://gcc.gnu.org/">GCC</a> 4.3 on Linux, Apple GCC 4.2 Preview 1 on OSX <ul> <li>May need <a class="external" href="http://gmplib.org/">libgmp</a> &gt;= 4.2.2 on Linux</li> </ul> </li> <li>XCode 3.0 and OSX 10.5 (mac only)</li>
</ul>
<h4 name="Building_GCC_with_plugin_support_on_Linux">Building GCC with plugin support on Linux</h4>
<p>By default GCC does not support plugins. Dehydra requires patching GCC such that it can load plugins as shared libraries:</p>
<pre class="eval"># Prepare a directory to build GCC and Dehydra in
mkdir $HOME/gcc-dehydra
cd $HOME/gcc-dehydra
#Obtain GCC 4.3 sources
wget <a class=" link-ftp" href="ftp://ftp.nluug.nl/mirror/languages/gcc/releases/gcc-4.3.0/gcc-4.3.0.tar.bz2" rel="freelink">ftp://ftp.nluug.nl/mirror/languages/...-4.3.0.tar.bz2</a>
tar jxvf gcc-4.3.0.tar.bz2

# Get the patches which enable plugins
cd gcc-4.3.0/
# Create an hg repository. This makes it easy to apply patches, they can be applied manually
hg init .
<span>hg clone <a class="external" href="http://hg.mozilla.org/users/tglek_mozilla.com/gcc-moz-plugin-mq">http://hg.mozilla.org/users/tglek_mozilla.com/gcc-moz-plugin-mq</a> .hg/patches</span>
# 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.0/configure --without-libstdcxx --enable-checking --disable-bootstrap CFLAGS="-g3 -O0" --enable-languages=c,c++ --enable-__cxa_atexit --prefix=$PWD/../installed
(on x86_64, use ../gcc-4.3.0/configure --without-libstdcxx --enable-checking --disable-bootstrap CFLAGS="-g3 -O0 -m64" --enable-languages=c,c++ --disable-multilib --enable-__cxa_atexit --prefix=$PWD/../installed )
make
make install
cd ..
</pre>
<h4 name="Building_GCC_with_plugin_support_on_OSX">Building GCC with plugin support on OSX</h4>
<p>Few notes: the gcc build process on Mac is significantly different from that under Linux: it deviates from FSF's configure =&gt; make =&gt; make install paradigm. This unusual process is usually called "Apple-style gcc build" and consists of a single "make install" command which performs configuration, build and installation. <strong>Apple-style build is a preferred to way of producing gcc binaries suitable for dehydra on Mac.</strong> It is still possible to perform FSF-style build but experience with gcc installation that results may be quite painful. <strong>It is suggested to perform gcc build that is described below under a low-priviliged user that is not capable of writing to /usr and other system locations, i.e. avoid "sudo" when running the build sequence.</strong> The risk is overwriting system compiler, e.g. the one installed by XCode by our experimental gcc which supports plugins or by broken compiler should something go wrong with the build. <strong>Texinfo <a class="external" href="http://www.macports.org/">mac port</a> is known to interfere with gcc build and make it fail. It is advised that you deactivate it before building gcc.</strong></p>
<pre class="eval"># Prepare a directory to build GCC and Dehydra in
mkdir $HOME/gcc-dehydra
cd $HOME/gcc-dehydra
# Obtain Apple GCC 4.2 prerelease sources
<span>wget <a class="external" href="http://www.opensource.apple.com/darwinsource/tarballs/other/gcc_42-5531.tar.gz">http://www.opensource.apple.com/darwinsource/tarballs/other/gcc_42-5531.tar.gz</a></span>
tar zxvf gcc_42-5531.tar.gz
</pre>
<pre class="eval"># Obtain and apply only the plugin patch (bug 447560)
cd gcc_42-5531
wget --no-check-certificate <a class=" link-https" href="https://bugzilla.mozilla.org/attachment.cgi?id=331685" rel="freelink">https://bugzilla.mozilla.org/attachment.cgi?id=331685</a> -O plugin.diff
patch -p1 &lt; plugin.diff
</pre>
<pre class="eval"># Apply one more patch to fix certain issues with parameter attributes (bug 438062)
wget --no-check-certificate  <a class=" link-https" href="https://bugzilla.mozilla.org/attachment.cgi?id=320305" rel="freelink">https://bugzilla.mozilla.org/attachment.cgi?id=320305</a> -O parm_attrs.diff
patch -p1 &lt; parm_attrs.diff
</pre>
<pre class="eval"># Compile and install GCC Apple way
# You may need to "sudo port deactivate texinfo" if applicable as it seems to interfere with the build
make install
# Make Apple-style build friendlier for dehydra
ditto dst/usr ../installed
cd ..
ln -s gcc_42-5531/obj/obj-i686-i686 gcc-build
</pre>
<p><strong>Before proceeding to build dehydra and treehydra, please apply one more patch on GCC source.</strong> This patch is required by treehydra bootstraping process which is a part of dehydra build described further. Currently this patch makes the gcc source uncompilable and this is {{ Bug("428593") }}. To workaround, apply this patch only after the gcc build:</p>
<pre class="eval">cd gcc_42-5531
wget --no-check-certificate <a class=" link-https" href="https://bugzilla.mozilla.org/attachment.cgi?id=315074" rel="freelink">https://bugzilla.mozilla.org/attachment.cgi?id=315074</a> -O gty.diff
patch -p1 &lt; gty.diff
cd ..
</pre>
<h4 name="Building_Dehydra">Building Dehydra</h4>
<p>Building Dehydra requires a standalone SpiderMonkey library, version 1.7 or higher (the current SpiderMonkey trunk is preferred). The SpiderMonkey built for Firefox or other Mozilla product is not suitable. See <a href="/en/SpiderMonkey_Build_Documentation" title="en/SpiderMonkey_Build_Documentation">SpiderMonkey_Build_Documentation</a> for how to build SpiderMonkey.</p>
<p>We'll assume here that your SpiderMonkey build is in $MOZILLA_CENTRAL/src/js, it's a BUILD_OPT=1 build, and you're on linux.</p>
<p>Dehydra releases can be found on the <a class="external" href="http://ftp.mozilla.org/pub/mozilla.org/static-analysis/dehydra/">Mozilla ftp site</a>, however it is recommended to get the latest Dehydra sources by checking out from Mercurial.</p>
<pre class="eval">cd $HOME/gcc-dehydra
<span>hg clone <a class="external" href="http://hg.mozilla.org/users/tglek_mozilla.com/dehydra-gcc/">http://hg.mozilla.org/users/tglek_mozilla.com/dehydra-gcc/</a></span>
cd dehydra-gcc
./configure \
  --js-libs=$MOZILLA_CENTRAL/js/src/Linux_All_OPT.OBJ \ 
  --js-include=$MOZILLA_CENTRAL/js/src  
make

# run dehydra-gcc tests
make check
</pre>
<h3 name="Usage">Usage</h3>
<p>Dehydra checking can be performed directly within the Mozilla build. To enable static checking of a Mozilla build, see <a href="/en/Building_with_static_checking" title="en/Building_with_static_checking">Building with static checking</a>.</p>
<p>To run Dehydra manually using G++, add the <code>-fplugin</code> and <code>-fplugin-arg</code> flags to specify the location of the Dehydra plugin and the location of the analysis script:</p>
<pre class="eval">$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
</pre>
<p>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:</p>
<pre class="eval">../../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
</pre>
<p>The <code>-fshort-wchar</code> is required for running against Firefox, but not necessarily for other codebases.</p>
<p>   </p>
<h3 name="See_Also">See Also</h3>
<ul> <li><a href="/en/Dehydra_Manual" title="en/Dehydra_Manual">Dehydra_Manual</a></li> <li><a href="/en/Treehydra_Build_Instructions" title="en/Treehydra_Build_Instructions">Treehydra Build Instructions</a></li>
</ul>
Revert to this revision