From Fedora Project Wiki

(How does it look like?)
Line 87: Line 87:
==== Quiet package rebuild ====
==== Quiet package rebuild ====
===== Failed rebuild =====
* <code>./gold-rebuild --quiet --color --rebuild --package kernel</code>
* <code>./gold-rebuild --quiet --color --rebuild --package kernel</code>
Line 110: Line 112:
  * Info ./gold-rebuild finishing with exit code: 1
  * Info ./gold-rebuild finishing with exit code: 1
===== Passed rebuild =====
* ./gold-rebuild --quiet --color --rebuild --package hardlink
''Just the parts which differs from failed rebuild''

Revision as of 14:59, 5 March 2010

Introducing GNU gold

Gold is a linker for ELF files. It was added to binutils March, 2008 and first released in binutils version 2.19. Gold is developed by Ian Lance Taylor and a small team at Google with participation of general GNU community. The motivation for writing gold was to make a linker that is faster than the GNU linker, especially for large applications coded in C++. Gold is known to work on x86 and x86-64, PowerPC (partially) and ARM. Gold is intended to link faster but may not support that much architectures as original GNU ld does however distributions, like Fedora, which primary supports GNU gold supported architectures may make it default linker in the future.

gold`s state in Fedora

GNU gold is in Fedora since binutils 2.19 release but was not built until recently. In binutils- (F-13/rawhide that time) we build gold as alternative linker to ld. Via /usr/sbin/alternatives we have /usr/bin/ld which is symbolic link to either /usr/bin/ld.bfd (original ld), or /usr/bin/ By default /usr/bin/ld links to BFD ld but altering spec file is easily possible.

Before Fedora may uses gold as primary linker, several things have to be assured

  • gold is stable and feature full, so linked apps generally work,
  • gold is supported and available for Fedora-supported architectures,
  • gold gives speed benefits, and
  • Fedora application stack is capable of being linked by gold

gold-rebuild script


gold-rebuild is a Bash script which utilizes Mock, rpm-build, createrepo, yum and gold itself to rebuild, hence the name, Fedora packages or even whole comps groups and link resulted object files with gold instead of ld. For this purpose builds daily binutils CVS snapshot from trunk as part of Rawhide binutils SRPM and installs resulted new binutils packages to repository reachable by Mock. If rebuild of particular package fails it`s logged and failure is guess-classified to state what might be the problem.

General Capabilities

Usage: gold-rebuild [OPTION]...
Link programs with gold linker.

  -c, --color              Output in colors.
  -r, --rebuild            Rebuild current binutils snapshot,
                           create Yum for Mock repository and use it.
                           Without --rebuild we use distribution binutils.
  -g, --group <GROUP>      Select Fedora comps GROUP to rebuild.
  -p, --package <P1,...>   Comma separated list of packages to
                           rebuild. Mutual exclusive with '-g'.
  -t, --target <ARCH>      Target arch (e.g. i686 at x86_64 box).
  -o, --os-release <OS>    Fedora release from which to take
                           packages (e.g. 12, 13, ...).
  -h, --help               Display this help and exit.
  -v, --version            Output version information and exit.
  -q, --quiet              Be as quiet much as possible.
  -d, --debug              Be as verbose as possible.
  gold-rebuild -c -r          Run with colors enabled as well as with
                              rebuild on.
  gold-rebuild                Run with defaults (colors=off, etc).

Report gold-rebuild bugs to
gold-rebuild home page: <>

Linear description of how-it-works

Code should be well commented so you shouldnt have much problems reading and understanding it

  1. First we parse options and set several variables determining whether we are "quiet" or "verbose", building whole comps group or just several packages, etc.
  2. If script is asked for rebuild of binutils from CVS, it
    1. Downloads latest binutils package from Koji and installs it on localhost
    2. Gets binutils.tar.bz2 and places it to RPM SOURCES/ directory
    3. Several necessary edits to Rawhides specfile is necessary - Version and Release fields are bumped to include snapshot date, recent upstream incorporated patches are turned off (one has to specify them in sources now...)
    4. SRPM package is built and we hand it to mock for rebuild
    5. binutils packages are built and placed into shiny new repository, createrepo is ran on it
    6. repository is added (if necessary) and enabled to be on for other packages when are being rebuilt
  3. Selected SRPM packages for rebuild and linage by gold are downloaded to cache, dupes are removed
  4. Logging facilities are being set
  5. Script now iterates for every SRPM package
    1. Mock is asked to rebuild package $PK1
    2. Log is archived for later investigation
    3. If rebuild passed - good for us! - size of produced packages and time spent are logged, otherwise script investigates roots of the problem
      1. Last lines from log are being removed known to be bogus lines (such as ^ *user or ^ *group or ^make[[0-9]*]: [LE].*), actually last 15 lines are being inspected.
      2. Error classification.
    4. When error type is guessed, error message is written out
  6. After all packages passed or failed to build'n'link statistics is produced (e.g. TOTAL: 99 PASS: 84 FAIL: 15)
  7. As last step, all logs are archived

Classification looks like this

   PKG    - problem in package
   LD     - problem in linker
   GCC    - problem in GCC
   FEDORA - e.g. we build i386-only package on PPC

How does it look like?

Quiet package rebuild

Failed rebuild
  • ./gold-rebuild --quiet --color --rebuild --package kernel

* Info		./gold-rebuild started
* Warning 	Mock will be run as root, this is not recomended
* Info		Fedora release: 12 | target: x86_64
* Info		We will build latest binutils tarball and create repo from build RPMs
* Info		Download latest Fedora (rawhide) binutils SRPM which we use as base for new RPMs
warning: user mockbuild does not exist - using root
warning: group mockbuild does not exist - using root
* Info		Download latest binutils tarball (18 MB)
2010-03-05 15:04:40 URL: [18738162] -> "/home/newman/rpmbuild/SOURCES/binutils.tar.bz2" [1]
* Info		Repository will be now: disabled
* Info		Creating binutils RPMs
ERROR: Exception(/home/newman/rpmbuild/SRPMS/binutils-2.20.51-0.20100305.17.fc12.src.rpm) Config(fedora-12-x86_64) 7 minutes 15 seconds
ERROR: Command failed. See logs for output.
 # ['bash', '--login', '-c', 'rpmbuild -bb --target x86_64 --nodeps builddir/build/SPECS/binutils.spec']
* Error 	Failed to build binutils snapshot from Fri Mar  5 15:12:06 CET 2010
* Info		Repository will be now: disabled
* Info		./gold-rebuild finishing with exit code: 1

Passed rebuild
  • ./gold-rebuild --quiet --color --rebuild --package hardlink

Just the parts which differs from failed rebuild {{{