5 HowToBuildFPR
Cameron Kaiser edited this page 2021-10-29 19:35:33 -07:00

This document covers how to build TenFourFox from the TenFourFox Github repository. It does not cover any other version.

Warning

These build instructions are always subject to change. You should be familiar with how Mozilla offers its source code and how to build Mozilla applications before you attempt these steps.

Prerequisites

  • At minimum you will need a G4 or G5 (G5 recommended), 10.4.11, Xcode 2.5, 1.5GB of RAM and 10GB disk space. The build should work on a G3, but has not been tested on it. Just for your interest, TenFourFox is built on a quad G5 with 16GB of RAM, because compilers like RAM. In this configuration, with Energy Saver set to Highest Performance, it takes approximately three hours to kick out a single architecture build, and about a half hour longer for a debugging build. Plan accordingly.

    • The currently supported compiler is gcc 4.8.x (4.8.2 or higher), from MacPorts (see below); building with 4.6 as used in TenFourFox 38 is no longer possible. However, although Apple gcc 4.0.1 and gcc 4.2 are no longer supported, you must still install Xcode for certain other prerequisites.
      • Later versions of gcc have been used in limited situations, and may work, but are not yet supported.
    • Building on 10.5.8 and/or with Xcode 3 should work, but linking against the 10.5 SDK is not supported. Note that the browser can still be built on 10.5.8, and will still run on 10.5.8, but the only allowed target will be a 10.4-compatible browser.
    • Building on Intel now functions again, but there are many known problems with the browser still (see the section in Building the browser).
    • If your compiler is compiled for 10.5, the browser will use the 10.4 SDK, but wind up linked against your 10.5-only libgcc, libatomic and libstdc++. If you intend to use your build on a 10.4 system, you will need to replace them with 10.4-compatible libraries. The easiest source is a TenFourFox binary package; see below (under Distributing the executable). If this is not acceptable, it is also possible, though involved, to make a cross-building gcc; see issue 52.
    • clang is not supported. However, it may be possible to do a cross-build on 10.6.8 using a cross-compiling version of gcc. Good luck, let us know if it works. We are not aware of any presently working way to get later versions of OS X to build TenFourFox, but this script may help. If you get any of this working, post an issue with how you did it!
  • Install MacPorts, using the Tiger dmg for 10.4 or the Leopard dmg for 10.5. Note that MacPorts does not always have the most current release up to date for 10.4 or 10.5, but you can still get whatever the most recently updated historical version was from the MacPorts download repository -- you need only grab the most recent 10.4 or 10.5 version available, because we will immediately force it to self-update in the next step (read on).

  • We need to install not only Git, a new Python and a new gcc, but we'll also need Mozilla's preferred autoconf and a newer GNU make to get around various bugs in Tiger's included version. Get a cup of coffee, because MacPorts likes to install everything else as a prereq for everything else.

      sudo port -v selfupdate
      sudo port install git libidl autoconf213 gmake python27 gcc48 freetype
    
    • MacPorts' gcc48 package also includes updated bintools, including its own copy of the Xcode 3 linker with a bug fix to enable TenFourFox's XUL to link correctly. The old ported Xcode 3 ld used to build TenFourFox 17 and earlier is no longer needed.
  • Stripped builds require special handling due to an apparent compiler bug, using a modified strip binary (renamed strip7 so it does not conflict with the regular strip) that ignores the variant N_SECTs this compiler can generate. You should not use this strip tool for other purposes, as it is intentionally loose with the specification, and you do not need to install it if you are only building a debug or non-stripped build for your own use. Decompress the binary and put it in /opt/local/bin/strip7 (the configure script is hardcoded to this location). You can get it from SourceForge.

  • Finally, you must install the TenFourFox debugger, because the gdb available with any PowerPC Xcode does not properly grok debugging symbols generated by later gcc versions. At least patchlevel 2 is required for the current version of 10.4Fx. Decompress and copy the binary to /usr/local/bin/gdb7 or wherever it is convenient. Although you can use it to replace your current gdb, it's probably safer that you do not. You can also get it from SourceForge.

