mozilla
Your Search Results

    Cross-Compiling Mozilla

    For information on cross-compiling in general, see the chapter titled Cross Compilation Tools in The GNU configure and build system document.

    If you are trying to compile 32-bit Firefox on a 64-bit Linux OS, you don't need to do a full cross-compile... see these simpler instructions.

    Setting up a cross-compilation build environment

    This isn't the end-all-be-all guide to setting up a cross-compilation build environment. WFM; YMMV. (If you have to ask "where do I get... or why doesn't 'X' work", then this isn't for you.)

    For all of these examples, the following definitions are used:

    xtarget_arch name of the target system (e.g., i686-linux)
    xprefix location of cross-compilation directory heiarchy (e.g. /usr/sparc-linux)

    You should add ${xprefix}/bin to your PATH.

    Cross-compile binutils (if needed)

    Download binutils and apply the binutils-cross-libpath.patch, which will make installing prebuilt libraries easier. Run configure using the following command:

    env CROSS_LIB_PATH="${xprefix}/${xtarget_arch}/lib:${xprefix}/${xtarget_arch}/usr/lib" ./configure --prefix=${xprefix} --target=${xtarget_arch}
    

    Build and install the package on the system.

    Install target system headers and libraries

    GCC and binutils will expect to find the system headers and libraries under ${xprefix}/${xtarget_arch} so you will need to copy those files from the target system, preserving directory structure and modify any scripts as necessary. You should copy over the X11 lib and include dirs as well.

    Note: If your target system uses glibc, you must take special care to modify the local copy of the target's /usr/lib/libc.so file (which is actually a script) so that it looks for its files under $xprefix/$target_arch rather than /usr.

    If you already have rpms for the target system and rpm installed on the build system, then you can use this shortcut script which should install the rpms into $xprefix/$xtarget_arch using rpm2cpio.

    Also, if you use Debian or Ubuntu, you can use dpkg-cross, apt-cross or Mutiarch to install the headers and libraries for target system.

    To setup multi architecture support on Debian, see https://wiki.debian.org/Multiarch/HOWTO for more details.

    Cross-compile gcc (if needed)

    Some distributions already have cross compling support such as g++-arm-linux-gnuabihf on Debian/sid.

    But if you need build gcc from source code, download gcc and run configure with the following command:

    ./configure --prefix=${xprefix} --with-gnu-ld --with-gnu-as --target=${xtarget_arch} --disable-nls --enable-languages=c++,objc
    

    Build and install the package on the system.

    Verification

    At this point, your cross-compilation environment should be completely set up. You should verify that it works. Start with Hello World and work your way up to a basic X11-based application.

    For most packages, ./configure --target=${xtarget_arch} should be sufficient to build.

    For others, you may have to explicitly set the build tools:

    env AR=${xtarget_arch}-ar CC=${xtarget_arch}-gcc CXX=${xtarget_arch}-g++ LD=${xtarget_arch}-ld AS=${xtarget_arch}-as ./configure --prefix=${xprefix} --target=${xtarget_arch}
    

    Cross-compile glib, gtk+ and etc

    This step is only necessary if you did not install pre-built versions of these packages. Use the steps outlined above to build and install them.

    Cross-compiling the lizard

    Assuming that you properly setup your cross-compilation build environment as outlined above, cross-compiling Mozilla is fairly straightforward although NSS isn't properly setup to cross-compile (bug 104541).

    The main thing to remember is that when --target=${xtarget_arch} is passed to configure, configure expects to find the compiler toolchain as ${xtarget_arch}-TOOL where TOOL is gcc, g++, ranlib, etc.

    You must pass the following environment arguments to configure:

    CROSS_COMPILE=1
    export PKG_CONFIG_PATH=/path/to/target/system/lib/pkgconfig
    

    and the follwing command line arguments to configure:

    --target=${xtarget_arch}
    

    Here's a sample mozconfig file used to cross-compile to the arm-linux-gnueabi target:

    # sh
    # Build configuration script
    #
    # See http://www.mozilla.org/build/unix.html for build instructions.
    #
    CROSS_COMPILE=1
    export PKG_CONFIG_PATH=/usr/lib/arm-linux-gnueabi/pkgconfig
    
    ac_add_options --prefix=/usr/lib/arm-linux-gnueabi
    ac_add_options --target=arm-linux-gnueabi
    
    # Options for 'configure' (same as command-line options). 
    # all are listed so that one can manually tweak this config file.
    ac_add_options --enable-application=browser
    

    Original Document Information

    • Author(s): Chris Seawood
    • Last Updated Date: June 22, 2002
    • Copyright Information: Portions of this content are © 1998–2007 by individual mozilla.org contributors; content available under a Creative Commons license | Details.

    Document Tags and Contributors

    Contributors to this page: BenjaminSmedberg, mkato, kohei.yoshino, GavinSharp, Mgjbot
    Last updated by: mkato,