Mozilla Static-analysis build with Dehydra
To start off the exploration of external strings for the project I am working on, outlined here, I will be doing a static analysis build of Mozilla. Smedberg has given me some instructions to get to the point of some doc generation:
- Do a static-analysis build of Mozilla
- Generate the docs with “make -C <objdir>/xpcom/analysis classapi”
- For the external API compile type-printer-external.cpp without MOZILLA_INTERNAL_API defined
Note: I am performing this work on a machine in CDOT, which is a 64-bit Linux machine (Fedora 10)
Note 2: I am doing all of this without root access.
Note 3: I already had Mozilla source and compiled (FireFox/MineField)
Step 1:
The static-analysis is done with Dehydra.
Build GCC with plugin support
To use it first off I have to build GCC with plugin support. The method to do so is detailed here.
My first run concluded early with this result:
/usr/include/gnu/stubs.h:7:27: error: gnu/stubs-32.h: No such file or directory
make[5]: *** [_muldi3.o] Error 1
make[5]: Leaving directory `/home/rdicke/gcc-dehydra/gcc-build/x86_64-unknown-linux-gnu/32/libgcc’
make[4]: *** [multi-do] Error 1
make[4]: Leaving directory `/home/rdicke/gcc-dehydra/gcc-build/x86_64-unknown-linux-gnu/libgcc’
make[3]: *** [all-multi] Error 2
make[3]: Leaving directory `/home/rdicke/gcc-dehydra/gcc-build/x86_64-unknown-linux-gnu/libgcc’
make[2]: *** [all-stage1-target-libgcc] Error 2
make[2]: Leaving directory `/home/rdicke/gcc-dehydra/gcc-build’
make[1]: *** [stage1-bubble] Error 2
make[1]: Leaving directory `/home/rdicke/gcc-dehydra/gcc-build’
make: *** [all] Error 2
make[1]: Entering directory `/home/rdicke/gcc-dehydra/gcc-build’
/bin/sh ../gcc-4.3.4/mkinstalldirs /home/rdicke/gcc-dehydra/gcc-build/../installed /home/rdicke/gcc-dehydra/gcc-build/../installed
mkdir -p — /home/rdicke/gcc-dehydra/gcc-build/../installed /home/rdicke/gcc-dehydra/gcc-build/../installed
/bin/sh: line 3: cd: ./fixincludes: No such file or directory
make[1]: *** [install-fixincludes] Error 1
make[1]: Leaving directory `/home/rdicke/gcc-dehydra/gcc-build’
make: *** [install] Error 2
After a bit of searching it appears that this is a “building on a 64-bit machine” issue. The solution seems to be to tell it to not built for 32-bit library with the parameter below.
./configure --disable-multilib
What (I believe) this does it keep the build from doing 32-bit stuff, keeping it from looking for files that aren’t there while also keeping one from being able to build 32-bit executable. I probably could have installed the 32-bit libraries but this was quicker and as far as I can tell (famous last words) shouldn’t effect me.
SpiderMonkey
Now I have to build a “standalone SpiderMonkey library” as detailed here.
After this the SpiderMonkey build ends with this: BugĀ 520623 – Building dehdyra against SpiderMonkey trunk fails
I applied the first, gcc mq, patch by actually running the first included patch which adds in a patch that is run in the commands included in the GCC patch part of the Dehydra build documentation. I went to the point where other patches are downloaded, then from the gcc-dehydra/gcc-4.3.4 directory:
cd ./.hg/patches
patch -p1 < $HOME/dehydra/nopoison.diff
Where nopoison.diff is the first patch listed in the bug. Then continued the steps and the patch is applied along with the rest.
Note: When I tried to apply the second patch to Dehydra it was already applied.
Build Dehydra
At first I tried using my stand alone SpiderMonkey with the configure for Dehydra.
./configure \
–js-libs=$HOME/sm/js/src/Linux_All_OPT.OBJ/ \
–js-headers=$HOME/sm/js/src/
Than I tried the ones built with FireFox/MineField, which was mentioned as inadequate.
./configure \
--js-libs=$MOZILLA_CENTRAL_OBJ/js/src/ \
--js-headers=$MOZILLA_CENTRAL/js/src/
Where I set $MOZILLA_CENTRAL to
(where your Mozilla source directory is)/src/
and $MOZILLA_CENTRAL_OBJ to
(where your Mozilla source directory is)/src/objdir-ff-release/
And this seemed to work??
Build static-analysis Mozilla
I added the lines below to my .mozconfig
CXX=$HOME/gcc-dehydra/installed/bin/g++
ac_add_options --with-static-checking=$HOME/gcc-dehydra/dehydra/gcc_treehydra.so
And it is broken…
But I am pretty sure it is because I didn’t use my stand alone SpiderMonkey.
Here is a taste of the output errors I got:
cc1plus: error: unrecognized command line option "-fplugin=/home/rdicke/gcc-dehydra/dehydra/gcc_treehydra.so"
cc1plus: error: unrecognized command line option "-fplugin-arg=/home/rdicke/mozilla/src/js/src/config/static-checking.js --topsrcdir=/home/rdicke/mozilla/src/js/src --objdir=. --dehydra-modules= --treehydra-modules=/home/rdicke/mozilla/src/js/src/jsstack.js "
I will be on IRC looking for a bit of clarification on this process soon I am sure.