Faster Teambuilder Builds

Материал из Wiki.crossplatform.ru

Перейти к: навигация, поиск
Image:qt-logo_new.png Image:qq-title-article.png
Qt Quarterly | Выпуск 13 | Документация


by Eirik Aavitsland

To speed up compilations, many Qt users -- and indeed the Trolltechdevelopers themselves -- use Trolltech's Teambuilder product todistribute the build load to all available Unix machines on the localnetwork. In this article, we will give some hints on how to useTeambuilder to its full potential.

Содержание

Some developer teams are lucky enough to have only one targetplatform to worry about. In such teams, all developers canrun the same operating system and compiler on theirdevelopment machines, and the task of Teambuilder is simply todistribute the compilation jobs -- i.e., the individual sourcefiles of the build -- to the machine farm for parallelcompilation.

Unfortunately, the reality is often different for developer teams using Qt:multiple target platforms is often the reason Qt was selected in thefirst place. And more often than not, there are some machines with adifferent operating system or compiler version accessible on thelocal network, machines with idle CPU cycles that one would dearlylike to use in the compilation farm. Here, we will see how to bestuse Teambuilder in such heterogeneous environments.

[править] Coping with Different Compiler Versions

By default, Teambuilder assumes that all compilers in thefarm with the same name as the one requested (e.g., gcc)are compatible, so all of them can be used to generate objectfiles that will happily link together at the end of thebuild. In reality, the output from different versions of thesame compiler can be binary incompatible. In particular, this isthe case with GCC versions 3.2 and 3.3.

The solution is to tell Teambuilder which compiler versions you willallow to compile your project. This is done by setting theTEAMBUILDER_CC_VERSION environment variable in the shell you usefor compilation. For example, if you are running GCC 3.3.3, thefollowing command (which you can type directly or add to your.bashrc file) will allow only 3.3.x versions of GCC to beused for your compilation jobs:

export TEAMBUILDER_CC_VERSION=3.3.*

Teambuilder understands the wildcard constructs *, ?, and[123] with their usual meanings.

[править] Coping with Different OSes and Architectures

Teambuilder automatically detects the operating system andhardware architecture of the machines in the farm. Intbmonitor, this is displayed in the form [OS:arch]. Bydefault, compilation jobs are only distributed to machineswith the same operating system as the one initiating thebuild.

In the case where the farm contains machines withincompatible hardware architectures, but which run the sameoperating system, you will want to tell Teambuilder to onlyuse machines with the same architecture as your own for yourbuilds. This is done through the TEAMBUILDER_SYSTEMenvironment variable. For example, if there are 32-bit and64-bit machines running Linux in the farm, and you arebuilding for 64-bit, set the variable like this:

export TEAMBUILDER_SYSTEM=Linux:x86_64


[править] The Next Level: Cross-Compilers

Rather than simply excluding a machine with another hardwarearchitecture than your own, it is very tempting to use the machine'sidle CPU cycles for your own builds by installing a cross-compiler on it.

A natural choice for this is GCC. To set it up as a cross-compiler,your best bet is probably to search the net for pre-built packagesfor your host and target systems, or to use the tools and helpprovided at Dan Kegek's homepage to build your own.

When the cross-compiler is in place, we just need to tell Teambuilder aboutit. On the machine with the cross-compiler, locate (orcreate) tbdaemon's configuration file. (It is"/etc/tbdaemon.conf" if tbdaemon is started by root; otherwiseit is " /.tbdaemonrc".) If, for example, you have installed a64-bit cross-compiling GCC on a 32-bit Linux machine, theconfiguration file must contain the following lines:

[Settings]
Compilers=gcc,g++,/path/to/crosscompiler/gcc[Linux:x86_64]

After restarting tbdaemon, Teambuilder will use the crosscompiler for builds where TEAMBUILDER_SYSTEM is set toLinux:x86_64. Note that having a Compilers entry in theconfiguration file will disable tbdaemon's normalauto-discovery of the native compilers, so you will need toinclude all those that you want to use. Also note that the Compilersline should contain no unnecessary whitespace.

Summing up, we have seen how to use Teambuilder in heterogeneousmachine farms. As always, though, remember to not let your bosses inon the secret of speeding up your builds by distributing thecompilation jobs -- they just might get funny ideas about not buyingnew and faster machines this year, and how will you get the necessaryiron for playing Half-Life 2 then?