This document will describe how to run Mozilla static check for Windows code under Linux platform by creating a cross-compiler with Dehydra support for Mingw.
We highly recommend you to read the cross compiling manual and the Dehydra build manual before you start the following reading.
Build GCC Corss-compiler with Plugin Support
By default GCC does not support plugins. Dehydra requires patching GCC such that it can load plugins as shared libraries:
# Prepare a directory mkdir $HOME/dehydra cd $HOME/dehydra #Obtain GCC 4.3 sources wget ftp://mirrors.kernel.org/gnu/gcc/gcc...-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_mo...-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 ..
Now, the Gcc source with plugin supports is ready, we should now build a cross compiler from this source. And the instructions are exactly the same with the one here. Follow that instructions strictly for making a cross compiler.
Build Dehydra for Cross-compiler
Build the Dehydra plugin
Dehydra is a shared library which will be loaded by the above plugin-support gcc. Build Dehydra for a cross compiler has nothing difference with building one for a Linux native compiler. So, please follow this link exactly.
Check the build
make check
If all tests past, you have gotten a workable Dehydra.
Build Treehydra
Build the Treehydra plugin
Building Treehydra for a cross compiler is something tricky. That is because the GCC with plugin support is needed to produce Treehydra shared library. But we just made a Mingw cross compiler, that means it can't produce the correct shared library.
So, we should make a Linux native compiler with plugin support to make Treehydra! This sound crazy, but it may be the only right way to do this.
Just follow this and this to compile both Dehydra and Treehydra shared libraries. And these libraries can be used directly with our cross compiler.
Check the build
Run:
make check_treehydra
Run Static Analysis on Mozilla Windows Code
Static analysis is hooked into Mozilla repository from Mozilla 2. You can obtain Mozilla 2 code by:
hg clone http://hg.mozilla.org/mozilla-central/
And compose a .mozconfig file for cross-compiling Mozilla with static analysis hooked:
#Specify the cross compile CROSS_COMPILE=1 ac_add_options --enable-application=browser ac_add_options --host=i686-linux ac_add_options --target=i686-mingw32 ac_add_options --enable-default-toolkit=cairo-windows mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/../mozilla-mingw # Mozilla trunk uses many Vista only features on Windows, so we should disable some components to make it buildable with mingw32. ac_add_options --enable-debug ac_add_options --disable-optimize ac_add_options --disable-tests ac_add_options --disable-embedding-tests ac_add_options --disable-installer ac_add_options --disable-accessibility ac_add_options --disable-vista-sdk-requirements ac_add_options --disable-updater #change this to where your libIDL-config file locate. HOST_LIBIDL_CONFIG=/usr/bin/libIDL-config #Config your moztools position GLIB_PREFIX=$HOME/moztools LIBIDL_PREFIX=$HOME/moztools #disable xpcom stdcall calling convention because of gcc 4.3.0 bug CPPFLAGS="-DMOZ_DISABLE_XPCOM_STDCALL" #Specify the CXX and static analysis #Point CXX to the cross compile g++ with plugin support CXX=$HOME/mingw-install/bin/i686-mingw32-g++ ac_add_options --with-static-checking=$HOME/dehydra/dehydra-gcc/gcc_dehydra.so
Then, you can start building your Mozilla. The static check will be done when compiling is going on.
Troubles
You can post any question about static check to the mozilla.dev.static-analysis newsgroup and any question about cross compiling to the mozilla.dev.builds newsgroup.