Building the browser

  1. In your nice fat source drive, git clone https://github.com/classilla/tenfourfox (or the desired release or revision).

  2. Select your desired configuration (any of the *.mozcfg files) and copy it to .mozconfig in the root of the repo. These configurations should be self-explanatory. For the gory details, see Configuring Build Options at MDN, but in general, you should avoid changing the standard build configurations unless you know exactly what you are doing. Use the mozconfigs that came with this most current revision if at all possible, because the options are periodically upgraded and changed as the build system gets modified, and old configurations may fail inexplicably.

    • G4 and G5 owners: if you want to test the AltiVec (VMX) code paths apart from the standard mozcfg files, you should include --enable-tenfourfox-vmx in your custom .mozconfig or it will be compiled without AltiVec/VMX acceleration.
    • G5 owners ONLY: if you want to test the G5-specific code paths apart from the standard G5.mozcfg, you should include --enable-tenfourfox-g5 in your custom .mozconfig or the regular code paths will be used instead of the G5-specific ones. This does not enable VMX; if you want that, specify it too. You may also need to add -D_PPC970_ to your compiler strings so that non-Mozilla libraries and JavaScript properly select the correct architecture optimizations. Although you don't need this, the browser will run substantially more poorly if you don't.
    • Intel owners ONLY: TenFourFox is now known to build on Intel systems again, but you may need to write your own .mozconfig to tailor it to your system. A sample intel-Yonah.mozcfg file for Yonah Intel systems is currently included which you can use as a basis. Currently there are many known bugs and certain features don't work other than basic functionality. Don't use the modified strip on Intel; also, we don't ship a debugger for this platform either right now. There is no support for building on Intel, but if you find and fix issues, pull requests will be accepted as long as they don't regress Power Macs.
  3. (Optional but recommended) Edit netwerk/protocol/http/OptimizedFor.h and set the string to something human-readable about the configuration you're building for. This string should be relatively short, and will appear after the TenFourFox/ in the user agent string.

    • Warning: if you don't do something like git update-index --skip-worktree netwerk/protocol/http/OptimizedFor.h, this change will end up in any pull requests you issue and we won't accept them!
  4. (Optional) If you want to change the reported version numbers, alter browser/config/version.txt for the reported browser version, browser/config/version_display.txt for the displayed browser version (this is where we usually put the long FPR string), and config/milestone.txt for the reported Gecko version.

    • We don't allow these changes in pull requests either! Consider setting skip-worktree on these files also if you change them!
  5. Once you're ready, if you are cleaning out an old build, or you need to "clobber" the current build, be sure to rm -rf configure obj-ff-dbg/ first. Then,

     autoconf213
     gmake -f client.mk build 
    

Known build issues

  • Until issue 202 is fixed, you will get spurious errors setting up the Python environment. You can ignore these for now.
  • If your build seems to intermittently crash with an internal compiler error, you may be running out of memory. Resuming the build with gmake -f client.mk build will usually get past the block (it will pick up where it left off). Alternatively, remove -j2 from the .mozconfig build flags: this will only run one compiler instance at once, so the build will be slower, but it will be much less likely to experience memory pressure.
  • If you get a message saying you need to "clobber" your build, clean your previous build as instructed above.
  • If you are making an optimized build, you will get warnings about N_SECT while linking and stripping XUL. These are harmless. If you actually get an error and it doesn't build, then somehow you are using the original strip. Check your binaries carefully.

Running and debugging

If the build worked, try out your binary in the TenFourFox debugger. We will assume you installed it to /usr/local/bin/gdb7 or somewhere else otherwise suitable in your path:

cd obj-ff-dbg/dist/TenFourFox.app/Contents/MacOS (or, if in Debug mode, TenFourFoxDebug.app)

gdb7 firefox

At the (gdb) prompt, run

If the build appeared to work, but the browser crashes in an unusual objc symbol when you try to run it or quit, you may have encountered issue 169 which is due to incorrect linker code generation. Make sure you are using the correct ld (see the prerequisites section).

If you receive strange Die errors in the debugger and backtraces don't work properly, you need to upgrade your debugger (or you're using the one that Apple provided, which won't work anymore).

Distributing the executable

Because the new compiler links against its own libgcc, libatomic and libstdc++, if you intend to make a build to generally distribute or use on another computer, you will need to include these libraries and update the linkage to point to the included copies. The tool 104fx_copy.sh (in the root) will help you with this. Make it executable with chmod +x if necessary, then simply type ./104fx_copy.sh [destination name.app] and the built binary will be copied to the destination name (which should be the new app bundle filename) and its linkages updated to be internal. This should be the last step you do before release since the binary it generates is completely standalone and disconnected from the build system.

If you built on 10.5 with a compiler that was also built on 10.5, your built browser will only work on 10.5 (despite using the 10.4 SDK) because the gcc 4.8 libgcc, libatomic and libstdc++ are linked against the 10.5 SDK, not 10.4. The easiest way to solve this problem is to replace libgcc_s.1.dylib, libatomic.1.dylib and libstdc++.6.dylib in your browser package with the ones from a "real" TenFourFox application package and then your build will "just work" on both operating systems. If this is not acceptable, it is possible, though involved, to build a cross-compiling 10.5 gcc that will create 10.4-compatible binaries; see issue 52.

Keeping up

Your repo is now a fully functional clone of the TenFourFox source repository, and you can simply git pull to get new changes (merging them with your local changes as appropriate). You can then incrementally update your build with gmake -f client.mk build to incorporate the new changes. Make sure the browser isn't running!